-
Notifications
You must be signed in to change notification settings - Fork 1
/
aoi-init
executable file
·56 lines (46 loc) · 1.51 KB
/
aoi-init
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
#!/bin/bash -e
if [ $(id -u) -eq 0 ]; then
echo "Please run this script as a normal user."
echo "You will be prompted by 'sudo' if necessary."
exit 1
fi
sudo apt-get update
sudo apt-get install -yu \
libvirt-daemon-system libvirt-clients \
bridge-utils \
qemu-kvm virtinst \
uuid \
rsync \
apparmor-profiles apparmor-utils \
genisoimage \
libosinfo-bin
# Note: libosinfo is for 'osinfo-query os', which defines the OS variants that
# virt-install knows about.
# Add the 'libvirt' and 'kvm' groups, but don't fail if it already exists.
sudo addgroup libvirt || true
sudo addgroup kvm || true
sudo usermod -a -G libvirt,kvm $USER
# These lines might be needed if you want to use an images directory
# which is not a subdirectory of /var/lib/libvirt/images.
#
# Use at your own risk.
#
# sudo aa-complain /usr/lib/libvirt/virt-aa-helper
# sudo aa-complain /usr/sbin/libvirtd
IMAGES_DIR="$(aoi config get images_dir /var/lib/libvirt/images/aoi)"
sudo mkdir -p $IMAGES_DIR
sudo chown $USER:kvm $IMAGES_DIR
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if ! id | awk '{ print $3 }' | grep '(libvirt)' | grep -q '(kvm)'; then
echo ""
echo "Your user was just added to the 'libvirt' and 'kvm' groups, but"
echo "membership was not yet taken effect."
echo "You need to log out, log back in, and then re-run:"
echo ""
echo " $(pwd)/$(basename $0)"
echo ""
exit 1
fi
$SCRIPT_DIR/aoi-configure-networks
$SCRIPT_DIR/aoi-sync
$SCRIPT_DIR/aoi-generate-ssh-keys