forked from techahold/rustdeskinstall
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinuxclientinstall.sh
More file actions
130 lines (114 loc) · 4.57 KB
/
linuxclientinstall.sh
File metadata and controls
130 lines (114 loc) · 4.57 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
#!/bin/bash
uname=$(whoami)
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c8)
architecture=$(arch)
bpwd=$(pwd)
# 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
# Install Rustdesk
if command -v curl > /dev/null; then
lversion=$(curl https://api.github.com/repos/rustdesk/rustdesk/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }')
fi
echo "Installing Rustdesk"
if [ "$OS" = "Ubuntu" ] || [ "${UPSTREAM_ID}" = "ubuntu" ]; then
if [[ "$architecture" != @("x86_64"|"aarch64") ]]; then
echo "Unsupported Architecture"
exit 1
fi
if [ "$architecture" = "aarch64" ]; then
sudo add-apt-repository -y universe
sudo apt install -y libxdo3 curl libva-drm2 libva-x11-2
if [ -z "$lversion" ]; then
lversion=$(curl https://api.github.com/repos/rustdesk/rustdesk/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }')
fi
fi
wget https://github.com/rustdesk/rustdesk/releases/download/$lversion/rustdesk-$lversion-$architecture.deb --output-document="$bpwd/rustdesk-$lversion-$architecture.deb"
sudo apt install -fy $bpwd/rustdesk-$lversion-$architecture.deb
elif [ "${ID}" = "debian" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
wget https://github.com/rustdesk/rustdesk/releases/download/$lversion/rustdesk-$lversion-x86_64.deb --output-document="$bpwd/rustdesk-$lversion-x86_64.deb"
sudo apt install -fy $bpwd/rustdesk-$lversion-x86_64.deb
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "$OS" = "Fedora Linux" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then
wget https://github.com/rustdesk/rustdesk/releases/download/$lversion/rustdesk-$lversion-0.x86_64.rpm --output-document="$bpwd/rustdesk-$lversion-0.x86_64.rpm"
sudo yum localinstall $bpwd/rustdesk-$lversion-0.x86_64.rpm
else
echo "Unsupported OS"
# here you could ask the user for permission to try and install anyway
# if they say yes, then do the install
# if they say no, exit the script
exit 1
fi
# Sleeping to let the package manager finish installation. If this does not complete before trying to run rustdesk, it can cause a panick citing an inability to find the files.
sleep 5
rustdesk --password ${admintoken}
sudo pkill -f "rustdesk"
# Setup Rustdesk in user profile
rustdesktoml2a="$(cat << EOF
rendezvous_server = 'wanipreg'
nat_type = 1
serial = 3
[options]
rendezvous-servers = 'rs-ny.rustdesk.com,rs-sg.rustdesk.com,rs-cn.rustdesk.com'
key = 'keyreg'
custom-rendezvous-server = 'wanipreg'
api-server = 'https://wanipreg'
relay-server = 'wanipreg'
EOF
)"
echo "${rustdesktoml2a}" | sudo tee /home/${uname}/.config/rustdesk/RustDesk2.toml > /dev/null
# Setup Rustdesk in root profile
rustdesktoml2b="$(cat << EOF
rendezvous_server = 'wanipreg'
nat_type = 1
serial = 3
[options]
rendezvous-servers = 'rs-ny.rustdesk.com,rs-sg.rustdesk.com,rs-cn.rustdesk.com'
key = 'keyreg'
custom-rendezvous-server = 'wanipreg'
api-server = 'https://wanipreg'
relay-server = 'wanipreg'
EOF
)"
echo "${rustdesktoml2b}" | sudo tee /root/.config/rustdesk/RustDesk2.toml > /dev/null
sudo chown ${uname}:${uname} /home/${uname}/.config/rustdesk/RustDesk2.toml
sudo systemctl restart rustdesk
echo "ID & Password for Rustdesk ${uname} are:"
grep -w id /home/${uname}/.config/rustdesk/RustDesk.toml
grep -w password /home/${uname}/.config/rustdesk/RustDesk.toml
echo "ID & Password for Rustdesk (root) are:"
sudo grep -w id /root/.config/rustdesk/RustDesk.toml
sudo grep -w password /root/.config/rustdesk/RustDesk.toml