Update linuxclientinstall.sh

This commit is contained in:
gitondezhuts 2024-03-15 10:48:43 +00:00 committed by GitHub
parent 7a3bdc2d02
commit 48702e108e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,11 +1,20 @@
#!/bin/bash
uname=$(whoami)
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c8)
architecture=$(arch)
bpwd=$(pwd)
# Assign a random value to the password variable
rustdesk_pw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
# identify OS
# Get your config string from your Web portal and Fill Below
rustdesk_cfg="secure-string"
################################### Please Do Not Edit Below This Line #########################################
# Check if the script is being run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
# Identify OS
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
@ -30,13 +39,13 @@ elif [ -f /etc/lsb-release ]; then
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
# Older Debian, Ubuntu, etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
elif [ -f /etc/SuSE-release ]; then
# Older SuSE etc.
OS=SuSE
VER=$(cat /etc/SuSe-release)
VER=$(cat /etc/SuSE-release)
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
OS=RedHat
@ -47,31 +56,15 @@ else
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
# Install RustDesk
echo "Installing RustDesk"
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
wget https://github.com/rustdesk/rustdesk/releases/download/1.2.2/rustdesk-1.2.2-x86_64.deb
apt-get install -fy ./rustdesk-1.2.2-x86_64.deb > null
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
wget https://github.com/rustdesk/rustdesk/releases/download/1.2.2/rustdesk-1.2.2-0.x86_64.rpm
yum localinstall ./rustdesk-1.2.2-0.x86_64.rpm -y > null
else
echo "Unsupported OS"
# here you could ask the user for permission to try and install anyway
@ -79,52 +72,26 @@ else
# 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
# Run the rustdesk command with --get-id and store the output in the rustdesk_id variable
rustdesk_id=$(rustdesk --get-id)
[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
# Apply new password to RustDesk
rustdesk --password $rustdesk_pw &> /dev/null
# Setup Rustdesk in root profile
rustdesktoml2b="$(cat << EOF
rendezvous_server = 'wanipreg'
nat_type = 1
serial = 3
rustdesk --config $rustdesk_cfg
[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
systemctl restart rustdesk
sudo systemctl restart rustdesk
echo "..............................................."
# Check if the rustdesk_id is not empty
if [ -n "$rustdesk_id" ]; then
echo "RustDesk ID: $rustdesk_id"
else
echo "Failed to get RustDesk ID."
fi
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
# Echo the value of the password variable
echo "Password: $rustdesk_pw"
echo "..............................................."