mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
Works on Mac, need to retest on Ubuntu
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
# Contrib Notes #
|
# 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
|
# RedHat: /etc/rc.d/init.d/gitbucket
|
||||||
# Ubuntu: /etc/init.d/gitbucket
|
# Ubuntu: /etc/init.d/gitbucket
|
||||||
|
# Mac OS/X: /Library/StartupItems/GitBucket
|
||||||
#
|
#
|
||||||
# Starts the GitBucket server
|
# Starts the GitBucket server
|
||||||
#
|
#
|
||||||
@@ -9,23 +10,23 @@
|
|||||||
# description: Run GitBucket server
|
# description: Run GitBucket server
|
||||||
# processname: java
|
# 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
|
# 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 ] && source /etc/sysconfig/gitbucket
|
[ -f /etc/sysconfig/gitbucket ] && source /etc/sysconfig/gitbucket # RedHat
|
||||||
[ -f $GITBUCKET_DIR/gitbucket.conf ] && source $GITBUCKET_DIR/gitbucket.conf # added for non-redhat systems
|
[ -f gitbucket.conf ] && source gitbucket.conf # For all systems
|
||||||
|
|
||||||
# Location of the log and PID file
|
# Location of the log and PID file
|
||||||
LOG_FILE=$GITBUCKET_LOG_DIR/run.log
|
LOG_FILE=$GITBUCKET_LOG_DIR/run.log
|
||||||
PID_FILE=/var/run/gitbucket.pid
|
PID_FILE=/var/run/gitbucket.pid
|
||||||
|
|
||||||
# Default return value
|
|
||||||
RETVAL=0
|
|
||||||
|
|
||||||
RED='\033[1m\E[37;41m'
|
RED='\033[1m\E[37;41m'
|
||||||
GREEN='\033[1m\E[37;42m'
|
GREEN='\033[1m\E[37;42m'
|
||||||
OFF='\E[0m'
|
OFF='\E[0m'
|
||||||
@@ -41,9 +42,12 @@ if [ -z "$(which failure)" ]; then
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
RETVAL=0
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
echo -n $"Starting GitBucket server: "
|
echo -n $"Starting GitBucket server: "
|
||||||
|
|
||||||
|
START_OPTS=
|
||||||
if [ $GITBUCKET_PORT ]; then
|
if [ $GITBUCKET_PORT ]; then
|
||||||
START_OPTS="${START_OPTS} --port=${GITBUCKET_PORT}"
|
START_OPTS="${START_OPTS} --port=${GITBUCKET_PORT}"
|
||||||
fi
|
fi
|
||||||
@@ -95,24 +99,39 @@ restart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case "$1" in
|
StartService() {
|
||||||
start)
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
StopService() {
|
||||||
|
stop
|
||||||
|
}
|
||||||
|
|
||||||
|
RestartService() {
|
||||||
|
restart
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ `isMac` ]; then
|
||||||
|
RunService "$1"
|
||||||
|
else
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
stop
|
stop
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
restart
|
restart
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
status -p $PID_FILE java
|
status -p $PID_FILE java
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 [start|stop|restart|status]"
|
echo $"Usage: $0 [start|stop|restart|status]"
|
||||||
RETVAL=2
|
RETVAL=2
|
||||||
esac
|
esac
|
||||||
|
exit $RETVAL
|
||||||
|
fi
|
||||||
exit $RETVAL
|
|
||||||
@@ -3,9 +3,16 @@
|
|||||||
# Only tested on Ubuntu 14.04
|
# Only tested on Ubuntu 14.04
|
||||||
|
|
||||||
# Uses information stored in GitBucket git repo on GitHub as defaults.
|
# 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
|
GITBUCKET_VERSION=2.1
|
||||||
|
|
||||||
|
if [ ! -f gitbucket.conf ]; then
|
||||||
|
echo "gitbucket.conf not found, aborting"
|
||||||
|
exit -3
|
||||||
|
fi
|
||||||
source gitbucket.conf
|
source gitbucket.conf
|
||||||
|
|
||||||
function createDir {
|
function createDir {
|
||||||
@@ -15,11 +22,6 @@ function createDir {
|
|||||||
fi
|
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
|
if [ "$(which iptables)" ]; then
|
||||||
echo "Opening port $GITBUCKET_PORT in firewall."
|
echo "Opening port $GITBUCKET_PORT in firewall."
|
||||||
sudo iptables -A INPUT -p tcp --dport $GITBUCKET_PORT -j ACCEPT
|
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"
|
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
|
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 rm -f "$GITBUCKET_LOG_DIR/run.log"
|
||||||
sudo cp gitbucket.init "$GITBUCKET_SERVICE"
|
|
||||||
echo "Copying gitbucket.conf to $GITBUCKET_DIR"
|
echo "Copying gitbucket.conf to $GITBUCKET_DIR"
|
||||||
sudo cp gitbucket.conf $GITBUCKET_DIR
|
sudo cp gitbucket.conf $GITBUCKET_DIR
|
||||||
sudo chown root:root $GITBUCKET_SERVICE
|
if [ `isUbuntu` ] || [ `isRedHat` ]; then
|
||||||
sudo chmod 755 $GITBUCKET_SERVICE
|
sudo cp gitbucket.init "$GITBUCKET_SERVICE"
|
||||||
sudo update-rc.d $GITBUCKET_SERVICE defaults
|
# 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
|
if [ $? != 0 ]; then
|
||||||
less "$GITBUCKET_LOG_DIR/run.log"
|
less "$GITBUCKET_LOG_DIR/run.log"
|
||||||
fi
|
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"?>
|
<?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">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
@@ -7,14 +14,15 @@
|
|||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>/usr/bin/java</string>
|
<string>/usr/bin/java</string>
|
||||||
<string>-Dmail.smtp.starttls.enable=true</string>
|
<string>$GITBUCKET_JVM_OPTS</string>
|
||||||
<string>-jar</string>
|
<string>-jar</string>
|
||||||
<string>gitbucket.war</string>
|
<string>gitbucket.war</string>
|
||||||
<string>--host=127.0.0.1</string>
|
<string>--host=$GITBUCKET_HOST</string>
|
||||||
<string>--port=8080</string>
|
<string>--port=$GITBUCKET_PORT</string>
|
||||||
<string>--https=true</string>
|
<string>--https=true</string>
|
||||||
</array>
|
</array>
|
||||||
<key>RunAtLoad</key>
|
<key>RunAtLoad</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</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