-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·48 lines (42 loc) · 1.34 KB
/
setup.sh
File metadata and controls
executable file
·48 lines (42 loc) · 1.34 KB
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
#!/usr/bin/env bash
if [ "$EUID" -ne 0 ]; then
echo 'The script needs to be run as root.'
# if not root exit
exit 1
else
exec 2>/var/log/VMInit.log 2>&1
fi
if [ ! -f /etc/VMInit.py ]; then
if cp ./VMInit.service /etc/systemd/system ; then
echo "Copied init script from ./VMInit.service to /etc/systemd/system"
else
echo "File VMInit.sh does not exist or could not be copied. Exiting."
exit 1
fi
if cp ./VMInit.py /etc/VMInit.py ; then
chmod +x /etc/VMInit.py
echo "Copied python executable ./VMInit.py to /etc/VMInit.py"
else
rm /etc/systemd/system/VMInit.service
echo "File VMInit.py does not exist or could not be copied. Exiting."
exit 1
fi
if cp ./vmlist.txt /etc/vmlist ; then
echo "Created file /etc/vmlist. In that file you can list all your existing vms."
else
rm /etc/systemd/system/VMInit.service
rm /etc/VMInit.py
echo "File vmlist could not be created. Exiting."
exit 1
fi
echo "Would you like to enable the init script? (yes or no)"
read answer
if [ $answer == "yes" ]; then
systemctl enable VMInit.service
else
echo "Very well. If you wish to do it later, simply run the command 'sudo systemctl enable VMInit.service'."
fi
else
echo "VMInit already exists in your system!"
fi
exit 0