ssfs annotate ssfs-sh @ rev 45

ssfs-sh: Handle rsync request first
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jun 12 18:16:52 2011 +0200 (2011-06-12)
parents 007200b945e3
children d1384d21313d
rev   line source
pankso@29 1 #!/bin/sh
pankso@29 2 #
pankso@29 3 # Ssfs users SHell - Chroot user into the virtual disk on login. This tool must
paul@33 4 # be installed on the server and in the vdisk chroot, it is executed when logging
paul@33 5 # in and when chrooting.
pankso@29 6 #
pankso@40 7 # Copyright (C) SliTaz GNU/Linux - BSD License
pankso@40 8 # Author: Christophe Lincoln <pankso@slitaz.org>
pankso@40 9 #
pankso@29 10
pankso@45 11 # Handle rsync first, user is chrooted after.
pankso@45 12 case "$@" in
pankso@45 13 *rsync*) exec /bin/sh "$@" ;;
pankso@45 14 esac
pankso@45 15
paul@33 16 # Ssfs server config doesn't exist in chroot.
pankso@29 17 if [ -f /etc/ssfs/ssfs-server.conf ]; then
pankso@29 18 . /etc/ssfs/ssfs-server.conf
pankso@29 19 root=$SSFS_CHROOT
pankso@29 20 # Make sure it's a valid Ssfs user.
pankso@29 21 [ -d "$root/home/$USER" ] || exit 0
pankso@41 22 exec chroot $root /bin/ssfs-sh $@
pankso@29 23 else
pankso@29 24 # Chroot will drop user into /, so set new HOME and cd. Set also
paul@33 25 # some env variables but don't source any profile.
pankso@42 26 cmd=$(echo $@ | sed s'/-c //') && clear
pankso@38 27 echo -e "\n\033[1m Welcome to the Ssfs SHell $USER\033[0m\n"
pankso@39 28 PS1='\u@\h\e[0m:\e[1;34m\w\e[0m\$ '
pankso@29 29 HOME=/home/$USER
pankso@29 30 SYNC=$HOME/Sync
pankso@29 31 SHELL=/bin/sh
pankso@42 32 export PS1 HOME SYNC SHELL
pankso@42 33 cd $HOME
pankso@42 34 [ "$cmd" ] || exec /bin/sh
pankso@42 35 exec /bin/sh -c "$cmd"
pankso@29 36 fi