-
Notifications
You must be signed in to change notification settings - Fork 0
/
kvminst
46 lines (36 loc) · 907 Bytes
/
kvminst
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
#!/bin/sh
cdir=`dirname $(readlink -f $0)`
if [ ! -f "/$cdir/kvm.txz" ]; then
echo "File kvm.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 /kvm)
if [ -n "$zl" ]; then
echo "kvm 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 kvm: " kpool
if [ -n "$kpool" ]; then
case $lpool in
*"$kpool"*) break;;
esac
fi
echo "Please choose a detected pool..."
done
zfs create $kpool/kvm
zfs create $kpool/kvm/vm
tar -xf kvm.txz -C /$kpool/kvm
echo "*** kvm has been installed in /$kpool/kvm. ***"