=== added file 'sbin/ns_execline.zsh' --- sbin/ns_execline.zsh 1970-01-01 00:00:00 +0000 +++ sbin/ns_execline.zsh 2020-12-17 14:59:24 +0000 @@ -0,0 +1,54 @@ +#!/bin/zsh +setopt no_unset +el_escape() { # escape for execline + RESULT="\"${${${1}//\\/\\\\}//\"/\\\"}\"" +} + +ROOTSRC=$1 +shift +el_escape $ROOTSRC; ROOT_EL=$RESULT + +: ${NS_TMPFS:=mnt/ns} +el_escape $NS_TMPFS; NS_TMPFS_EL=$RESULT + +: ${NS_BIN_DIR:=/mnt/volumes/containers/bin} +el_escape $NS_BIN_DIR:A; NS_BIN_EL+=( $RESULT ) + +#: ${IF_BIN:=/mnt/volumes/containers/bin/if} +#: ${BUSYBOX_BIN=/mnt/volumes/containers/bin/busybox} +#binaries=() +#el_escape $IF_BIN:A; binaries+=( $RESULT ) +#el_escape $BUSYBOX_BIN:A; binaries+=( $RESULT ) + +printf '%s\n' "fdmove 0 3" +printf '%s\n' "if { mount --rbind $ROOT_EL /mnt/chroot }" +printf '%s\n' "cd /mnt/chroot" +printf '%s\n' "foreground { cp /etc/resolv.conf etc/ }" +printf '%s\n' "if { mount -t proc proc proc }" +printf '%s\n' "if { s6-mount -nwt tmpfs -o nosuid,dev,mode=0755 dev dev }" +printf '%s\n' "if { mknod -m 666 dev/null c 1 3 }" +printf '%s\n' "if { mknod -m 666 dev/full c 1 7 }" +printf '%s\n' "if { mknod -m 666 dev/ptmx c 5 2 }" +printf '%s\n' "if { mknod -m 644 dev/random c 1 8 }" +printf '%s\n' "if { mknod -m 644 dev/urandom c 1 9 }" +printf '%s\n' "if { mknod -m 666 dev/zero c 1 5 }" +printf '%s\n' "if { mknod -m 666 dev/tty c 5 0 }" +printf '%s\n' "if { mkdir dev/shm dev/pts }" +printf '%s\n' "if { mount -t devpts devpts dev/pts }" +printf '%s\n' "if { s6-mount -nwt tmpfs -o nosuid,nodev,mode=1777 shm dev/shm }" +printf '%s\n' "if { mount -o remount,ro dev }" +if [[ $+NS_FSTAB == 1 && -n $NS_FSTAB ]]; then + printf '%s\n' "if { mount -a --fstab \"${${NS_FSTAB//\\/\\\\}//\"/\\\"}\" }" +fi +if [[ $+NS_EXTRA == 1 && -n $NS_EXTRA ]]; then + printf '\n%s\n\n' "$NS_EXTRA" +fi +printf '%s\n' "if { s6-mount -nwt tmpfs -o nosuid,nodev,mode=700 mnt_ns $NS_TMPFS_EL }" +printf '%s\n' "if { mkdir $NS_TMPFS_EL/oldroot $NS_TMPFS_EL/bin }" +printf '%s\n' "if { s6-hiercopy $NS_BIN_EL $NS_TMPFS_EL/bin }" +printf '%s\n' "if { pivot_root . $NS_TMPFS_EL/oldroot }" +awk -vROOT=/$NS_TMPFS/oldroot -vBIN=/$NS_TMPFS_EL/bin '$5 {print BIN"/if { "BIN"/if -n -t { "BIN"/busybox umount "ROOT $5" } "BIN"/busybox umount -l "ROOT $5" }" }' /proc/self/mountinfo | tac +printf '%s' "./$NS_TMPFS_EL/bin/busybox chpst -/ ." +#printf '%s' "./$NS_TMPFS_EL/bin/chpst -/ ." +printf ' "%s"' "$@" +printf '\n'