Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdesk-server: add the init.d file for rustdesk-server #1442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions net/rustdesk-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ define Package/rustdesk-server
URL:=https://rustdesk.com/server
endef

define Package/rustdesk-server/install
$(INSTALL_DIR) $(1)/etc/init.d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to add commands for installing the binaries too since you have overridden the default install recipe.
otherwise only this script will be packed.

$(INSTALL_BIN) ./files/rustdesk.init $(1)/etc/init.d/rustdesk
endef

define Package/rustdesk-server/description
Self-host your own RustDesk server, it is free and open source.
endef
Expand Down
43 changes: 43 additions & 0 deletions net/rustdesk-server/files/rustdesk.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh /etc/rc.common

START=99
STOP=10
USE_PROCD=1
NAME="rustdesk"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NAME="rustdesk"
NAME="rustdesk"

WORKDIR="/etc/rustdesk"

start_service() {
if [ ! -d "$WORKDIR" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use tabs for indentation.

mkdir -p "$WORKDIR"
if [ $? -ne 0 ]; then
Comment on lines +11 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir -p "$WORKDIR"
if [ $? -ne 0 ]; then
if ! mkdir -p "$WORKDIR"; then

i would say this error is unlikely to happen, no need to check here

logger -p daemon.err -t "$NAME" "Failed to create working directory: $WORKDIR"
return 1
fi
fi

procd_open_instance "$NAME.server"
procd_set_param cwd "$WORKDIR"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no param called cwd

procd_set_param command sh -c "cd $WORKDIR && /usr/bin/hbbs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is... ugly. needs a way to get rid of sh wrapper

procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance

procd_open_instance "$NAME.relay"
procd_set_param cwd "$WORKDIR"
procd_set_param command sh -c "cd $WORKDIR && /usr/bin/hbbr"
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}

stop_service() {
killall hbbs
killall hbbr
}

reload_service() {
stop_service
start_service
}
Comment on lines +35 to +43
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
stop_service() {
killall hbbs
killall hbbr
}
reload_service() {
stop_service
start_service
}

procd will handle these, drop