gitea/scripts/run

52 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
source $GITEA_DIR/scripts/library
declare Ini
declare Upgrade=false
declare Template=false
declare Lock=true
declare OPTARG
declare OPTION
declare OPTIND=0
Saved=("$*")
while getopts 'itu' OPTION; do
case "$OPTION" in
u) Upgrade=true ;;
t) Template=true ;;
i) Lock=false ;;
*) ;;
esac
done
shift $(( $OPTIND - 1 ))
set_env $Saved
echo "#### running instance: $GITEA_INSTANCE with environment ####"
env | grep GITEA
echo "##################################"
[[ $Upgrade = true ]] && download_bin "${Saved[@]}"
[[ ! $(version) ]] && echo FATAL! $GITEA_BIN missing or corrupt: run `fetch-bin` script && exit 1
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
[[ $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; }
export GITEA_WORK_DIR=$GITEA_DATA_DIR
export GITEA_CUSTOM=$GITEA_DIR/frontend/current
export USER=sysadmin
export HOME=/home/sysadmin
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