-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupgrade.sh
executable file
·59 lines (53 loc) · 1.53 KB
/
upgrade.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
#!/bin/bash
cd /etc/code-server-hub
git pull --no-edit
export image_name=$(python3 util/get_docker_image_name.py)
echo $image_name
SUDOERS_FILE="/etc/sudoers"
LINE="www-data ALL=NOPASSWD: /etc/code-server-hub/util/close_docker.sh"
install() {
# Check if the line already exists in sudoers
if sudo grep -Fxq "$LINE" "$SUDOERS_FILE"; then
echo "Entry already exists in sudoers."
else
# Add the line to sudoers
echo "$LINE" | sudo tee -a "$SUDOERS_FILE" > /dev/null
echo "Entry added to sudoers."
fi
}
install
function get_cpu_architecture()
{
local cpuarch;
cpuarch=$(uname -m)
case $cpuarch in
x86_64)
echo "amd64";
;;
aarch64)
echo "arm64";
;;
*)
echo "Not supported cpu architecture: ${cpuarch}" >&2
exit 1
;;
esac
}
cpu_arch=$(get_cpu_architecture)
echo "###doenload latest code-server###"
curl -L -s https://api.github.com/repos/cdr/code-server/releases/latest \
| grep "browser_download_url.*linux-${cpu_arch}.tar.gz" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -i - -O code-server.tar.gz
echo "###unzip code-server.tar.gz###"
rm -r /etc/code-server-hub/.cshub/* || true
tar xzvf code-server.tar.gz -C .cshub
mv .cshub/*/* .cshub/
rm code-server.tar.gz
if hash docker 2>/dev/null; then
echo "Docker installed, update docker image"
echo docker pull $image_name
docker pull $image_name
fi
/etc/code-server-hub/util/openresty/build/bin/openresty -s reload