beszel: init.d pass all env to Beszel, update conf.d, pre-install adduser with nologin

This commit is contained in:
minoplhy 2025-04-29 12:09:18 +07:00
parent 404a7021eb
commit 69d18c31f9
Signed by: minoplhy
GPG Key ID: 41D406044E2434BF
7 changed files with 33 additions and 11 deletions

View File

@ -64,8 +64,8 @@ agent_openrc() {
sha512sums=" sha512sums="
2e0bda8b78b5aaa0e3d57a4b3b443f6bbe3cb6de6eadfed1aed37e4556b4c3092855b95b9450485b1a96609e08aabfa018bf60cd437291b3f9fd0ae20b50403b beszel-0.11.0.tar.gz 2e0bda8b78b5aaa0e3d57a4b3b443f6bbe3cb6de6eadfed1aed37e4556b4c3092855b95b9450485b1a96609e08aabfa018bf60cd437291b3f9fd0ae20b50403b beszel-0.11.0.tar.gz
175af1b0ddf112d00feef5782a9bdf6ac37a08cd5f504e97526a2e7def9bd403216ee4cc3b4ba3f45e0724ba8fd5a736b9ceb2157095316e224ceca5f6463ff2 beszel.confd daeb915d3395d1b0fa278a74e20b2eb711f6db177ea11b30d147355c37511fb5577e6ba541947f7dbfb40ffcbc78589429ee9de13862ed47f71b1968872eaae6 beszel.confd
fd64065cc06b2ec3492722bdd2da0ea3bb2a823533239e1c79c117de163dd1a9832853538f1377af57524c9023e636afc09e163a38007e8e4b71e63035d1881f beszel.initd 240f1573b54a8a4a45ed6034ea6225ebb6b2e361af2fa77a5186acb941aa6aa0946ce773c86c80755e14c1a41ea5baad65a54462446bde207a65de177bc423bb beszel.initd
d999dfdafb6f206a486a3714ef99f52f4c3fbd229bc5d9248fde76679babb0be962ae4fa226e032b16a6c9dcf34ccf2c94454dc8a7a9b0134853789dba657979 beszel-agent.confd 404dec30f31feab4c421cf7e820486b277b0261346abe1cfe9cf7aa78b19f23692243a67b74b479051c2739b3e664d1030562fae594ece101faa8ea4cc0ed915 beszel-agent.confd
a460056a16ad780e30ce819b8d2c484caf0243665138655bd2b8df8939bee4f7b44f41c6839a23f7423f3cf5b652f84361af653613340565978fa27dce03f4f1 beszel-agent.initd 2075fcfac9a8df815b7541d1b55ce4de5327e8afeb079da8fceabe523978070c678eb035efe6815af1e6e735dc6da531634976b82c15f2e505356ca447852484 beszel-agent.initd
" "

View File

@ -3,5 +3,12 @@
# Beszel agent require ssh key from beszel hub to run # Beszel agent require ssh key from beszel hub to run
# without KEY Enviroment, the agent won't run # without KEY Enviroment, the agent won't run
KEY="" KEY=""
# Beszel agent runner port, default is 45876 # Beszel agent runner port, default is 45876
PORT="45876" LISTEN="45876"
# DEPRECATED since v0.10.0
# PORT="45876"
# Monitor extra disk
# more info: https://beszel.dev/guide/additional-disks#binary-agent
#EXTRA_FILESYSTEMS=""

View File

@ -5,6 +5,7 @@ description="Beszel Agent Service"
command="/usr/bin/beszel-agent" command="/usr/bin/beszel-agent"
command_user="beszel-agent" command_user="beszel-agent"
command_background="yes" command_background="yes"
config="/etc/conf.d/beszel-agent"
pidfile="/run/\${RC_SVCNAME}.pid" pidfile="/run/\${RC_SVCNAME}.pid"
output_log="/var/log/beszel-agent/beszel-agent.log" output_log="/var/log/beszel-agent/beszel-agent.log"
error_log="/var/log/beszel-agent/beszel-agent.err" error_log="/var/log/beszel-agent/beszel-agent.err"
@ -12,9 +13,11 @@ error_log="/var/log/beszel-agent/beszel-agent.err"
start_pre() { start_pre() {
checkpath -f -p -m 0644 -o beszel-agent:beszel-agent "\$output_log" "\$error_log" checkpath -f -p -m 0644 -o beszel-agent:beszel-agent "\$output_log" "\$error_log"
checkpath --directory -o beszel-agent:beszel-agent ${pidfile%/*} checkpath --directory -o beszel-agent:beszel-agent ${pidfile%/*}
export PORT="$PORT" # Source and export Configuration variables
export KEY="$KEY" set -a
source $config
set +a
} }
depend() { depend() {

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
addgroup -S beszel-agent 2>/dev/null addgroup -S beszel-agent 2>/dev/null
adduser -S -D -s /bin/sh -G beszel-agent -g beszel-agent beszel-agent 2>/dev/null \ adduser -S -D -s /sbin/nologin -G beszel-agent -g beszel-agent beszel-agent 2>/dev/null \
&& passwd -u beszel-agent 2>/dev/null && passwd -u beszel-agent 2>/dev/null
exit 0 exit 0

View File

@ -6,4 +6,8 @@ PORT=8090
# Beszel dir # Beszel dir
BESZEL_DATADIR=/var/lib/beszel BESZEL_DATADIR=/var/lib/beszel
BESZEL_LOG_FILE=/var/log/beszel/beszel.log BESZEL_LOG_FILE=/var/log/beszel/beszel.log
# URL of the web UI. Must set if serving on a subpath
# more info: https://beszel.dev/guide/serve-on-subpath
#APP_URL=""

View File

@ -6,6 +6,7 @@ command="/usr/bin/beszel"
command_user="${BESZEL_USER:-beszel}" command_user="${BESZEL_USER:-beszel}"
command_args="serve --dir '${BESZEL_DATADIR:-/var/lib/beszel}' --http '${HOST:-127.0.0.1}:${PORT:-8090}'" command_args="serve --dir '${BESZEL_DATADIR:-/var/lib/beszel}' --http '${HOST:-127.0.0.1}:${PORT:-8090}'"
supervise_daemon_args="--chdir '${BESZEL_DATADIR:-/var/lib/beszel}' --stdout '${BESZEL_LOG_FILE:-/var/log/beszel/beszel.log}' --stderr '${BESZEL_LOG_FILE:-/var/log/beszel/beszel.log}'" supervise_daemon_args="--chdir '${BESZEL_DATADIR:-/var/lib/beszel}' --stdout '${BESZEL_LOG_FILE:-/var/log/beszel/beszel.log}' --stderr '${BESZEL_LOG_FILE:-/var/log/beszel/beszel.log}'"
config="/etc/conf.d/beszel"
pidfile="/run/beszel.pid" pidfile="/run/beszel.pid"
extra_started_commands="reopen_log" extra_started_commands="reopen_log"
capabilities="^cap_net_bind_service" capabilities="^cap_net_bind_service"
@ -20,4 +21,11 @@ reopen_log() {
ebegin "Reopening logfile for ${RC_SVCNAME}" ebegin "Reopening logfile for ${RC_SVCNAME}"
${supervisor} ${RC_SVCNAME} --signal USR1 --pidfile "${pidfile}" ${supervisor} ${RC_SVCNAME} --signal USR1 --pidfile "${pidfile}"
eend $? eend $?
}
start_pre() {
# Source and export Configuration variables
set -a
source $config
set +a
} }

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
addgroup -S beszel 2>/dev/null addgroup -S beszel 2>/dev/null
adduser -S -D -s /bin/sh -G beszel -g beszel beszel 2>/dev/null \ adduser -S -D -s /sbin/nologin -G beszel -g beszel beszel 2>/dev/null \
&& passwd -u beszel 2>/dev/null && passwd -u beszel 2>/dev/null
exit 0 exit 0