tbrehm
2013-02-22 526b997c9891a796b152cdbab8e329b356b1f596
commit | author | age
6a95c8 1 #!/bin/bash
D 2
3 # Add user to the jailkit chroot
4
5 #
6 # Usage: ./create_jailkit_user username /path/to/chroot/ /home/webuser /bin/bash web2 /home/web2
7 #
8
9 # Sanity check
10
11 if [ "$1" = "" ]; then
12         echo "    Usage: ./create_jailkit_user username /path/to/chroot/ /home/webuser /bin/bash"
13         exit
14 fi
15
16
17 CHROOT_USERNAME=$1
18 CHROOT_HOMEDIR=$2
19 CHROOT_USERHOMEDIR=$3
20 CHROOT_SHELL=$4
21 CHROOT_P_USER=$5
22 CHROOT_P_USER_HOMEDIR=$6
23
24 ### Add the chroot user ###
e47d46 25 jk_jailuser -n -s $CHROOT_SHELL -j $CHROOT_HOMEDIR $CHROOT_USERNAME
6a95c8 26
D 27 ### Reconfigure the chroot home directory for the user ###
526b99 28 usermod --home=$CHROOT_HOMEDIR/.$CHROOT_USERHOMEDIR $CHROOT_USERNAME 2>/dev/null
6a95c8 29
D 30 ### We have to reconfigure the chroot home directory for the parent user ###
31 if [ "$CHROOT_P_USER" != "" ]; then
526b99 32   usermod --home=$CHROOT_HOMEDIR/.$CHROOT_P_USER_HOMEDIR $CHROOT_P_USER 2>/dev/null
6a95c8 33 fi