ns-tools

Namespace utilities to reuse Open Source packaging efforts.
git clone git://r-36.net/ns-tools
Log | Files | Refs | README | LICENSE

ns-unprepare (921B)


      1 #!/bin/sh
      2 
      3 doforce=0
      4 [ "$1" = "-f" ] && doforce=1 && shift 1
      5 
      6 if [ $# -lt 1 ];
      7 then
      8 	printf "usage: %s ns\n" "$(basename $0)" >&2
      9 	exit 1
     10 fi
     11 
     12 nsroot="$(ns-root "$1")"
     13 [ $? -gt 0 ] && exit $?
     14 
     15 [ -e "$nsroot/.ns/preparedonboot" -a $doforce -eq 0 ] && exit 0
     16 [ ! -e "$nsroot/.ns/prepared" -a $doforce -eq 0 ] && exit 0
     17 
     18 if [ $(id -u) -ne 0 ];
     19 then
     20 	printf "ns-unprepare needs to be run with root rights.\n" 2>&1
     21 	exit 1
     22 fi
     23 
     24 MOUNTFS=""
     25 UMOUNTFS=""
     26 TOUCHFILES=""
     27 COPYFILES=""
     28 [ -e "$nsroot/.ns/rc.conf" ] && . "$nsroot/.ns/rc.conf"
     29 
     30 if [ ! -d "$nsroot" ];
     31 then
     32 	printf "$nsroot does not seem to be a valid directory.\n" >&2
     33 	exit 1
     34 fi
     35 
     36 ns-umount "$nsroot" >/dev/null
     37 
     38 #ufilesystems="$UMOUNTFS proc sys tmp dev/pts mnt home run etc/conn etc/svc devel dev"
     39 #for m in $ufilesystems;
     40 #do
     41 #	umount "$nsroot/$m"
     42 #done
     43 
     44 rm -f "$nsroot/.ns/prepared"
     45 rm -f "$nsroot/.ns/preparedonboot"
     46 printf "$nsroot has been unprepared.\n"
     47 
     48 exit 0
     49