A service of Daily Data, Inc.
Contact Form

User Tools

Site Tools


software:rust:server_devuan

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
software:rust:server_devuan [2025/09/18 08:16] rodolicosoftware:rust:server_devuan [2025/09/18 11:18] (current) rodolico
Line 8: Line 8:
 We use [[https://www.devuan.org/|Devuan]] as an alternative to Debian as Devuan allows us to choose the init system instead of forcing the use of SystemD. With its many faults, we still choose SysVInit for our init system, and Devuan allows that. We use [[https://www.devuan.org/|Devuan]] as an alternative to Debian as Devuan allows us to choose the init system instead of forcing the use of SystemD. With its many faults, we still choose SysVInit for our init system, and Devuan allows that.
  
-The Rust Server install script unfortunately assumes SystemD, and will fail halfway through as it is attempting to set up the SystemD service. The same is true of the .deb package which is available.+An excellent Rust Server install script is available at [[https://github.com/techahold/rustdeskinstall/blob/master/install.sh|GitHub built by techahold]]. This script has a lot of extra features, but unfortunately, it assumes SystemD, and will fail halfway through as it is attempting to set up the SystemD service. The same is true of the .deb package which is available from RustDesk.
  
 This article describes how to set up the Rust Server on Devuan, and may be helpful for other systems also. This article describes how to set up the Rust Server on Devuan, and may be helpful for other systems also.
Line 50: Line 50:
  
 **Note**: The check is made in the current working directory, so you **must** run hbbs from within it's home directory (/opt/rustdesk) **Note**: The check is made in the current working directory, so you **must** run hbbs from within it's home directory (/opt/rustdesk)
 +
 +A way that gives you more control is to run the rustdesk-utils, generate the key, then run hbbs.
 +
 +<code bash>
 +cd /opt/rustdesk
 +sudo -u rust ./rustdesk-utils genkeypair
 +# verify they exist
 +ls -ablph id_ed25519*
 +# make them owned by the rust user
 +chown rust:rust id_ed25519*
 +sudo -u rust ./hbbs
 +# watch for errors, press ^c to leave.
 +
 +echo Your key for the clients is
 +cat id_ed25519.pub
 +echo To find this again at a later date, just run the command cat id_ed25519.pub
 +</bash>
 +
 +===== Set automatic run =====
 +
 +Everything up to this point will work on all Unix systems, and we have done nothing that techahold's install script will do faster, and more reliably. However, for the Unix systems which do not use SysV, we need a SysV init script. Actually two; one for hbbr and one for hbbs.
 +
 +Copy the following two files to /etc/init.d (Devuan), or wherever your init scripts are stored. By the way, I built these starting with the template at [[https://github.com/fhd/init-script-template|fhd's Github]].
 +
 +<code bash hbbs>
 +#!/bin/sh
 +### BEGIN INIT INFO
 +# Provides:          hbbs
 +# Required-Start:    $remote_fs $syslog
 +# Required-Stop:     $remote_fs $syslog
 +# Default-Start:     2 3 4 5
 +# Default-Stop:      0 1 6
 +# Short-Description: Rust Signaling Server
 +# Description:       This provides the definition of the signaling server for rust
 +### END INIT INFO
 +
 +dir="/opt/rust"
 +cmd="hbbs"
 +user="rust"
 +
 +name=`basename $0`
 +pid_file="/var/run/$name.pid"
 +stdout_log="/var/log/$name.log"
 +stderr_log="/var/log/$name.err"
 +
 +get_pid() {
 +    cat "$pid_file"
 +}
 +
 +is_running() {
 +    [ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1
 +}
 +
 +case "$1" in
 +    start)
 +    if is_running; then
 +        echo "Already started"
 +    else
 +        echo "Starting $name"
 +        cd "$dir"
 +        if [ -z "$user" ]; then
 +            sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
 +        else
 +            sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
 +        fi
 +        echo $! > "$pid_file"
 +        if ! is_running; then
 +            echo "Unable to start, see $stdout_log and $stderr_log"
 +            exit 1
 +        fi
 +    fi
 +    ;;
 +    stop)
 +    if is_running; then
 +        echo -n "Stopping $name.."
 +        kill `get_pid`
 +        for i in 1 2 3 4 5 6 7 8 9 10
 +        # for i in `seq 10`
 +        do
 +            if ! is_running; then
 +                break
 +            fi
 +
 +            echo -n "."
 +            sleep 1
 +        done
 +        echo
 +
 +        if is_running; then
 +            echo "Not stopped; may still be shutting down or shutdown may have failed"
 +            exit 1
 +        else
 +            echo "Stopped"
 +            if [ -f "$pid_file" ]; then
 +                rm "$pid_file"
 +            fi
 +        fi
 +    else
 +        echo "Not running"
 +    fi
 +    ;;
 +    restart)
 +    $0 stop
 +    if is_running; then
 +        echo "Unable to stop, will not attempt to start"
 +        exit 1
 +    fi
 +    $0 start
 +    ;;
 +    status)
 +    if is_running; then
 +        echo "Running"
 +    else
 +        echo "Stopped"
 +        exit 1
 +    fi
 +    ;;
 +    *)
 +    echo "Usage: $0 {start|stop|restart|status}"
 +    exit 1
 +    ;;
 +esac
 +
 +exit 0
 +</code>
 +
 +<code bash hbbr>
 +#!/bin/sh
 +### BEGIN INIT INFO
 +# Provides:          hbbs
 +# Required-Start:    $remote_fs $syslog
 +# Required-Stop:     $remote_fs $syslog
 +# Default-Start:     2 3 4 5
 +# Default-Stop:      0 1 6
 +# Short-Description: Rust Relay Server
 +# Description:       This provides the definition of the relay server for rust
 +### END INIT INFO
 +
 +dir="/opt/rust"
 +cmd="hbbr"
 +user="rust"
 +
 +name=`basename $0`
 +pid_file="/var/run/$name.pid"
 +stdout_log="/var/log/$name.log"
 +stderr_log="/var/log/$name.err"
 +
 +get_pid() {
 +    cat "$pid_file"
 +}
 +
 +is_running() {
 +    [ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1
 +}
 +
 +case "$1" in
 +    start)
 +    if is_running; then
 +        echo "Already started"
 +    else
 +        echo "Starting $name"
 +        cd "$dir"
 +        if [ -z "$user" ]; then
 +            sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
 +        else
 +            sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
 +        fi
 +        echo $! > "$pid_file"
 +        if ! is_running; then
 +            echo "Unable to start, see $stdout_log and $stderr_log"
 +            exit 1
 +        fi
 +    fi
 +    ;;
 +    stop)
 +    if is_running; then
 +        echo -n "Stopping $name.."
 +        kill `get_pid`
 +        for i in 1 2 3 4 5 6 7 8 9 10
 +        # for i in `seq 10`
 +        do
 +            if ! is_running; then
 +                break
 +            fi
 +
 +            echo -n "."
 +            sleep 1
 +        done
 +        echo
 +
 +        if is_running; then
 +            echo "Not stopped; may still be shutting down or shutdown may have failed"
 +            exit 1
 +        else
 +            echo "Stopped"
 +            if [ -f "$pid_file" ]; then
 +                rm "$pid_file"
 +            fi
 +        fi
 +    else
 +        echo "Not running"
 +    fi
 +    ;;
 +    restart)
 +    $0 stop
 +    if is_running; then
 +        echo "Unable to stop, will not attempt to start"
 +        exit 1
 +    fi
 +    $0 start
 +    ;;
 +    status)
 +    if is_running; then
 +        echo "Running"
 +    else
 +        echo "Stopped"
 +        exit 1
 +    fi
 +    ;;
 +    *)
 +    echo "Usage: $0 {start|stop|restart|status}"
 +    exit 1
 +    ;;
 +esac
 +
 +exit 0
 +</code>
 +
 +Now (we're almost done), run the following commands to start the both servers up.
 +
 +<code bash>
 +chmod 755 /etc/init.d/hbbr
 +chmod 755 /etc/init.d/hbbs
 +# test hbbs
 +/etc/init.d/hbbs start
 +# test hbbr
 +/etc/init.d/hbbr start
 +# if both worked correctly, run the following command to automatically start at boot
 +update-rc.d hbbs defaults
 +update-rc.d hbbr defaults
 +</code>
 +
 +If you made it through the last step with no errors, you should now be able to access the server from one of the clients.
 +
 +===== Optional Steps =====
 +
 +The script that techahold wrote will ask permission, then automatically install a lightweight web server and create customized installers for Windows and Linux. I'm not going into that here, but it is pretty straightforward. Another github user, dinger1986, has install scripts for [[https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1|Microsoft Windows]] and many flavors of [[https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh|Linux]] (not Devuan, unfortunately).
 +
 +Basically, you can download those scripts and run the following commands on them. Then, make them available to your users who can run them on their computer and have RustDesk Client installed on their computer, already set up for your server.
 +
 +Download and edit the following file. Change your.url.or.ip to the URL or IP of your new server, and change contents_of_public_key_file_on_your_server to the contents of /opt/rustdesk/id_ed25519.pub. When done, you will have two files, //WindowsAgentAIOInstall.ps1//, which can be run with Windows Power Shell, and //linuxclientinstall.sh// which can be run from the command line on a Linux machine.
 +
 +<code bash>
 +#!/usr/bin/env sh
 +
 +WANIP=your.url.or.ip
 +KEY=contents_of_public_key_file_on_your_server
 +string="{\"host\":\"${wanip}\",\"relay\":\"${wanip}\",\"key\":\"${key}\",\"api\":\"https://${wanip}\"}"
 +string64=$(echo -n "$string" | base64 -w 0 | tr -d '=')
 +string64rev=$(echo -n "$string64" | rev)
 +wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1
 +sudo sed -i "s|secure-string|${string64rev}|g" WindowsAgentAIOInstall.ps1
 +# Create linux install script
 +wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh
 +sudo sed -i "s|secure-string|${string64rev}|g" linuxclientinstall.sh
 +</code>
 +
 +===== Links =====
 +
 +  * [[https://github.com/fhd/init-script-template|Template for creating SysV init scripts]]
 +  * [[https://github.com/techahold/rustdeskinstall/blob/master/install.sh|Excellent install script for open source RustDesk Server on Linux which uses SystemD]]
 +  * [[https://rustdesk.com/docs/en/self-host/rustdesk-server-oss/install/|Documentation from RustDesk for installing the Open Source server]]
 +  * [[https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/|Installer Scripts for RustDesk Client]]
 +  * [[https://rustdesk.com/docs/en/self-host/client-deployment/|Several customized installer scripts for RustDesk Client]]
software/rust/server_devuan.1758201419.txt.gz · Last modified: 2025/09/18 08:16 by rodolico