From 8a38f402b0301d0046e1353e97d84ab9bd2a8cb4 Mon Sep 17 00:00:00 2001 From: Yun Date: Sat, 4 Jan 2025 16:40:43 +0800 Subject: [PATCH 1/4] rustdesk-server: add the init.d file for rustdesk-server Signed-off-by: Yun --- net/rustdesk-server/Makefile | 5 +++ net/rustdesk-server/files/rustdesk.init | 43 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 net/rustdesk-server/files/rustdesk.init diff --git a/net/rustdesk-server/Makefile b/net/rustdesk-server/Makefile index e21b973036..e21992d857 100644 --- a/net/rustdesk-server/Makefile +++ b/net/rustdesk-server/Makefile @@ -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 + $(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 diff --git a/net/rustdesk-server/files/rustdesk.init b/net/rustdesk-server/files/rustdesk.init new file mode 100644 index 0000000000..b1a902e9eb --- /dev/null +++ b/net/rustdesk-server/files/rustdesk.init @@ -0,0 +1,43 @@ +#!/bin/sh /etc/rc.common + +START=99 +STOP=10 +USE_PROCD=1 +NAME="rustdesk" +WORKDIR="/etc/rustdesk" + +start_service() { + if [ ! -d "$WORKDIR" ]; then + mkdir -p "$WORKDIR" + if [ $? -ne 0 ]; then + 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" + procd_set_param command sh -c "cd $WORKDIR && /usr/bin/hbbs" + 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 +} From 39f47c9a516f9d5118a1c95b2f5ad0ca23d9104d Mon Sep 17 00:00:00 2001 From: maoerpet Date: Fri, 10 Jan 2025 18:55:52 +0800 Subject: [PATCH 2/4] rustdesk-server: add binaries installation command for makefile Signed-off-by: maoerpet --- net/rustdesk-server/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/rustdesk-server/Makefile b/net/rustdesk-server/Makefile index e21992d857..f807c17f80 100644 --- a/net/rustdesk-server/Makefile +++ b/net/rustdesk-server/Makefile @@ -33,6 +33,10 @@ endef define Package/rustdesk-server/install $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/rustdesk.init $(1)/etc/init.d/rustdesk + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/hbbr $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/hbbs $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/rustdesk-utils $(1)/usr/bin endef define Package/rustdesk-server/description From e321997314f4321b42ce1f113b1c692b20f274b9 Mon Sep 17 00:00:00 2001 From: maoerpet Date: Fri, 10 Jan 2025 18:56:57 +0800 Subject: [PATCH 3/4] rustdesk-server: remove unnecessary commands from the init.d file Signed-off-by: maoerpet --- net/rustdesk-server/files/rustdesk.init | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/net/rustdesk-server/files/rustdesk.init b/net/rustdesk-server/files/rustdesk.init index b1a902e9eb..b89a222274 100644 --- a/net/rustdesk-server/files/rustdesk.init +++ b/net/rustdesk-server/files/rustdesk.init @@ -2,42 +2,25 @@ START=99 STOP=10 + USE_PROCD=1 NAME="rustdesk" + WORKDIR="/etc/rustdesk" start_service() { - if [ ! -d "$WORKDIR" ]; then - mkdir -p "$WORKDIR" - if [ $? -ne 0 ]; then + if ! mkdir -p "$WORKDIR"; then 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" procd_set_param command sh -c "cd $WORKDIR && /usr/bin/hbbs" 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 -} From aa2ff910db8efe68167959a7e23266b63048b683 Mon Sep 17 00:00:00 2001 From: maoerpet Date: Fri, 10 Jan 2025 22:56:04 +0800 Subject: [PATCH 4/4] rustdesk-server: fix indentation by using tabs instead of spaces Signed-off-by: maoerpet --- net/rustdesk-server/Makefile | 6 +++--- net/rustdesk-server/files/rustdesk.init | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/net/rustdesk-server/Makefile b/net/rustdesk-server/Makefile index f807c17f80..95ac65cd67 100644 --- a/net/rustdesk-server/Makefile +++ b/net/rustdesk-server/Makefile @@ -31,10 +31,10 @@ define Package/rustdesk-server endef define Package/rustdesk-server/install - $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_BIN) ./files/rustdesk.init $(1)/etc/init.d/rustdesk + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/rustdesk.init $(1)/etc/init.d/rustdesk $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/hbbr $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/hbbr $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/hbbs $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/rustdesk-utils $(1)/usr/bin endef diff --git a/net/rustdesk-server/files/rustdesk.init b/net/rustdesk-server/files/rustdesk.init index b89a222274..f339ab8a40 100644 --- a/net/rustdesk-server/files/rustdesk.init +++ b/net/rustdesk-server/files/rustdesk.init @@ -10,8 +10,8 @@ WORKDIR="/etc/rustdesk" start_service() { if ! mkdir -p "$WORKDIR"; then - logger -p daemon.err -t "$NAME" "Failed to create working directory: $WORKDIR" - return 1 + logger -p daemon.err -t "$NAME" "Failed to create working directory: $WORKDIR" + return 1 fi procd_open_instance "$NAME.server"