mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
Works on Mac, need to retest on Ubuntu
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
# 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.
|
||||
The configuration adapts according to the OS.
|
||||
Linux directory contains scripts for Ubuntu and RedHat.
|
||||
The Mac scripts have been folded in as well.
|
||||
Common scripts are in this directory.
|
||||
|
||||
This version of scripts has so far only been tested on Ubuntu and Mac. Someone else will have to test on RedHat.
|
||||
|
||||
To run, type:
|
||||
|
||||
install
|
||||
52
contrib/gitbucket.conf
Normal file
52
contrib/gitbucket.conf
Normal file
@@ -0,0 +1,52 @@
|
||||
function isUbuntu {
|
||||
if [ -f /etc/lsb-release ]; then
|
||||
grep -i ubuntu /etc/lsb-release | head -n 1 | cut -d \ -f 1 | cut -d = -f 2
|
||||
fi
|
||||
}
|
||||
|
||||
function isRedHat {
|
||||
if [ -d "/etc/rc.d/init.d" ]; then echo yes; fi
|
||||
}
|
||||
|
||||
function isMac {
|
||||
if [[ "$(uname -a | cut -d \ -f 1 )" == "Darwin" ]]; then echo yes; fi
|
||||
}
|
||||
|
||||
# Bind host
|
||||
GITBUCKET_HOST=0.0.0.0
|
||||
|
||||
# Other Java option
|
||||
GITBUCKET_JVM_OPTS=-Dmail.smtp.starttls.enable=true
|
||||
|
||||
# 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
|
||||
|
||||
# GitBucket version to fetch when installing
|
||||
GITBUCKET_VERSION=2.1
|
||||
|
||||
if [ `isUbuntu` ]; then
|
||||
GITBUCKET_SERVICE=/etc/init.d/gitbucket
|
||||
elif [ `isRedHat` ]; then
|
||||
GITBUCKET_SERVICE=/etc/rc.d/init.d
|
||||
elif [ `isMac` ]; then
|
||||
GITBUCKET_SERVICE=/Library/StartupItems/GitBucket/GitBucket
|
||||
else
|
||||
echo "Don't know how to install onto this OS"
|
||||
exit -2
|
||||
fi
|
||||
@@ -2,6 +2,7 @@
|
||||
#
|
||||
# RedHat: /etc/rc.d/init.d/gitbucket
|
||||
# Ubuntu: /etc/init.d/gitbucket
|
||||
# Mac OS/X: /Library/StartupItems/GitBucket
|
||||
#
|
||||
# Starts the GitBucket server
|
||||
#
|
||||
@@ -9,23 +10,23 @@
|
||||
# description: Run GitBucket server
|
||||
# processname: java
|
||||
|
||||
[ -f /etc/rc.d/init.d/functions ] && source /etc/rc.d/init.d/functions
|
||||
set -e
|
||||
|
||||
[ -f /etc/rc.d/init.d/functions ] && source /etc/rc.d/init.d/functions # RedHat
|
||||
[ -f /etc/rc.common ] && source /etc/rc.common # Mac OS/X
|
||||
|
||||
# Default values
|
||||
GITBUCKET_HOME=/var/lib/gitbucket
|
||||
GITBUCKET_WAR_FILE=/usr/share/gitbucket/lib/gitbucket.war
|
||||
|
||||
# Pull in cq settings
|
||||
[ -f /etc/sysconfig/gitbucket ] && source /etc/sysconfig/gitbucket
|
||||
[ -f $GITBUCKET_DIR/gitbucket.conf ] && source $GITBUCKET_DIR/gitbucket.conf # added for non-redhat systems
|
||||
[ -f /etc/sysconfig/gitbucket ] && source /etc/sysconfig/gitbucket # RedHat
|
||||
[ -f gitbucket.conf ] && source gitbucket.conf # For all systems
|
||||
|
||||
# Location of the log and PID file
|
||||
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'
|
||||
@@ -41,9 +42,12 @@ if [ -z "$(which failure)" ]; then
|
||||
}
|
||||
fi
|
||||
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
echo -n $"Starting GitBucket server: "
|
||||
|
||||
START_OPTS=
|
||||
if [ $GITBUCKET_PORT ]; then
|
||||
START_OPTS="${START_OPTS} --port=${GITBUCKET_PORT}"
|
||||
fi
|
||||
@@ -95,24 +99,39 @@ restart() {
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
StartService() {
|
||||
start
|
||||
}
|
||||
|
||||
StopService() {
|
||||
stop
|
||||
}
|
||||
|
||||
RestartService() {
|
||||
restart
|
||||
}
|
||||
|
||||
|
||||
if [ `isMac` ]; then
|
||||
RunService "$1"
|
||||
else
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
status)
|
||||
status)
|
||||
status -p $PID_FILE java
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
*)
|
||||
echo $"Usage: $0 [start|stop|restart|status]"
|
||||
RETVAL=2
|
||||
esac
|
||||
|
||||
|
||||
exit $RETVAL
|
||||
esac
|
||||
exit $RETVAL
|
||||
fi
|
||||
@@ -3,9 +3,16 @@
|
||||
# Only tested on Ubuntu 14.04
|
||||
|
||||
# Uses information stored in GitBucket git repo on GitHub as defaults.
|
||||
# Edit gitbucket.conf before running this script
|
||||
# Edit gitbucket.conf before running this
|
||||
|
||||
set -e
|
||||
|
||||
GITBUCKET_VERSION=2.1
|
||||
|
||||
if [ ! -f gitbucket.conf ]; then
|
||||
echo "gitbucket.conf not found, aborting"
|
||||
exit -3
|
||||
fi
|
||||
source gitbucket.conf
|
||||
|
||||
function createDir {
|
||||
@@ -15,11 +22,6 @@ function createDir {
|
||||
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
|
||||
@@ -33,17 +35,30 @@ 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"
|
||||
sudo rm -f "$GITBUCKET_LOG_DIR/run.log"
|
||||
|
||||
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
|
||||
if [ `isUbuntu` ] || [ `isRedHat` ]; then
|
||||
sudo cp gitbucket.init "$GITBUCKET_SERVICE"
|
||||
# Install gitbucket as a service that starts when system boots
|
||||
sudo chown root:root $GITBUCKET_SERVICE
|
||||
sudo chmod 755 $GITBUCKET_SERVICE
|
||||
sudo update-rc.d $GITBUCKET_SERVICE defaults
|
||||
echo "Starting GitBucket service"
|
||||
sudo $GITBUCKET_SERVICE start
|
||||
elif [ `isMac` ]; then
|
||||
sudo macosx/makePlist
|
||||
echo "Starting GitBucket service"
|
||||
sudo cp gitbucket.conf "$GITBUCKET_SERVICE"
|
||||
sudo cp gitbucket.init "$GITBUCKET_SERVICE"
|
||||
sudo chmod a+x "$GITBUCKET_SERVICE"
|
||||
sudo "$GITBUCKET_SERVICE" start
|
||||
else
|
||||
echo "Don't know how to install this OS"
|
||||
exit -2
|
||||
fi
|
||||
|
||||
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
|
||||
14
contrib/macosx/gitbucket.plist → contrib/macosx/makePlist
Normal file → Executable file
14
contrib/macosx/gitbucket.plist → contrib/macosx/makePlist
Normal file → Executable file
@@ -1,3 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# From http://docstore.mik.ua/orelly/unix3/mac/ch02_02.htm
|
||||
source gitbucket.conf
|
||||
GITBUCKET_SERVICE_DIR=`dirname "$GITBUCKET_SERVICE"`
|
||||
mkdir -p "$GITBUCKET_SERVICE_DIR"
|
||||
cat << EOF > "$GITBUCKET_SERVICE_DIR/gitbucket.plist"
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
@@ -7,14 +14,15 @@
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/bin/java</string>
|
||||
<string>-Dmail.smtp.starttls.enable=true</string>
|
||||
<string>$GITBUCKET_JVM_OPTS</string>
|
||||
<string>-jar</string>
|
||||
<string>gitbucket.war</string>
|
||||
<string>--host=127.0.0.1</string>
|
||||
<string>--port=8080</string>
|
||||
<string>--host=$GITBUCKET_HOST</string>
|
||||
<string>--port=$GITBUCKET_PORT</string>
|
||||
<string>--https=true</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
@@ -1,30 +0,0 @@
|
||||
# Bind host
|
||||
GITBUCKET_HOST=0.0.0.0
|
||||
|
||||
# Other Java option
|
||||
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
|
||||
Reference in New Issue
Block a user