Esempio n. 1
0
 public static void ThrowOnError(Bash bash)
 {
     if (!bash.Ok)
     {
         throw Errors.NewProcessError(bash.command, bash.ErrLines.Take(1).ToList(), bash.ExitCode);
     }
 }
Esempio n. 2
0
        public void RecursiveBindMount(PathName source, PathName target)
        {
            var bind = MountRun($"mount --verbose --rbind {source} {target}");

            this.mountPoints.Push(new MountPoint(target, true));

            Bash.ThrowOnError(bind);
        }
Esempio n. 3
0
        public void ProcfsMount(PathName target)
        {
            var bind = MountRun($"mount --verbose --types proc proc {target}");

            this.mountPoints.Push(new MountPoint(target, false));

            Bash.ThrowOnError(bind);
        }
Esempio n. 4
0
        public static Bash RemoveDirectory(PathName directory)
        {
            var bash = new Bash()
                       .Command($"rm --recursive --force --verbose \"{directory}\"")
                       .WithProgress()
            ;

            return(bash.Run());
        }
Esempio n. 5
0
        public static void DoTheChrootBash(Pogo pogo)
        {
            Mono.Unix.Native.Syscall.chroot(pogo.Box.Merged.Full);

            var bash = new Bash()
                       .Command($"bash")
                       .Directory("/root")
                       .Interactive()
                       .Run();
        }
Esempio n. 6
0
        public static Bash TarExtract(PathName archivePath, PathName extractPath)
        {
            var bash = new Bash()
                       .Command($"tar --extract --verbose --owner=0 --group=0 --file \"{archivePath}\"")
                       .Directory(extractPath)
                       .WithProgress()
            ;

            return(bash.Run());
        }
Esempio n. 7
0
        private void UnMountOne(ChrootBox box, MountPoint mountPoint, Progress progress)
        {
            var flag = (mountPoint.Recursive ? "--recursive" : string.Empty);

            var umount = new Bash()
                         .Command($"umount --verbose {flag} {mountPoint.Path}")
                         .WithProgress(progress)
                         .Run();

            Bash.ThrowOnError(umount);
        }
Esempio n. 8
0
        public void MountOverlay()
        {
            this.box.Base.CreateDirectory();
            this.box.Changes.CreateDirectory();
            this.box.Work.CreateDirectory();
            this.box.Merged.CreateDirectory();

            var lowerdir = $"/:{this.box.Base}:{this.box.Pogo.Root}";
            var upperdir = box.Changes;
            var workdir  = box.Work;

            var options = $"lowerdir={lowerdir},upperdir={upperdir},workdir={workdir}";
            var command = $"mount --verbose --types overlay overlay --options {options} {box.Merged}";
            var mount   = MountRun(command);

            this.mountPoints.Push(new MountPoint(box.Merged, false));

            Bash.ThrowOnError(mount);
        }
Esempio n. 9
0
        public static Bash Checker()
        {
            var bash = new Bash()
                       .Command($"env")
                       .WithEnviroment(env =>
            {
                env["PATH"] = "/bin:/usr/bin:/root/LiFo/bin";
                env.Remove("PROMPT_COMMAND");
                env.Remove("PS1");
            })
                       .Run();

            bash.Run();

            foreach (var output in bash.Outputs)
            {
                Terminal.WriteLine(output);
            }

            return(bash);
        }