-
Notifications
You must be signed in to change notification settings - Fork 0
/
kinst
52 lines (41 loc) · 1.12 KB
/
kinst
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
#!/bin/sh
cdir=`dirname $(readlink -f $0)`
if [ ! -f "/$cdir/kjail.txz" ]; then
echo "File kjail.txz is missing. Installation aborted." >&2
exit 1
fi
if [ $(id -u) -ne 0 ]; then
echo "You need to be root to run this." >&2
exit 1
fi
lpool=$(zpool list -o name | tail -n +2)
if [ -z "$lpool" ]; then
echo "No pool detected. Installation aborted." >&2
exit 1
fi
zl=$(zfs list | grep /kjail)
if [ -n "$zl" ]; then
echo "kjail seems to be already installed on this system." >&2
echo "Please uninstall it before." >&2
exit 1
fi
echo -n "Detected pool(s) are/is: "
echo $lpool
while true; do
read -p "Choose the pool where to install kjail: " kpool
if [ -n "$kpool" ]; then
case $lpool in
*"$kpool"*) break;;
esac
fi
echo "Please choose a detected pool..."
done
zfs create $kpool/kjail
zfs create $kpool/kjail/base
zfs create $kpool/kjail/jails
mkdir -p /$kpool/kjail/settings/etc
cp -p /etc/resolv.conf /$kpool/kjail/settings/etc/
tar -xf kjail.txz -C /$kpool/kjail
sed -i "" -e "s#/\*\*\*/#/$kpool/#" /$kpool/kjail/kjail
cp /$kpool/kjail/kjail /usr/local/etc/rc.d/
echo "*** kjail has been installed in /$kpool/kjail. ***"