blob: b6caac563999608f33f5c2f60ec0924fdabc5732 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#!/bin/bash
#
# mkjail v0.4: chroot jail maker
# feedback: rhatto at riseup.net | GPL
#
BASE_CONF=/etc/mkjail
CONF=$BASE_CONF/mkjail.conf
# under the config file, adjust this to where your things live
# PACKAGES="/storage/vserver/slack/"
# DEVICES="/storage/vserver/devices.tar.gz"
# SCRIPTS="/storage/vserver/etc/"
# GPGKEY="/storage/vserver/slack/GPG-KEY"
# SKEL="/storage/vserver/skel.conf"
if [ -f "$CONF" ]; then
source $CONF
else
echo $0 error: config file $CONFIG not found
exit 1
elif (($# != 1)); then
echo "usage: $0 <jail-name> [template]"
exit 1
elif [ -d "/vservers/$1" ]; then
echo $0 error: vserver $1 already exists
exit 1
fi
if [[ ! -z "$2" && -f "$BASE_CONF/$2.template"]]; then
TEMPLATE="$BASE_CONF/$2.template"
elif [ -f "$BASE_CONF/default.template" ]
echo template $2 not found, using default template
else
echo $0 error: no templates found
echo please create a template using templatepkg
exit 1
fi
server=$1
mkdir /vservers/$server
echo "instaling packages..."
for pack in `cat $TEMPLATE`; do
installpkg --root /vservers/$server `searchpkg -1 $pack`
done
echo "creating /etc/ and copying init scripts"
if [ -d "$BASE_CONF/$template" ]; then
rsync -Cav $BASE_CONF/$template/ /vservers/$server/
fi
cp /etc/resolv.conf /vservers/$server/etc/
cp /etc/localtime /vservers/$server/etc/
echo /dev/hdv1 / ext2 defaults 1 1 > /vservers/$server/etc/fstab
echo /dev/hdv1 / ext2 rw 0 0 > /vservers/$server/etc/mtab
echo "creating devices and dependencies"
cd /vservers/$server/
tar zxvf $DEVICES
chroot /vservers/$server/ sbin/ldconfig
echo "creating /etc/vservers/$server.conf"
cp $SKEL /etc/vservers/$server.conf
echo "importing slack gpg pubkey"
mkdir /vservers/$server/root/.gnupg
gpg --homedir /vservers/$server/root/.gnupg --import $GPGKEY
# todo: add rebootmgr
echo "done; now edit /etc/vservers/$server.conf"
echo "then, set iptables rules and start $server vserver"
echo "dont forget to change root's password"
|