Skip to content

Simple shell script to update your rustdesk server running on your uberspace instance

Thanks to the wonderful rustdesk howto, I was able to quickly setup my own rustdesk instance.

With this benefit, I know I have to maintain yet another software so I wrote a dead simple "update_rustdesk.sh" I want to share.

#!/bin/bash
####
# @ref: https://lab.uberspace.de/guide_rustdesk/
# @since: 2025-04-19
# @author: stev leibelt <artodeto@bazzline.net>
####

function _main ()
{
    local CURRENT_WORKING_DIRECTORY
    local INSTALLED_VERSION
    local LOCAL_BASE_PATH
    local VERSION_TO_DOWNLOAD

    CURRENT_WORKING_DIRECTORY=$(pwd)
    # adapt this line
    LOCAL_BASE_PATH="${2:-/home/<string: your_user>/rustdesk}"
    VERSION_TO_DOWNLOAD="${1}"

    if [[ -z "${VERSION_TO_DOWNLOAD}" ]];
    then
        echo ":: Usage"
        echo "   ${0} <string: latest_rustdesk_version> [<string: local_installed_path>"
        echo ""

        return 0
    fi

    if [[ ! -d "${LOCAL_BASE_PATH}" ]];
    then
        echo ":: Error"
        echo "   >>${LOCAL_BASE_PATH}<< is not a directory."
        echo ""

        return 10
    fi

    cd "${LOCAL_BASE_PATH}"

    if [[ ! -f ".current_version" ]];
    then
        echo ":: Error"
        echo "   >>${LOCAL_BASE_PATH}/.current_version<< is not a file."
        echo ""
        cd "${CURRENT_WORKING_DIRECTORY}"

        return 15
    fi

    INSTALLED_VERSION=$(cat ".current_version")

    if [[ "${INSTALLED_VERSION}" == "${VERSION_TO_DOWNLOAD}" ]];
    then
        echo ":: Nothing to do"
        echo "   ${INSTALLED_VERSION} already installed."
        echo ""
        cd "${CURRENT_WORKING_DIRECTORY}"

        return 0
    fi

    if [[ -d "new" ]];
    then
        rm -fr "new"
    fi

    supervisorctl stop rustdesk_hbbr
    supervisorctl stop rustdesk_hbbs

    mkdir -p "new"
    cd new
    if wget "https://github.com/rustdesk/rustdesk-server/releases/download/${VERSION_TO_DOWNLOAD}/rustdesk-server-linux-amd64.zip";
    then
        unzip -j rustdesk-server-linux-amd64.zip

        if [[ ! -f hbbr ]];
        then
            echo ":: Error"
            echo "   >>${LOCAL_BASE_PATH}/new/hbbr is not a file."
            echo ""
            cd "${CURRENT_WORKING_DIRECTORY}"

            return 30
        fi

        if [[ ! -f hbbs ]];
        then
            echo ":: Error"
            echo "   >>${LOCAL_BASE_PATH}/new/hbbs is not a file."
            echo ""
            cd "${CURRENT_WORKING_DIRECTORY}"

            return 32
        fi

        if [[ ! -f rustdesk-utils ]];
        then
            echo ":: Error"
            echo "   >>${LOCAL_BASE_PATH}/new/rustdesk-utils is not a file."
            echo ""
            cd "${CURRENT_WORKING_DIRECTORY}"

            return 34
        fi

        mv ../hbbr ../hbbr.previous
        mv ../hbbs ../hbbs.previous
        mv ../rustdesk-utils ../rustdesk-utils.previous

        mv hbbr ../
        mv hbbs ../
        mv rustdesk-utils ../

        echo "${VERSION_TO_DOWNLOAD}" > ../.current_version

        supervisorctl start rustdesk_hbbs
        supervisorctl start rustdesk_hbbr

        echo "   Switched from >>${INSTALLED_VERSION}<< to >>${VERSION_TO_DOWNLOAD}<<"
    else
        echo ":: Error"
        echo "   wget last exit code ${?}"
        echo ""
        cd "${CURRENT_WORKING_DIRECTORY}"

        return 20
    fi
}

_main "${@}"

You only have to adapt one line, all else should work out of the box.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

The author does not allow comments to this entry

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Markdown format allowed
Form options