Skip to content

Instantly share code, notes, and snippets.

@alealexpro100
Last active February 24, 2023 20:50
Show Gist options
  • Save alealexpro100/9e3f9a00dd1baaf605d64f373a3ab187 to your computer and use it in GitHub Desktop.
Save alealexpro100/9e3f9a00dd1baaf605d64f373a3ab187 to your computer and use it in GitHub Desktop.
Build Rustdesk-Server under Alpine Linux + service to run it (based on samba service file).
#!/bin/bash
set -e
declare packages="git alpine-sdk cargo"
declare project_name="rustdesk-server"
echo "Installing build packages..."
sudo apk add $packages
if [[ -d $project_name ]]; then
cd ${project_name}
git pull
else
git clone https://github.com/rustdesk/${project_name}.git
cd ${project_name}
fi
echo "Building..."
#cargo build --release
echo "Copying binaries..."
cp -a target/release/{hbbs,hbbr} ../
cd ../
echo "Compressing files..."
[[ ! -f ${project_name}-release.zip ]] || rm -rf ${project_name:?}-release.zip
zip -9 ${project_name}-release.zip hbbr hbbs
echo "Complete. Have a nice day!"
#!/sbin/openrc-run
name="rustdesk"
description="RustDesk server service"
daemon_list=${daemon_list:-"hbbs hbbr"}
user="$name"
group="$user"
home_dir="/var/opt/rustdesk-server"
depend() {
need net
after firewall
}
start_hbbs() {
start-stop-daemon --start --background \
-k 0002 -u ${user} -g ${group} \
--chdir ${home_dir} \
--exec ${home_dir}/hbbs -- \
${hbbs_options}
}
start_hbbr() {
start-stop-daemon --start --background \
-k 0002 -u ${user} -g ${group} \
--chdir ${home_dir} \
--exec ${home_dir}/hbbr -- \
${hbbr_options:-"-k _"}
}
stop_hbbs() {
start-stop-daemon --stop --exec ${home_dir}/hbbs
}
stop_hbbr() {
start-stop-daemon --stop --exec ${home_dir}/hbbr
}
start() {
for i in $daemon_list; do
ebegin "Starting $i"
start_$i
eend $?
done
}
stop() {
for i in $daemon_list; do
ebegin "Stopping $i"
stop_$i
eend $?
done
}
@alealexpro100
Copy link
Author

alealexpro100 commented Jun 20, 2022

If You don't want to compile it yourself, you can download compiled binaries (for Alpine Linux 3.15) here.
UPDATE: Changed to correct URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment