2020-12-11 22:55:28 -08:00
|
|
|
#!/bin/bash
|
|
|
|
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(readlink -f "$BASH_SOURCE")"; pwd -P)")"
|
|
|
|
source $GITEA_DIR/scripts/library
|
|
|
|
|
2020-12-13 13:24:31 -08:00
|
|
|
declare Ini
|
|
|
|
declare Upgrade=false
|
|
|
|
declare Template=false
|
|
|
|
declare Lock=true
|
2020-12-11 22:55:28 -08:00
|
|
|
declare OPTARG
|
|
|
|
declare OPTION
|
2020-12-13 13:24:31 -08:00
|
|
|
declare OPTIND=0
|
|
|
|
|
|
|
|
while getopts 'itu' OPTION; do
|
|
|
|
case "$OPTION" in
|
|
|
|
u) Upgrade=true ;;
|
|
|
|
t) Template=true ;;
|
|
|
|
i) Lock=false ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# echo upgrade: $Upgrade
|
|
|
|
# echo passed $@
|
|
|
|
set_env "$@"
|
|
|
|
# echo passed $@
|
|
|
|
|
|
|
|
echo "#### running instance: $GITEA_INSTANCE with environment ####"
|
|
|
|
env | grep GITEA
|
|
|
|
echo "##################################"
|
|
|
|
|
|
|
|
[[ $Upgrade = true ]] && $GITEA_DIR/scripts/fetch-bin "$@"
|
|
|
|
[[ ! $(version) ]] && echo FATAL! $GITEA_BIN missing or corrupt: run `fetch-bin` script && exit 1
|
|
|
|
|
2020-12-11 22:55:28 -08:00
|
|
|
mkdir -p $GITEA_DATA_DIR 2>/dev/null || { echo "unable to make repos directory at $GITEA_DATA_DIR, exiting"; exit; }
|
|
|
|
# setup the custom directory in /current
|
|
|
|
mkdir -p $GITEA_DIR/frontend/current
|
|
|
|
rsync -a --delete $GITEA_DIR/frontend/default/ $GITEA_DIR/frontend/current
|
|
|
|
[[ -d $GITEA_DIR/frontend/$GITEA_INSTANCE ]] && rsync -a $GITEA_DIR/frontend/$GITEA_INSTANCE/ $GITEA_DIR/frontend/current
|
2020-12-13 13:24:31 -08:00
|
|
|
|
|
|
|
[[ $Template = true ]] && ini_gen $([[ $Lock = false ]] && echo "-i") $GITEA_INSTANCE
|
|
|
|
Ini=${GITEA_DIR}/config/${GITEA_INSTANCE}.ini
|
|
|
|
[[ ! -f "$Ini" ]] && { echo "no ini file $Ini, aborting" ; exit; }
|
|
|
|
|
2020-12-11 22:55:28 -08:00
|
|
|
export GITEA_WORK_DIR=$GITEA_DATA_DIR
|
|
|
|
export GITEA_CUSTOM=$GITEA_DIR/frontend/current
|
|
|
|
export USER=sysadmin
|
|
|
|
export HOME=/home/sysadmin
|
2020-12-13 13:24:31 -08:00
|
|
|
echo Running: $GITEA_BIN web -c $Ini
|
|
|
|
echo Git Server repos/logs/data/db will be in $GITEA_DATA_DIR
|
|
|
|
$GITEA_BIN web -c $Ini
|