From 6510607877fe4e680a0f7db3e110ad87d4a55a86 Mon Sep 17 00:00:00 2001 From: minoplhy Date: Thu, 3 Oct 2024 13:22:26 +0700 Subject: [PATCH] build_gitea: fix: missing dependency(Alpine), init.d / nginx_build_script: add: init.d --- build_gitea/Linux/build.sh | 2 +- build_gitea/Linux/init.d/gitea.initd | 32 ++++++++++++ nginx_build_script/README.md | 78 ++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 build_gitea/Linux/init.d/gitea.initd diff --git a/build_gitea/Linux/build.sh b/build_gitea/Linux/build.sh index 75acd03..8c774c7 100644 --- a/build_gitea/Linux/build.sh +++ b/build_gitea/Linux/build.sh @@ -86,7 +86,7 @@ DISTRO=linux-x64 case $os in "alpine") - apk add nodejs # NodeJS broken when install from binary + apk add nodejs npm # NodeJS broken when install from binary ;; * ) wget https://nodejs.org/dist/$NODEJS_VERSION/node-$NODEJS_VERSION-$DISTRO.tar.xz -O $DESTINATION/node-$NODEJS_VERSION-$DISTRO.tar.xz diff --git a/build_gitea/Linux/init.d/gitea.initd b/build_gitea/Linux/init.d/gitea.initd new file mode 100644 index 0000000..e3616fe --- /dev/null +++ b/build_gitea/Linux/init.d/gitea.initd @@ -0,0 +1,32 @@ +#!/sbin/openrc-run + +supervisor=supervise-daemon +name=gitea +command="/usr/bin/gitea" +command_user="${GITEA_USER:-gitea}" +command_args="web --config '${GITEA_CONF:-/etc/gitea/app.ini}'" +supervise_daemon_args="--env GITEA_WORK_DIR='${GITEA_WORK_DIR:-/var/lib/gitea}' --chdir '${GITEA_WORK_DIR:-/var/lib/gitea}' --stdout '${GITEA_LOG_FILE:-/var/log/gitea/http.log}' --stderr '${GITEA_LOG_FILE:-/var/log/gitea/http.log}'" +pidfile="/run/gitea.pid" +extra_started_commands="reopen_log" +capabilities="^cap_net_bind_service" + +depend() { + use logger dns + need net + after firewall mysql postgresql +} + +#https://github.com/go-gitea/gitea/issues/17976 +#reload() { +# ebegin "Reloading ${RC_SVCNAME}" +# ${supervisor} ${RC_SVCNAME} --signal HUP --pidfile "${pidfile}" +# eend $? +#} + +reopen_log() { + ebegin "Reopening logfile for ${RC_SVCNAME}" + ${supervisor} ${RC_SVCNAME} --signal USR1 --pidfile "${pidfile}" + eend $? +} + +# Taken from https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/gitea/gitea.initd \ No newline at end of file diff --git a/nginx_build_script/README.md b/nginx_build_script/README.md index 31444e5..5c07c54 100644 --- a/nginx_build_script/README.md +++ b/nginx_build_script/README.md @@ -118,3 +118,81 @@ KillMode=mixed WantedBy=multi-user.target ``` + +Nginx init.d + +```initd +#!/sbin/openrc-run + +description="Nginx http and reverse proxy server" +extra_commands="checkconfig" +extra_started_commands="reload reopen upgrade" + +cfgfile=${cfgfile:-/etc/nginx/nginx.conf} +pidfile=/run/nginx.pid +command=${command:-/usr/sbin/nginx} +command_args="-c $cfgfile" +required_files="$cfgfile" + +depend() { + need net + use dns logger netmount +} + +start_pre() { + checkpath --directory --owner www-data:www-data ${pidfile%/*} + $command $command_args -t -q +} + +checkconfig() { + ebegin "Checking $RC_SVCNAME configuration" + start_pre + eend $? +} + +reload() { + ebegin "Reloading $RC_SVCNAME configuration" + start_pre && start-stop-daemon --signal HUP --pidfile $pidfile + eend $? +} + +reopen() { + ebegin "Reopening $RC_SVCNAME log files" + start-stop-daemon --signal USR1 --pidfile $pidfile + eend $? +} + +upgrade() { + start_pre || return 1 + + ebegin "Upgrading $RC_SVCNAME binary" + + einfo "Sending USR2 to old binary" + start-stop-daemon --signal USR2 --pidfile $pidfile + + einfo "Sleeping 3 seconds before pid-files checking" + sleep 3 + + if [ ! -f $pidfile.oldbin ]; then + eerror "File with old pid ($pidfile.oldbin) not found" + return 1 + fi + + if [ ! -f $pidfile ]; then + eerror "New binary failed to start" + return 1 + fi + + einfo "Sleeping 3 seconds before WINCH" + sleep 3 ; start-stop-daemon --signal 28 --pidfile $pidfile.oldbin + + einfo "Sending QUIT to old binary" + start-stop-daemon --signal QUIT --pidfile $pidfile.oldbin + + einfo "Upgrade completed" + + eend $? "Upgrade failed" +} + +modified from https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/nginx/nginx.initd +```