-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathciab-pre-install.sh
More file actions
102 lines (75 loc) · 2.91 KB
/
Copy pathciab-pre-install.sh
File metadata and controls
102 lines (75 loc) · 2.91 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
clear
INSTALL_DIR="/opt/ciab"
#==================================================================================================================================
# ciab-pre-install.sh
#
# Purpuse:
#
# If the User/Installer doesn't already have LXD installed then this script will install it for them.
#==================================================================================================================================
echo
echo
echo "===={ BEGIN }================================================================================================================"
echo
echo "NOTE: This script should NOT be executed as SUDO or ROOT .. but as your 'normal' UserID"
echo
echo "Checking if this script was axecuted as either Root or Sudo ... if it was then it will exit and you can try again."
echo
echo
if [ $(id -u) = 0 ]; then echo "Do NOT run this script SUDO or ROOT... Please re-run with your Normal UserID !"; exit 1 ; fi
echo
echo
echo
echo "==============================================================================================================================="
echo " Uninstall any pre-installed LXD and reinstall and re-init using an LXD Init Preseed Yaml config file so answers are all"
echo " automated."
echo
echo
echo
sudo apt-get update && sudo apt-get upgrade -y
cd $INSTALL_DIR
LXD_EXISTS="/var/snap/lxd"
if [ -d $LXD_EXISTS ]
then
echo "LXD is already installed so skipping installation of SNAP LXD."
else
sudo apt-get purge lxd
sudo apt-get install snapd
sudo snap remove lxd
sudo snap install lxd
fi
#====================================================================================================================================
# the following will use SED to substitute a password entered by the Installer for using LXD over the Internet
# for the "default' string "ciab-lxd-password" check the ciab-lxd-preseed.yaml
while true
do
clear
echo
echo "======================================================="
echo
read -s -p "Enter a Password for using LXD over the Network: " lxd_pwd
echo
read -s -p "Confirm the Password: " pwd_confirmation
echo
[ "$lxd_pwd" = "$pwd_confirmation" ] && break
echo "Passwords don't match... try again!"
echo
done
sudo sed -i 's/ciab-lxd-password /$lxd_pwd/' $INSTALL_DIR/ciab-lxd-init-preseed.yaml
echo
echo
echo " Using the $INSTALL_DIR/ciab-lxd-init-preseed.yaml file for automating LXD INIT... "
echo
sudo lxd init --preseed < $INSTALL_DIR/ciab-lxd-init-preseed.yaml
#====================================================================================================================================
# Adding the Installer's UserID to the LXD group to enable use of lxc cli
sudo adduser $USER lxd
newgrp lxd
echo
echo
echo
echo "===={ LXD is now installed }==================================================================================================="
echo
echo
exit