ssfs diff ssfs-server @ rev 34

Samlls improvment to server tool Shell
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jun 12 13:31:26 2011 +0200 (2011-06-12)
parents 95b88686a283
children 72c49d4cc4e9
line diff
     1.1 --- a/ssfs-server	Sun Jun 12 12:02:48 2011 +0100
     1.2 +++ b/ssfs-server	Sun Jun 12 13:31:26 2011 +0200
     1.3 @@ -7,9 +7,10 @@
     1.4  #
     1.5  
     1.6  app=$(basename $0)
     1.7 -cache=/var/cache/ssfs
     1.8  [ -f "/etc/ssfs/$app.conf" ] && . /etc/ssfs/$app.conf
     1.9  [ -f "./data/$app.conf" ] && . ./data/$app.conf
    1.10 +state=/var/lib/ssfs
    1.11 +share=/usr/share/ssfs
    1.12  
    1.13  # Be sure we're root.
    1.14  [ $(id -u) != 0 ] && gettext "You must be root to run:" && \
    1.15 @@ -210,15 +211,25 @@
    1.16  		gettext -e "\nBack to the host system:"
    1.17  		echo -e " $(hostname)\n" ;;
    1.18  	gen-vdisk)
    1.19 +<<<<<<< local
    1.20 +		# Generated a virtual disk with a minimal chroot for Ssfs users home.
    1.21 +		rootfs=$share/rootfs
    1.22 +=======
    1.23  		# Generate a virtual disk with a minimal chroot for Ssfs users home.
    1.24 +>>>>>>> other
    1.25  		if [ -d "$root/bin" ]; then
    1.26 -			gettext -e "A chroot already exists in:"; echo " $root"
    1.27 +			gettext "A chroot already exists in:"; echo " $root"
    1.28 +			exit 0
    1.29 +		fi
    1.30 +		if [ ! -f "$rootfs/etc/busybox.conf" ]; then
    1.31 +			gettext "Missing package ssfs-busybox"; echo
    1.32  			exit 0
    1.33  		fi
    1.34  		echo ""
    1.35 -		gettext "Creating chroot in:"; echo " $root"
    1.36 +		gettext "Creating Sshs vdisk minimal chroot"; echo
    1.37  		separator
    1.38 -
    1.39 +		echo "Chroot path: $root"
    1.40 +		
    1.41  		# Create vdisk if missing.
    1.42  		if [ ! -f "$vdisk" ]; then
    1.43  			gettext "Creating virtual disk:"; echo " $vdisk ${size}Gb"
    1.44 @@ -233,22 +244,35 @@
    1.45  		# Create a radically minimal chroot with all libs in /lib.
    1.46  		gettext "Creating base files..."
    1.47  		mkdir -p $root && cd $root
    1.48 -		for d in etc tmp lib usr home root
    1.49 +		for d in etc lib home root
    1.50  		do
    1.51  			mkdir -p $d
    1.52  		done && status
    1.53 -		cp -a /etc/slitaz-release $root/etc
    1.54 -		echo "root:x:0:0:root:/root:/bin/sh" > etc/passwd
    1.55 -		echo "root::13525:0:99999:7:::" > etc/shadow
    1.56 -		echo "root:x:0:" > etc/group
    1.57 -		echo "root:*::" > etc/gshadow
    1.58 +
    1.59 +		# /etc files.
    1.60 +		cp -f /etc/slitaz-release $root/etc
    1.61 +		if [ ! -f "$root/etc/passwd" ]; then
    1.62 +			echo "root:x:0:0:root:/root:/bin/sh" > $root/etc/passwd
    1.63 +			echo "root::13525:0:99999:7:::" > $root/etc/shadow
    1.64 +			echo "root:x:0:" > $root/etc/group
    1.65 +			echo "root:*::" > $root/etc/gshadow
    1.66 +		fi
    1.67 +
    1.68 +		# /dev nodes.
    1.69  		#mknod -m 666 $root/dev/null c 1 3
    1.70 -		
    1.71 -		gettext "Setting files permissions..."
    1.72 -		chmod 640 etc/shadow etc/gshadow
    1.73 -		chmod 0700 root && chmod 1777 tmp
    1.74 +
    1.75 +		# Ssfs Busybox package install files in $cache and allow easy vdisk
    1.76 +		# upgrade folowing SliTaz repo.
    1.77 +		gettext "Installing Ssfs Busybox..."
    1.78 +		cp -a $rootfs/* $root
    1.79  		status
    1.80  
    1.81 +<<<<<<< local
    1.82 +		gettext "Setting files permissions..."
    1.83 +		chmod 0640 $root/etc/*shadow
    1.84 +		chmod 0700 $root/root && status
    1.85 +		chmod 4755 $root/bin/busybox
    1.86 +=======
    1.87  		# Busybox without deps (get && extract). No system comands are allowed
    1.88  		# in /etc/busybox.conf to restrict SSH'd users.
    1.89  		gettext "Installing Busybox..."
    1.90 @@ -265,8 +289,8 @@
    1.91  			> $root/etc/busybox.conf
    1.92  		echo -e "\n[SUID]" >> $root/etc/busybox.conf
    1.93  		echo -e "su = --- root.root" >> $root/etc/busybox.conf
    1.94 +>>>>>>> other
    1.95  		chmod 0600 $root/etc/busybox.conf
    1.96 -		status
    1.97  
    1.98  		# Glib minimal libs, use host lib since package should be installed
    1.99  		# from same repo.
   1.100 @@ -274,12 +298,19 @@
   1.101  		for l in  ld-*.*so* libc-*.*so libc.so.* libnss_files*
   1.102  		do
   1.103  			cp -a /lib/$l* $root/lib
   1.104 -		done && chmod 0644 $root/lib/* && status
   1.105 +		done && status
   1.106  		
   1.107  		# Ssfs chroot SHell
   1.108  		gettext "Installing Ssfs SHell..."
   1.109  		install -m 0755 /bin/ssfs-sh $root/bin
   1.110  		status
   1.111 +
   1.112 +		# List of all system files.
   1.113 +		cd $root
   1.114 +		for d in bin etc lib sbin
   1.115 +		do
   1.116 +			find ./$d | sed s'/^.//'
   1.117 +		done
   1.118  		
   1.119  		size=$(du -sh $root | awk '{print $1}')
   1.120  		separator
   1.121 @@ -303,19 +334,19 @@
   1.122  		separator && echo "" ;;
   1.123  	clean-vdisk)
   1.124  		# clean up the vdisk storage chroot.
   1.125 -		if [ ! -d "$root/bin" ] || [ ! -d "$root/usr" ]; then
   1.126 +		if [ ! -d "$root/bin" ] || [ ! -d "$root/lib" ]; then
   1.127  			gettext -e "No chroot found in:"; echo " $root"
   1.128  			exit 0
   1.129  		fi
   1.130  		gettext -e "\nCleaning virtual disk\n"
   1.131  		separator
   1.132 -		gettext "Changing directory to:"; echo " $root"
   1.133 +		echo "Chroot path: $root"
   1.134  		cd $root
   1.135  		for dir in *
   1.136  		do
   1.137  			size=$(du -sh $dir | awk '{print $1}')
   1.138  			case "$dir" in
   1.139 -				home|root|lost*)
   1.140 +				etc|home|root|lost*)
   1.141  					gettext "Skipping:"; echo " $dir $size *" ;;
   1.142  				*)
   1.143  					gettext "Removing:"; echo " $dir $size"