Last active
July 10, 2021 13:37
-
-
Save making/10707457 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# SUSE system statup script for GitBucket | |
# Copyright (C) 2014 Toshiaki Maki | |
# Copyright (C) 2007 Pascal Bleser | |
# | |
# This library is free software; you can redistribute it and/or modify it | |
# under the terms of the GNU Lesser General Public License as published by | |
# the Free Software Foundation; either version 2.1 of the License, or (at | |
# your option) any later version. | |
# | |
# This library is distributed in the hope that it will be useful, but | |
# WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
# Lesser General Public License for more details. | |
# | |
# You should have received a copy of the GNU Lesser General Public | |
# License along with this library; if not, write to the Free Software | |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, | |
# USA. | |
# | |
### BEGIN INIT INFO | |
# Provides: gitbucket | |
# Required-Start: $local_fs $remote_fs $network $time $named | |
# Should-Start: $time sendmail | |
# Required-Stop: $local_fs $remote_fs $network $time $named | |
# Should-Stop: $time sendmail | |
# Default-Start: 3 5 | |
# Default-Stop: 0 1 2 6 | |
# Short-Description: GitBucket REST API Server | |
# Description: Start the GitBucket REST API Server | |
### END INIT INFO | |
# Check for missing binaries (stale symlinks should not happen) | |
GITBUCKET_WAR="/usr/lib/gitbucket/gitbucket.war" | |
test -r "$GITBUCKET_WAR" || { echo "$GITBUCKET_WAR not installed"; | |
if [ "$1" = "stop" ]; then exit 0; | |
else exit 5; fi; } | |
# Check for existence of needed config file and read it | |
GITBUCKET_CONFIG=/etc/sysconfig/gitbucket | |
test -e "$GITBUCKET_CONFIG" || { echo "$GITBUCKET_CONFIG not existing"; | |
if [ "$1" = "stop" ]; then exit 0; | |
else exit 6; fi; } | |
test -r "$GITBUCKET_CONFIG" || { echo "$GITBUCKET_CONFIG not readable. Perhaps you forgot 'sudo'?"; | |
if [ "$1" = "stop" ]; then exit 0; | |
else exit 6; fi; } | |
GITBUCKET_PID_FILE="/var/run/gitbucket.pid" | |
# Source function library. | |
. /etc/init.d/functions | |
# Read config | |
[ -f "$GITBUCKET_CONFIG" ] && . "$GITBUCKET_CONFIG" | |
# Search usable Java. We do this because various reports indicated | |
for candidate in /etc/alternatives/java /usr/bin/java | |
do | |
[ -x "$GITBUCKET_JAVA_CMD" ] && break | |
GITBUCKET_JAVA_CMD="$candidate" | |
done | |
if [ ! -d /var/log/gitbucket ];then | |
mkdir -p /var/log/gitbucket | |
fi | |
JAVA_CMD="$GITBUCKET_JAVA_CMD $GITBUCKET_JAVA_OPTIONS -jar $GITBUCKET_WAR" | |
PARAMS="" | |
[ -n "$GITBUCKET_PORT" ] && PARAMS="$PARAMS --port=$GITBUCKET_PORT" | |
[ -n "$GITBUCKET_PREFIX" ] && PARAMS="$PARAMS --prefix=$GITBUCKET_PREFIX" | |
[ -n "$GITBUCKET_HOST" ] && PARAMS="$PARAMS --host=$GITBUCKET_HOST" | |
[ -n "$GITBUCKET_HOME" ] && PARAMS="$PARAMS --gitbucket.home=$GITBUCKET_HOME" | |
[ -n "$GITBUCKET_ARGS" ] && PARAMS="$PARAMS $GITBUCKET_ARGS" | |
RETVAL=0 | |
case "$1" in | |
start) | |
echo -n "Starting GitBucket " | |
nohup $JAVA_CMD $PARAMS < /dev/null > /var/log/gitbucket/gitbucket.log 2>&1 & | |
pid=$! | |
echo $pid > "$GITBUCKET_PID_FILE" | |
success | |
echo | |
;; | |
stop) | |
echo -n "Shutting down GitBucket " | |
killproc gitbucket | |
RETVAL=$? | |
echo | |
;; | |
try-restart|condrestart) | |
if test "$1" = "condrestart"; then | |
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" | |
fi | |
$0 status | |
if test $? = 0; then | |
$0 restart | |
else | |
: # Not running is not a failure. | |
fi | |
;; | |
restart) | |
$0 stop | |
$0 start | |
;; | |
force-reload) | |
echo -n "Reload service GitBucket " | |
$0 try-restart | |
;; | |
reload) | |
$0 restart | |
;; | |
status) | |
status gitbucket | |
RETVAL=$? | |
;; | |
probe) | |
## Optional: Probe for the necessity of a reload, print out the | |
## argument to this init script which is required for a reload. | |
## Note: probe is not (yet) part of LSB (as of 1.9) | |
test "$GITBUCKET_CONFIG" -nt "$GITBUCKET_PID_FILE" && echo reload | |
;; | |
*) | |
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}" | |
exit 1 | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment