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