Exemplo n.º 1
0
        public async Task MountVolume(Volume volume, BobApiClient bobApiClient)
        {
            if (volume.IsMounted && !volume.IsReadOnly)
            {
                logger.LogDebug($"{volume} is already mounted");
                return;
            }
            if (!volume.Mountable)
            {
                logger.LogDebug($"{volume} can't be mounted");
                return;
            }

            var mountPath = neededInfoStorage.FindMountPath(volume);

            if (mountPath != null)
            {
                var path = mountPath?.Path;
                if (!Directory.Exists(path))
                {
                    await processInvoker.InvokeSudoProcess("mkdir", path);
                }
                if (await TryCleanPreviousData(volume, bobApiClient, mountPath.Value) && !volume.IsMounted)
                {
                    logger.LogInformation($"Mounting {volume} to {mountPath}");
                    await processInvoker.InvokeSudoProcess("mount", volume.DevPath.Path, path);

                    await processInvoker.SetDirPermissionsAndOwner(path, configuration.MountPointPermissions, configuration.MountPointOwner);

                    logger.LogInformation($"Successfully mounted {volume} to {mountPath}");
                }
            }
            else
            {
                logger.LogInformation($"No mount path found for {volume}");
            }
        }
Exemplo n.º 2
0
 private async Task RunScript(string script) => await processInvoker.InvokeSudoProcess("bash", "-c", script);
Exemplo n.º 3
0
        private async Task CreatePrimaryVolume(PhysicalDisk physicalDisk)
        {
            await processInvoker.InvokeSudoProcess("parted", physicalDisk.DevPath.Path, "--script", "--", "mklabel", "gpt");

            await processInvoker.InvokeSudoProcess("parted", physicalDisk.DevPath.Path, "--script", "--", "mkpart", "primary", "0%", "100%");
        }
Exemplo n.º 4
0
 private async Task <IList <string> > InvokeLshw()
 {
     return(await processInvoker.InvokeSudoProcess("lshw", "-c", "storage", "-c", "disk", "-c", "volume"));
 }