gitea/scripts/run

51 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(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
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
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