Added install script, made existing RedHat init script also work with Ubuntu

This commit is contained in:
Mike Slinn
2014-07-28 10:10:27 -07:00
parent 723de9e81e
commit 08e29e7077
4 changed files with 104 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
#!/bin/bash
#
# /etc/rc.d/init.d/gitbucket
# RedHat: /etc/rc.d/init.d/gitbucket
# Ubuntu: /etc/init.d/gitbucket
#
# Starts the GitBucket server
#
@@ -8,28 +9,41 @@
# description: Run GitBucket server
# processname: java
# Source function library
. /etc/rc.d/init.d/functions
[ -f /etc/rc.d/init.d/functions ] && source /etc/rc.d/init.d/functions
# Default values
GITBUCKET_HOME=/var/lib/gitbucket
GITBUCKET_WAR_FILE=/usr/share/gitbucket/lib/gitbucket.war
# Pull in cq settings
[ -f /etc/sysconfig/gitbucket ] && . /etc/sysconfig/gitbucket
[ -f /etc/sysconfig/gitbucket ] && source /etc/sysconfig/gitbucket
[ -f $GITBUCKET_DIR/gitbucket.conf ] && source $GITBUCKET_DIR/gitbucket.conf # added for non-redhat systems
# Location of the log and PID file
LOG_FILE=/var/log/gitbucket/run.log
LOG_FILE=$GITBUCKET_LOG_DIR/run.log
PID_FILE=/var/run/gitbucket.pid
# Default return value
RETVAL=0
RED='\033[1m\E[37;41m'
GREEN='\033[1m\E[37;42m'
OFF='\E[0m'
if [ -z "$(which success)" ]; then
function success {
printf "%b\n" "$GREEN $* $OFF"
}
fi
if [ -z "$(which failure)" ]; then
function failure {
printf "%b\n" "$RED $* $OFF"
}
fi
start() {
echo -n $"Starting GitBucket server: "
# Compile statup parameters
if [ $GITBUCKET_PORT ]; then
START_OPTS="${START_OPTS} --port=${GITBUCKET_PORT}"
fi
@@ -40,17 +54,15 @@ start() {
START_OPTS="${START_OPTS} --host=${GITBUCKET_HOST}"
fi
# Run the Java process
GITBUCKET_HOME="${GITBUCKET_HOME}" java $GITBUCKET_JVM_OPTS -jar $GITBUCKET_WAR_FILE $START_OPTS >>$LOG_FILE 2>&1 &
RETVAL=$?
# Store PID of the Java process into a file
echo $! > $PID_FILE
if [ $RETVAL -eq 0 ] ; then
success "GitBucket startup"
success "Success"
else
failure "GitBucket startup"
failure "Exit code $RETVAL"
fi
echo