commit | author | age
|
6a95c8
|
1 |
#!/bin/bash |
D |
2 |
|
|
3 |
# Create the jailkit chroot |
|
4 |
|
|
5 |
# |
|
6 |
# Usage: ./create_jailkit_chroot username 'basicshell editors' |
|
7 |
# |
|
8 |
|
|
9 |
|
|
10 |
# Sanity check |
|
11 |
|
|
12 |
if [ "$1" = "" ]; then |
|
13 |
echo " Usage: ./create_jailkit_chroot username 'basicshell editors'" |
|
14 |
exit |
|
15 |
fi |
|
16 |
|
|
17 |
CHROOT_HOMEDIR=$1 |
|
18 |
CHROOT_APP_SECTIONS=$2 |
|
19 |
|
|
20 |
## Change ownership of the chroot directory to root |
|
21 |
chown root:root $CHROOT_HOMEDIR |
|
22 |
|
|
23 |
## Initialize the chroot into the specified directory with the specified applications |
edf806
|
24 |
jk_init -f -k -c /etc/jailkit/jk_init.ini -j $CHROOT_HOMEDIR $CHROOT_APP_SECTIONS |
6a95c8
|
25 |
|
D |
26 |
## Create the temp directory |
42b385
|
27 |
if [ ! -d "$CHROOT_HOMEDIR/tmp" ] |
T |
28 |
then |
|
29 |
mkdir $CHROOT_HOMEDIR/tmp |
|
30 |
fi |
6a95c8
|
31 |
chmod a+rwx $CHROOT_HOMEDIR/tmp |
D |
32 |
|
e37c42
|
33 |
## Fix permissions of the root firectory |
TB |
34 |
chmod g-w $CHROOT_HOMEDIR/bin |
|
35 |
|
6a95c8
|
36 |
|
D |
37 |
# mysql needs the socket in the chrooted environment |
|
38 |
mkdir $CHROOT_HOMEDIR/var |
|
39 |
mkdir $CHROOT_HOMEDIR/var/run |
|
40 |
mkdir $CHROOT_HOMEDIR/var/run/mysqld |
42b385
|
41 |
|
T |
42 |
# ln /var/run/mysqld/mysqld.sock $CHROOT_HOMEDIR/var/run/mysqld/mysqld.sock |
|
43 |
if [ -e "/var/run/mysqld/mysqld.sock" ] |
|
44 |
then |
|
45 |
ln /var/run/mysqld/mysqld.sock $CHROOT_HOMEDIR/var/run/mysqld/mysqld.sock |
|
46 |
fi |