73 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| #!/sbin/openrc-run
 | |
| # Apache License 2015
 | |
| 
 | |
| user="${user:-gogs}"
 | |
| group="${group:-gogs}"
 | |
| pidfile="${pidfile:-/run/${SVCNAME}.pid}"
 | |
| daemon_opts="${daemon_opts:-web}"
 | |
| logfile="${logfile:-/var/log/gogs/gogs.log}"
 | |
| defaultconf="${defaultconf:-/etc/gogs/conf/app.ini}"
 | |
| startwait=${startwait:-500}
 | |
| timeout=${timeout:-1000}
 | |
| GOGS_CUSTOM="${custom_config_dir:-/etc/gogs/custom}"
 | |
| GOGS_WORK_DIR="${workdir:-/var/lib/gogs}"
 | |
| 
 | |
| depend() {
 | |
| 	need gogs net localmount
 | |
| 	use logger mysql pam cert nginx memcache
 | |
| 	after bootmisc
 | |
| }
 | |
| 
 | |
| start_pre() {
 | |
| 	if [ ! -r "${customconf}" ] ; then
 | |
| 		einfo "Cannot read custom configuration file '${customconf}'"
 | |
| 		if [ ! -r "${defaultconf}" ] ; then
 | |
| 			eerror "Cannot read default configuration file '${defaultconf}'"
 | |
| 			return 1
 | |
| 		else
 | |
| 			einfo "Falling back to '${defaultconf}'"
 | |
| 			customconf="${defaultconf}"
 | |
| 		fi
 | |
| 	fi
 | |
| }
 | |
| 
 | |
| start() {
 | |
| 	ebegin "Starting ${SVCNAME}"
 | |
| 
 | |
| 	export GOGS_CUSTOM
 | |
| 	export GOGS_WORK_DIR
 | |
| 	sh -c "start-stop-daemon \
 | |
| 		--start \
 | |
| 		--user ${user} \
 | |
| 		--group ${group} \
 | |
| 		--background \
 | |
| 		--make-pidfile \
 | |
| 		--pidfile=${pidfile} \
 | |
| 		--wait=${startwait} \
 | |
| 		--stderr=${logfile} \
 | |
| 		--stdout=${logfile} \
 | |
| 		--exec /usr/bin/gogs \
 | |
| 		-- ${daemon_opts} --config ${customconf} "
 | |
| 	local i=0
 | |
| 	while [ ! -f ${pidfile} ] && [ $i -le ${timeout} ]; do
 | |
| 		sleep 1
 | |
| 		i=$(($i + 1000))
 | |
| 	done
 | |
| 
 | |
| 	[ $timeout -gt $i ]
 | |
| 	eend $?
 | |
| }
 | |
| 
 | |
| stop() {
 | |
| 	ebegin "Stopping ${SVCNAME}"
 | |
| 
 | |
| 	start-stop-daemon \
 | |
| 		${DEBUG:+"--verbose"} \
 | |
| 		--stop \
 | |
| 		--exec /usr/bin/gogs \
 | |
| 		--pidfile "${pidfile}"
 | |
| 	eend $?
 | |
| 	rm -f $PIDFILE
 | |
| 	return 0;
 | |
| }
 |