-
Notifications
You must be signed in to change notification settings - Fork 73
/
update.sh
135 lines (114 loc) · 3.91 KB
/
update.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
#!/bin/bash
# shellcheck disable=2034,2059,2164
true
TLS=""
if command -v ldconfig &> /dev/null; then
if ldconfig -p | grep -q "libssl.so.3"; then
TLS="-nativetls"
fi
fi
# Get username
usern=$(whoami) # not used btw ... yet
# Get current release version
RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server-pro/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }')
RDCURRENT=$(/usr/bin/hbbr --version | sed -r 's/hbbr (.*)/\1/')
if [ $RDLATEST == $RDCURRENT ]; then
echo "Same version, no need to update."
exit 0
fi
sudo systemctl stop rustdesk-hbbs.service
sudo systemctl stop rustdesk-hbbr.service
sleep 20
ARCH=$(uname -m)
# Identify OS
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
UPSTREAM_ID=${ID_LIKE,,}
# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then
UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)"
fi
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian, Ubuntu, etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSE-release ]; then
# Older SuSE, etc.
OS=SuSE
VER=$(cat /etc/SuSE-release)
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
OS=RedHat
VER=$(cat /etc/redhat-release)
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
# Output debugging info if $DEBUG set
if [ "$DEBUG" = "true" ]; then
echo "OS: $OS"
echo "VER: $VER"
echo "UPSTREAM_ID: $UPSTREAM_ID"
exit 0
fi
if ! [ -e /var/lib/rustdesk-server/ ]; then
echo "No directory /var/lib/rustdesk-server/ found. No update of RustDesk possible (use install.sh script?)"
exit 4
else
:
fi
cd /var/lib/rustdesk-server/
rm -rf static/
echo "Upgrading RustDesk Server"
if [ "${ARCH}" = "x86_64" ] ; then
wget https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-amd64${TLS}.tar.gz
tar -xf rustdesk-server-linux-amd64${TLS}.tar.gz
mv amd64${TLS}/static /var/lib/rustdesk-server/
sudo mv amd64${TLS}/hbbr /usr/bin/
sudo mv amd64${TLS}/hbbs /usr/bin/
sudo mv amd64${TLS}/rustdesk-utils /usr/bin/
rm -rf amd64${TLS}/
rm -rf rustdesk-server-linux-amd64${TLS}.tar.gz
elif [ "${ARCH}" = "armv7l" ] ; then
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-armv7.tar.gz"
tar -xf rustdesk-server-linux-armv7.tar.gz
mv armv7/static /var/lib/rustdesk-server/
sudo mv armv7/hbbr /usr/bin/
sudo mv armv7/hbbs /usr/bin/
sudo mv armv7/rustdesk-utils /usr/bin/
rm -rf armv7/
rm -rf rustdesk-server-linux-armv7.tar.gz
elif [ "${ARCH}" = "aarch64" ] ; then
wget "https://github.com/rustdesk/rustdesk-server-pro/releases/download/${RDLATEST}/rustdesk-server-linux-arm64v8${TLS}.tar.gz"
tar -xf rustdesk-server-linux-arm64v8${TLS}.tar.gz
mv arm64v8${TLS}/static /var/lib/rustdesk-server/
sudo mv arm64v8${TLS}/hbbr /usr/bin/
sudo mv arm64v8${TLS}/hbbs /usr/bin/
sudo mv arm64v8${TLS}/rustdesk-utils /usr/bin/
rm -rf arm64v8${TLS}/
rm -rf rustdesk-server-linux-arm64v8${TLS}.tar.gz
fi
sudo chmod +x /usr/bin/hbbs
sudo chmod +x /usr/bin/hbbr
sudo chmod +x /usr/bin/rustdesk-utils
sudo systemctl start rustdesk-hbbs.service
sudo systemctl start rustdesk-hbbr.service
while ! [[ $CHECK_RUSTDESK_READY ]]; do
CHECK_RUSTDESK_READY=$(sudo systemctl status rustdesk-hbbr.service | grep "Active: active (running)")
echo -ne "RustDesk Relay not ready yet...${NC}\n"
sleep 3
done
echo -e "Updates are complete"