Last active
November 1, 2024 16:56
-
-
Save hintoz/31016e23950ecfbade2d64f26d8e580e to your computer and use it in GitHub Desktop.
A modified script for downloading and installing the latest version of RustDesk for macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Assign the value random password to the password variable | |
rustdesk_pw=$(openssl rand -hex 4) | |
# Set or change the password | |
set_rustdesk_pw=false | |
# Get your config string from your Web portal and Fill Below | |
# Use a reverse Base64 string in the format {"host":"HOSTADDRESS","relay":"","api":"","key":"HOSTKEY"} | |
rustdesk_cfg="configstring" | |
################################### Please Do Not Edit Below This Line ######################################### | |
# Root password request for privilege escalation | |
[ "$UID" -eq 0 ] || exec sudo bash "$0" "$@" | |
# Specify the mount point for the DMG (temporary directory) | |
mount_point="/Volumes/RustDesk" | |
# Download the rustdesk.dmg file | |
echo "Downloading RustDesk Now" | |
# Current example link: https://github.com/rustdesk/rustdesk/releases/download/1.3.2/rustdesk-1.3.2-x86_64.dmg | |
if [[ $(arch) == 'arm64' ]]; then | |
rd_link=$(curl -sL https://github.com/rustdesk/rustdesk/releases/latest | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*/\d{1}.\d{1,2}.\d{1,2}/rustdesk.\d{1}.\d{1,2}.\d{1,2}.aarch64.dmg") | |
dmg_file=$(echo $rd_link | grep -Eo "rustdesk.\d{1}.\d{1,2}.\d{1,2}.aarch64.dmg") | |
curl -L "$rd_link" --output "$dmg_file" | |
else | |
rd_link=$(curl -sL https://github.com/rustdesk/rustdesk/releases/latest | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*/\d{1}.\d{1,2}.\d{1,2}/rustdesk.\d{1}.\d{1,2}.\d{1,2}.x86_64.dmg") | |
dmg_file=$(echo $rd_link | grep -Eo "rustdesk.\d{1}.\d{1,2}.\d{1,2}.x86_64.dmg") | |
curl -L "$rd_link" --output "$dmg_file" | |
fi | |
# Mount the DMG file to the specified mount point | |
hdiutil attach "$dmg_file" -mountpoint "$mount_point" &> /dev/null | |
# Check if the mounting was successful | |
if [ $? -eq 0 ]; then | |
# Move the contents of the mounted DMG to the /Applications folder | |
cp -R "$mount_point/RustDesk.app" "/Applications/" &> /dev/null | |
# Unmount the DMG file | |
hdiutil detach "$mount_point" &> /dev/null | |
else | |
echo "Failed to mount the RustDesk DMG. Installation aborted." | |
exit 1 | |
fi | |
# Run the rustdesk command with --get-id and store the output in the rustdesk_id variable | |
cd /Applications/RustDesk.app/Contents/MacOS/ | |
rustdesk_id=$(./RustDesk --get-id) | |
# Apply new password to RustDesk if set_rustdesk_pw=true | |
if [ "$set_rustdesk_pw" = true ]; then | |
./RustDesk --server & | |
/Applications/RustDesk.app/Contents/MacOS/RustDesk --password $rustdesk_pw &> /dev/null | |
fi | |
/Applications/RustDesk.app/Contents/MacOS/RustDesk --config $rustdesk_cfg | |
# Kill all processes named RustDesk | |
rdpid=$(pgrep RustDesk) | |
kill $rdpid &> /dev/null | |
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 the value of the password variable if set_rustdesk_pw=true | |
if [ "$set_rustdesk_pw" = true ]; then | |
echo "Password: $rustdesk_pw" | |
else | |
echo "The password has not been set or changed." | |
fi | |
echo "..............................................." | |
echo "Please complete install on GUI, launching RustDesk now." | |
open -n /Applications/RustDesk.app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment