Skip to content

Instantly share code, notes, and snippets.

@dstapp
Created August 6, 2016 12:13
Show Gist options
  • Save dstapp/38f603b9252aed333a319eed756d0d2c to your computer and use it in GitHub Desktop.
Save dstapp/38f603b9252aed333a319eed756d0d2c to your computer and use it in GitHub Desktop.
Gogs FreeBSD rc.d script
#!/bin/sh
#
# PROVIDE: gogs
# REQUIRE: networking syslog
# KEYWORD:
. /etc/rc.subr
name="gogs"
rcvar="gogs_enable"
load_rc_config $name
: ${gogs_enable:=no}
: ${gogs_path:="/home/git/go/src/github.com/gogits/gogs"}
command="$gogs_path/gogs web"
pidfile="$gogs_path/gogs.pid"
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
gogs_user="git"
start_cmd="gogs_start"
status_cmd="gogs_status"
stop_cmd="gogs_stop"
gogs_start() {
echo "Starting ${name}..."
cd $gogs_path
su $gogs_user -c "PATH=$PATH /usr/sbin/daemon -p $pidfile -f $command"
}
gogs_status() {
if [ -f ${pidfile} ]; then
echo "${name} is running as $(cat $pidfile)."
else
echo "${name} is not running."
return 1
fi
}
gogs_stop() {
if [ ! -f ${pidfile} ]; then
echo "${name} is not running."
return 1
fi
echo "Stopping ${name}..."
kill -KILL $(cat $pidfile) 2> /dev/null && echo "Killed."
rm -f ${pidfile}
}
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment