commit c54a8b0e056da4d7a9eaf477a91847bffa9358b2 Author: root Date: Tue Jul 9 20:39:53 2024 +0300 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e52770 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +id_ed25519* +db_v2* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0bb9822 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +all: + echo OK + +install: + mkdir -p /opt/rustdesk + cp -vf hbbs /opt/rustdesk/ + chmod +x /opt/rustdesk/hbbs + cp -vf hbbr /opt/rustdesk/ + chmod +x /opt/rustdesk/hbbr + cp -vf rustdesk-utils /opt/rustdesk/ + chmod +x /opt/rustdesk/rustdesk-utils + cp -vf hbbr.service /etc/systemd/system/ + cp -vf hbbs.service /etc/systemd/system/ + cp -vf hbbs.default /etc/default/hbbs + mkdir -p /var/log/rustdesk + systemctl daemon-reload + +enable: + systemctl enable hbbs hbbr + +start: + systemctl start hbbs hbbr + +stop: + systemctl stop hbbs hbbr + +restart: stop start + +disable: + systemctl disable hbbs hbbr diff --git a/gen-keys.sh b/gen-keys.sh new file mode 100755 index 0000000..1f88fe9 --- /dev/null +++ b/gen-keys.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +public_key="/opt/rustdesk/id_ed25519.pub" +private_key="/opt/rustdesk/id_ed25519" + +function genNewKeys() { + echo "Generatiing a new key pair" + KEY_PAIR=$(/opt/rustdesk/rustdesk-utils genkeypair ) + PUBLIC_KEY=$(echo "${KEY_PAIR}"|head -1 |awk '{print $3}') + PRIVATE_KEY=$(echo "${KEY_PAIR}"|tail -1 |awk '{print $3}') + echo -n "${PUBLIC_KEY}" > "${public_key}" + echo -n "${PRIVATE_KEY}" > "${private_key}" +} + +function validateNewKeys() { + PUBLIC_KEY=$(cat "${public_key}" 2>/dev/null) + PRIVATE_KEY=$(cat "${private_key}" 2>/dev/null ) + /opt/rustdesk/rustdesk-utils validatekeypair "${PUBLIC_KEY}" "${PRIVATE_KEY}" +} + +stat "${public_key}" >/dev/null 2>&1 +stat "${private_key}" >/dev/null 2>&1 + +valid_key_pair="0" + +while [[ "$valid_key_pair" != "1" ]]; do + validateNewKeys | grep "^Key pair is VALID" >/dev/null + if [ "$?" -eq "0" ];then + echo "Foudn the keys to be VALID" + valid_key_pair="1" + else + echo "Found the keys to be invalid" + valid_key_pair="0" + genNewKeys + fi + +done diff --git a/hbbr b/hbbr new file mode 100755 index 0000000..843ef5b Binary files /dev/null and b/hbbr differ diff --git a/hbbr.service b/hbbr.service new file mode 100644 index 0000000..a202dfd --- /dev/null +++ b/hbbr.service @@ -0,0 +1,23 @@ +[Unit] +Description=RustDesk Relay Server +After=network.target + +[Service] +Type=simple +User=root +Group=root + +#Environment="KEY_PRIV=private_key_text" +#Environment="KEY_PUB=pub_key_text" + +LimitNOFILE=1000000 + +WorkingDirectory=/opt/rustdesk/ +ExecStart=/opt/rustdesk/hbbr -k _ +Restart=always +RestartSec=10 +StandardOutput=append:/var/log/rustdesk/relayserver.log +StandardError=append:/var/log/rustdesk/relayserver.error + +[Install] +WantedBy=multi-user.target diff --git a/hbbs b/hbbs new file mode 100755 index 0000000..0b585f9 Binary files /dev/null and b/hbbs differ diff --git a/hbbs.default b/hbbs.default new file mode 100644 index 0000000..5b90576 --- /dev/null +++ b/hbbs.default @@ -0,0 +1,2 @@ +ALWAYS_USE_RELAY=Y +RELAY_SERVERS=rd.ngtech.co.il diff --git a/hbbs.service b/hbbs.service new file mode 100644 index 0000000..da7ca75 --- /dev/null +++ b/hbbs.service @@ -0,0 +1,22 @@ +[Unit] +Description=Rustdesk Signal Server +After=network.target + +[Service] +Type=simple +LimitNOFILE=1000000 +User=root +Group=root + +EnvironmentFile=/etc/default/hbbs + +WorkingDirectory=/opt/rustdesk/ +ExecStart=/opt/rustdesk/hbbs -k _ +StandardOutput=append:/var/log/rustdesk/signalserver.log +StandardError=append:/var/log/rustdesk/signalserver.error + +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target diff --git a/rustdesk-utils b/rustdesk-utils new file mode 100755 index 0000000..5adb3cc Binary files /dev/null and b/rustdesk-utils differ