#!/bin/sh # Added to the official RustDesk AppImage by https://support.srx.digital # # Makes RustDesk use the server below, unless a server is already set on this # computer, and then starts the AppImage's original launcher (AppRun.bin). # Nothing else in the AppImage is changed. host='support.srx.digital' key='Wbu22yFw1MdLu6Yed2HCySS6L1qS50AB7yJRmjlSJ6s=' set_server() { [ -n "${XDG_CONFIG_HOME:-$HOME}" ] || return 0 conf="${XDG_CONFIG_HOME:-$HOME/.config}/rustdesk/RustDesk2.toml" # A server or key that is already set stays. if grep -qsE "^[[:space:]]*(custom-rendezvous-server|key)[[:space:]]*=[[:space:]]*[\"'][^\"']" "$conf"; then return 0 fi mkdir -p "$(dirname "$conf")" || return 0 if [ -s "$conf" ]; then # Into the [options] table, which is added if the file has none. tmp="$conf.srx.$$" awk -v host="$host" -v key="$key" ' function server() { print "custom-rendezvous-server = \047" host "\047" print "key = \047" key "\047" done = 1 } /^[[:space:]]*(custom-rendezvous-server|key)[[:space:]]*=/ { next } { print } /^\[options\][[:space:]]*$/ && !done { server() } END { if (!done) { print ""; print "[options]"; server() } } ' "$conf" > "$tmp" && mv "$tmp" "$conf" rm -f "$tmp" else printf "[options]\ncustom-rendezvous-server = '%s'\nkey = '%s'\n" "$host" "$key" > "$conf" fi } # Never keeps RustDesk from starting. set_server || true here=${APPDIR:-$(dirname "$(readlink -f "$0")")} exec "$here/AppRun.bin" "$@"