-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·137 lines (107 loc) · 3.38 KB
/
install.sh
File metadata and controls
executable file
·137 lines (107 loc) · 3.38 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
export COMPOSEVERSION=1.25.4
export SERVICESTART=true
export VTMZBRANCH=master
export NODEMO=true
# check for correct distribution and os version
VERSION=$(cat /etc/*-release | grep -w VERSION_CODENAME | cut -f 2 -d"=")
if [ "$VERSION" != "buster" ]; then
echo "this install script only supports debian 10 (buster)"
exit 1
fi
# check if we run as root
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit 1
fi
while getopts b:nd flag
do
case "${flag}" in
b) export VTMZBRANCH=${OPTARG};;
n) export SERVICESTART=false;;
d) export NODEMO=false
esac
done
# https://computingforgeeks.com/install-docker-and-docker-compose-on-debian-10-buster/
# Prerequisites
apt update
apt -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common openssl git apache2
# docker repo
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
# install docker
apt update
apt -y install docker-ce docker-ce-cli containerd.io
curl -L "https://github.com/docker/compose/releases/download/$COMPOSEVERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
if grep -q docker /etc/group
then
echo "docker group already exists"
else
newgrp docker
usermod -aG docker $USER
fi
# virtomize installation
cd /opt
git clone -b $VTMZBRANCH https://github.com/Virtomize/virtomize.git
if [ "$NODEMO" = false ]; then
exit 0
fi
mkdir /opt/virtomize-scripts
touch /etc/issue.tmpl
cat <<EOF >/etc/issue.tmpl
Welcome to Virtomize
It may take a few minutes until the system is available.
Please visit:
- https://<IP>/ to use the webfrontend
- https://<IP>/rest/v1/ to use the REST API
EOF
# change ip on start if something changes
touch /opt/virtomize-scripts/issue-ip.sh
chmod +x /opt/virtomize-scripts/issue-ip.sh
cat <<EOF >/opt/virtomize-scripts/issue-ip.sh
IP=\$(ip a | grep ens | awk '/inet/ {print \$2}' | cut -f1 -d'/')
while [ -z "\$IP" ]
do
IP=\$(ip a | grep ens | awk '/inet/ {print \$2}' | cut -f1 -d'/')
done
sed "s/<IP>/\$IP/g" /etc/issue.tmpl > /etc/issue
EOF
touch /etc/cron.d/issueip
cat <<EOF >/etc/cron.d/issueip
@reboot root /opt/virtomize-scripts/issue-ip.sh
EOF
# run it to create the issue file
/opt/virtomize-scripts/issue-ip.sh
# set motd
cat <<EOF >/etc/motd
###################### VIRTOMIZE ######################
# #
# Welcome to the Virtomize #
# #
###################### VIRTOMIZE ######################
EOF
# set update cron
touch /etc/cron.d/update
cat <<EOF >/etc/cron.d/update
* * * * * root /opt/virtomize/update.sh >> /opt/virtomize/update.log
EOF
# apache reverse proxy
systemctl enable apache2
a2enmod ssl
a2enmod proxy
a2enmod proxy_http
a2enmod headers
a2enmod rewrite
curl https://ssl-config.mozilla.org/ffdhe2048.txt >> /etc/ssl/certs/ssl-cert-snakeoil.pem
cp /opt/virtomize/proxy/apache.conf /etc/apache2/sites-available/000-default.conf
systemctl restart apache2
# -n prevents from starting the service
# used for creating development virtual appliances
if [ "$SERVICESTART" = true ]; then
cd /opt/virtomize
docker-compose up -d
fi
unset COMPOSEVERSION
unset SERVICESTART
unset VTMZBRANCH