Skip to content

Instantly share code, notes, and snippets.

@CaseOf
Created September 4, 2017 21:38
Show Gist options
  • Save CaseOf/3096b4c02484bfe3b5aab4c00e075a8a to your computer and use it in GitHub Desktop.
Save CaseOf/3096b4c02484bfe3b5aab4c00e075a8a to your computer and use it in GitHub Desktop.
Gogs init script for ArchLinux
# Apache License 2015
# What user and group should Gogs run as?
user="gogs"
group="gogs"
# Where is Gogs installed?
basedir="/usr/share/gogs" # never used
homedir="/var/lib/gogs"
# What is the Gogs executable called?
daemon="gogs"
# What arguments should be passed to Gogs?
# Only "web" is supported (to start the server)
daemon_opts="web"
# Where does Gogs keep configuration files?
# Only for user information messages at the moment
# default configuration file is in {basedir}/conf/app.ini
conffile="/etc/gogs/app.ini"
# Where should logs be stored?
# Default is ${basedir}/${SVCNAME}.log"
# eg /usr/share/gogs/gogs.log
logfile="${logfile:-/var/log/${SVCNAME}/${SVCNAME}.log}"
# Where should the PID file be saved while Gogs is running?
# Default is "/run/${SVCNAME}.pid"
# eg "/run/gogs.pid"
#pidfile="/run/gogs.pid"
# How long should we wait for Gogs itself to start?
# Expects a number (in milliseconds)
# Default 500
startwait=500
# What is the maximum wait for start-stop-daemon to create a PID file?
# Expects a number (in milliseconds)
# Default 1000
timeout=1000
#!/usr/bin/openrc-run
# Apache License 2015
description="Gogs"
user="${user:-gogs}"
group="${group:-gogs}"
homedir="${homedir:-/var/lib/gogs}"
USER="${user}"
HOME="${homedir}"
basedir="${basedir:-/usr/share/gogs}"
daemon_opts="${daemon_opts:-web}"
logfile="${logfile:-/var/log/${SVCNAME}/${SVCNAME}.log}"
conffile="${conffile:-/etc/gogs/app.ini}"
startwait=${startwait:-500}
timeout=${timeout:-1000}
pidfile="${pidfile:-/run/${SVCNAME}.pid}"
command="${daemon:-gogs}"
command_args="${daemon_opts} --config \"${conffile}\""
command_background=true
start_stop_daemon_args="--chdir=${homedir} --user ${user} --group ${group} --wait=${startwait} --stderr=${logfile} --stdout=${logfile} ${DEBUG:+"--verbose"}"
depend() {
need gogs net localmount
use logger mysql sqlite3 postgresql tidb pam cert nginx memcache redis
after bootmisc
}
start_pre() {
if [ ! -r "${conffile}" ] ; then
eerror "Cannot read configuration file '${conffile}'"
return 1
fi
}
start_post() {
local i=0
while [ ! -f ${pidfile} ] && [ $i -le ${timeout} ]; do
sleep 1
i=$(($i + 1000))
done
[ $timeout -gt $i ]
}
stop_post() {
rm -f ${pidfile}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment