-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-umbrel.sh
155 lines (119 loc) · 3.81 KB
/
install-umbrel.sh
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
#
# Script usage, in /home/umbrel:
# wget install-umbrel.sh
# ./install-umbrel.sh
#
set -e
UMBREL_VERSION='0.4.9'
user=`whoami`
if [ $user != 'umbrel' ]; then
echo 'Error: Expected user `umbrel`, but it was '$user
exit 1
fi
userId=`id -u`
if [ $userId != 1000 ]; then
echo 'Error: Expected user id 1000, but it was '$userId
echo 'This script has to be executed as the first non-administrator (non-root) user.'
exit 1
fi
##Functions####################################################################
function log() {
echo -e '\n'$1
}
function installDockerEngine() {
log 'remove old docker'
set +e
sudo apt-get remove \
containerd \
docker \
docker-engine \
docker.io \
runc
set -e
log 'install docker'
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
log "add docker's official GPG key"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg -v --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
log 'set up the stable repository'
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
log 'install docker engine'
sudo apt-get install docker-ce docker-ce-cli containerd.io
}
function manageDockerAsNonRoot() {
log 'create docker group'
sudo groupadd -f docker
user=`whoami`
sudo usermod -aG docker $user
log 'configure Docker to start on boot'
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
}
function installDockerCompose() {
log 'install docker compose'
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
}
function cpService() {
fileName=$1
filePath=/etc/systemd/system/$1
sudo cp -v ./scripts/umbrel-os/services/$1 $filePath
# don't need these services
externalStorage='umbrel-external-storage.service'
externalStorageSd='umbrel-external-storage-sdcard-update.service'
r='Requires='$externalStorage
a='After='$externalStorage
b='Before='$externalStorage
sudo sed -i "/$r/d" $filePath
sudo sed -i "/$a/d" $filePath
sudo sed -i "/$b/d" $filePath
r='Requires='$externalStorageSd
a='After='$externalStorageSd
b='Before='$externalStorageSd
sudo sed -i "/$r/d" $filePath
sudo sed -i "/$a/d" $filePath
sudo sed -i "/$b/d" $filePath
}
function installUmbrel() {
umbrelFolder=~/umbrel
log 'Install Umbrel '$UMBREL_VERSION
mkdir -pv $umbrelFolder
cd $umbrelFolder
curl -L 'https://github.com/getumbrel/umbrel/archive/v'$UMBREL_VERSION'.tar.gz' | tar -xz --strip-components=1
log 'copy services'
sudo rm -vf /etc/systemd/system/umbrel*
cpService umbrel-startup.service
cpService umbrel-connection-details.service
cpService umbrel-status-server-iptables-update.service
cpService umbrel-status-server.service
sudo chmod 644 /etc/systemd/system/umbrel-*
sudo systemctl enable umbrel-startup.service
sudo systemctl enable umbrel-connection-details.service
sudo systemctl enable umbrel-status-server-iptables-update.service
sudo systemctl enable umbrel-status-server.service
cd -
}
##Execute######################################################################
log 'install dependencies'
sudo apt update -y
sudo apt-get install fswatch jq rsync curl git
installDockerEngine
manageDockerAsNonRoot
installDockerCompose
log 'verify Docker installation'
newgrp docker << DOCKERPERMISSIONED
set -e
docker run hello-world
exit 0
DOCKERPERMISSIONED
installUmbrel
sudo ./umbrel/scripts/start
log 'Install completed. If you like, reboot to verify Umbrel starts on bootstrap.'
exit 0