mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-10-27 08:36:17 +01:00
Added install script, made existing RedHat init script also work with Ubuntu
This commit is contained in:
6
contrib/README.md
Normal file
6
contrib/README.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Contrib Notes #
|
||||||
|
RedHat directory also contains scripts for Ubuntu, and the configuration adapts according to the OS.
|
||||||
|
Ideally the Mac scripts would also be folded in as well.
|
||||||
|
|
||||||
|
This version of scripts has so far only been tested on Ubuntu. I'll test on Mac also, but someone else will have to test on RedHat.
|
||||||
|
|
||||||
@@ -1,17 +1,30 @@
|
|||||||
# Bind host
|
# Bind host
|
||||||
#GITBUCKET_HOST=0.0.0.0
|
GITBUCKET_HOST=0.0.0.0
|
||||||
|
|
||||||
# Server port
|
|
||||||
#GITBUCKET_PORT=8080
|
|
||||||
|
|
||||||
# Data directory (GITBUCKET_HOME/gitbucket)
|
|
||||||
#GITBUCKET_HOME=/var/lib/gitbucket
|
|
||||||
|
|
||||||
# Path to the WAR file
|
|
||||||
#GITBUCKET_WAR_FILE=/usr/share/gitbucket/lib/gitbucket.war
|
|
||||||
|
|
||||||
# URL prefix for the GitBucket page (http://<host>:<port>/<prefix>/)
|
|
||||||
#GITBUCKET_PREFIX=
|
|
||||||
|
|
||||||
# Other Java option
|
# Other Java option
|
||||||
#GITBUCKET_JVM_OPTS=
|
GITBUCKET_JVM_OPTS=
|
||||||
|
|
||||||
|
# Data directory, holds repositories
|
||||||
|
GITBUCKET_HOME=/var/lib/gitbucket
|
||||||
|
|
||||||
|
GITBUCKET_LOG_DIR=/var/log/gitbucket
|
||||||
|
|
||||||
|
# Server port
|
||||||
|
GITBUCKET_PORT=8080
|
||||||
|
|
||||||
|
# URL prefix for the GitBucket page (http://<host>:<port>/<prefix>/)
|
||||||
|
GITBUCKET_PREFIX=
|
||||||
|
|
||||||
|
# Directory where GitBucket is installed
|
||||||
|
# Configuration is stored here:
|
||||||
|
GITBUCKET_DIR=/usr/share/gitbucket
|
||||||
|
GITBUCKET_WAR_DIR=$GITBUCKET_DIR/lib
|
||||||
|
|
||||||
|
# Path to the WAR file
|
||||||
|
GITBUCKET_WAR_FILE=$GITBUCKET_WAR_DIR/gitbucket.war
|
||||||
|
|
||||||
|
# RedHat prefers /etc/rc.d/init.d
|
||||||
|
GITBUCKET_SERVICE=/etc/init.d/gitbucket
|
||||||
|
|
||||||
|
# GitBucket version to fetch when installing
|
||||||
|
GITBUCKET_VERSION=2.1
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# /etc/rc.d/init.d/gitbucket
|
# RedHat: /etc/rc.d/init.d/gitbucket
|
||||||
|
# Ubuntu: /etc/init.d/gitbucket
|
||||||
#
|
#
|
||||||
# Starts the GitBucket server
|
# Starts the GitBucket server
|
||||||
#
|
#
|
||||||
@@ -8,28 +9,41 @@
|
|||||||
# description: Run GitBucket server
|
# description: Run GitBucket server
|
||||||
# processname: java
|
# processname: java
|
||||||
|
|
||||||
# Source function library
|
[ -f /etc/rc.d/init.d/functions ] && source /etc/rc.d/init.d/functions
|
||||||
. /etc/rc.d/init.d/functions
|
|
||||||
|
|
||||||
# Default values
|
# Default values
|
||||||
GITBUCKET_HOME=/var/lib/gitbucket
|
GITBUCKET_HOME=/var/lib/gitbucket
|
||||||
GITBUCKET_WAR_FILE=/usr/share/gitbucket/lib/gitbucket.war
|
GITBUCKET_WAR_FILE=/usr/share/gitbucket/lib/gitbucket.war
|
||||||
|
|
||||||
# Pull in cq settings
|
# 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
|
# 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
|
PID_FILE=/var/run/gitbucket.pid
|
||||||
|
|
||||||
# Default return value
|
# Default return value
|
||||||
RETVAL=0
|
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() {
|
start() {
|
||||||
echo -n $"Starting GitBucket server: "
|
echo -n $"Starting GitBucket server: "
|
||||||
|
|
||||||
# Compile statup parameters
|
|
||||||
if [ $GITBUCKET_PORT ]; then
|
if [ $GITBUCKET_PORT ]; then
|
||||||
START_OPTS="${START_OPTS} --port=${GITBUCKET_PORT}"
|
START_OPTS="${START_OPTS} --port=${GITBUCKET_PORT}"
|
||||||
fi
|
fi
|
||||||
@@ -40,17 +54,15 @@ start() {
|
|||||||
START_OPTS="${START_OPTS} --host=${GITBUCKET_HOST}"
|
START_OPTS="${START_OPTS} --host=${GITBUCKET_HOST}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the Java process
|
|
||||||
GITBUCKET_HOME="${GITBUCKET_HOME}" java $GITBUCKET_JVM_OPTS -jar $GITBUCKET_WAR_FILE $START_OPTS >>$LOG_FILE 2>&1 &
|
GITBUCKET_HOME="${GITBUCKET_HOME}" java $GITBUCKET_JVM_OPTS -jar $GITBUCKET_WAR_FILE $START_OPTS >>$LOG_FILE 2>&1 &
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
|
||||||
# Store PID of the Java process into a file
|
|
||||||
echo $! > $PID_FILE
|
echo $! > $PID_FILE
|
||||||
|
|
||||||
if [ $RETVAL -eq 0 ] ; then
|
if [ $RETVAL -eq 0 ] ; then
|
||||||
success "GitBucket startup"
|
success "Success"
|
||||||
else
|
else
|
||||||
failure "GitBucket startup"
|
failure "Exit code $RETVAL"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|||||||
49
contrib/redhat/install
Executable file
49
contrib/redhat/install
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Only tested on Ubuntu 14.04
|
||||||
|
|
||||||
|
# Uses information stored in GitBucket git repo on GitHub as defaults.
|
||||||
|
# Edit gitbucket.conf before running this script
|
||||||
|
|
||||||
|
GITBUCKET_VERSION=2.1
|
||||||
|
source gitbucket.conf
|
||||||
|
|
||||||
|
function createDir {
|
||||||
|
if [ ! -d "$1" ]; then
|
||||||
|
echo "Making $1 directory."
|
||||||
|
sudo mkdir -p "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -d "/etc/init.d/" ]; then
|
||||||
|
echo "/etc/init.d/ does not exist. This script requires System V init script compatibility."
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(which iptables)" ]; then
|
||||||
|
echo "Opening port $GITBUCKET_PORT in firewall."
|
||||||
|
sudo iptables -A INPUT -p tcp --dport $GITBUCKET_PORT -j ACCEPT
|
||||||
|
fi
|
||||||
|
|
||||||
|
createDir "$GITBUCKET_HOME"
|
||||||
|
createDir "$GITBUCKET_WAR_DIR"
|
||||||
|
createDir "$GITBUCKET_DIR"
|
||||||
|
createDir "$GITBUCKET_LOG_DIR"
|
||||||
|
|
||||||
|
echo "Fetching GitBucket v$GITBUCKET_VERSION and saving as $GITBUCKET_WAR_FILE"
|
||||||
|
sudo wget -qO "$GITBUCKET_WAR_FILE" https://github.com/takezoe/gitbucket/releases/download/$GITBUCKET_VERSION/gitbucket.war
|
||||||
|
|
||||||
|
# Install gitbucket as a service that starts when system boots
|
||||||
|
sudo cp gitbucket.init "$GITBUCKET_SERVICE"
|
||||||
|
echo "Copying gitbucket.conf to $GITBUCKET_DIR"
|
||||||
|
sudo cp gitbucket.conf $GITBUCKET_DIR
|
||||||
|
sudo chown root:root $GITBUCKET_SERVICE
|
||||||
|
sudo chmod 755 $GITBUCKET_SERVICE
|
||||||
|
sudo update-rc.d $GITBUCKET_SERVICE defaults
|
||||||
|
|
||||||
|
echo "Starting GitBucket service"
|
||||||
|
sudo rm -f "$GITBUCKET_LOG_DIR/run.log"
|
||||||
|
sudo $GITBUCKET_SERVICE start
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
less "$GITBUCKET_LOG_DIR/run.log"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user