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 #!/bin/bash
uname=$(whoami) # Assign a random value to the password variable
admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c8) rustdesk_pw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
architecture=$(arch)
bpwd=$(pwd)
# 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 if [ -f /etc/os-release ]; then
# freedesktop.org and systemd # freedesktop.org and systemd
. /etc/os-release . /etc/os-release
@ -30,13 +39,13 @@ elif [ -f /etc/lsb-release ]; then
OS=$DISTRIB_ID OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc. # Older Debian, Ubuntu, etc.
OS=Debian OS=Debian
VER=$(cat /etc/debian_version) VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then elif [ -f /etc/SuSE-release ]; then
# Older SuSE/etc. # Older SuSE etc.
OS=SuSE OS=SuSE
VER=$(cat /etc/SuSe-release) VER=$(cat /etc/SuSE-release)
elif [ -f /etc/redhat-release ]; then elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc. # Older Red Hat, CentOS, etc.
OS=RedHat OS=RedHat
@ -47,31 +56,15 @@ else
VER=$(uname -r) VER=$(uname -r)
fi fi
# Install Rustdesk # 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) }') echo "Installing RustDesk"
fi if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
echo "Installing Rustdesk" wget https://github.com/rustdesk/rustdesk/releases/download/1.2.2/rustdesk-1.2.2-x86_64.deb
if [ "$OS" = "Ubuntu" ] || [ "${UPSTREAM_ID}" = "ubuntu" ]; then apt-get install -fy ./rustdesk-1.2.2-x86_64.deb > null
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 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" wget https://github.com/rustdesk/rustdesk/releases/download/1.2.2/rustdesk-1.2.2-0.x86_64.rpm
sudo yum localinstall $bpwd/rustdesk-$lversion-0.x86_64.rpm yum localinstall ./rustdesk-1.2.2-0.x86_64.rpm -y > null
else else
echo "Unsupported OS" echo "Unsupported OS"
# here you could ask the user for permission to try and install anyway # 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 # if they say no, exit the script
exit 1 exit 1
fi 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 # Run the rustdesk command with --get-id and store the output in the rustdesk_id variable
rustdesktoml2a="$(cat << EOF rustdesk_id=$(rustdesk --get-id)
rendezvous_server = 'wanipreg'
nat_type = 1
serial = 3
[options] # Apply new password to RustDesk
rendezvous-servers = 'rs-ny.rustdesk.com,rs-sg.rustdesk.com,rs-cn.rustdesk.com' rustdesk --password $rustdesk_pw &> /dev/null
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 rustdesk --config $rustdesk_cfg
rustdesktoml2b="$(cat << EOF
rendezvous_server = 'wanipreg'
nat_type = 1
serial = 3
[options] systemctl restart rustdesk
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 "..............................................."
# 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:" # Echo the value of the password variable
grep -w id /home/${uname}/.config/rustdesk/RustDesk.toml echo "Password: $rustdesk_pw"
grep -w password /home/${uname}/.config/rustdesk/RustDesk.toml echo "..............................................."
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