watch script working now for realtime edits of UI and config

fixed bug where passed arguments  need to be saved for reuse further in script
master
David Kebler 2020-12-13 17:16:53 -08:00
parent 9755e5d08e
commit d2551161d2
16 changed files with 85 additions and 1076 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
/bin/amd64/custom/
/frontend/current/
*.bin
/scripts/addrs=127.0.0.1:6379 db=0/

1
config/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/3115.ini

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
; see https://docs.gitea.io/en-us/config-cheat-sheet/ for additional documentation.
;
; App name that shows in every page title
APP_NAME = McCarty Git Server on Frodo
APP_NAME = Nick McCarty Personal Git Server
; Change it if you run locally
RUN_USER = sysadmin
; Either "dev", "prod" or "test", default is "dev"

View File

@ -1 +0,0 @@
<div><h1>McCarty Git Server<h1></div>

View File

@ -0,0 +1 @@
<div><h1>{{ AppName }}<h1></div>

View File

@ -1 +1 @@
<div>Default Body Inner Pre </div>
<div><h1>{{ AppName }}<h1></div>

View File

@ -1,5 +1,5 @@
#!/bin/bash
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(readlink -f "$BASH_SOURCE")"; pwd -P)")"
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
source $GITEA_DIR/scripts/library
ini_gen "$@"

View File

@ -1,5 +1,5 @@
#!/bin/bash
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(dirname "$BASH_SOURCE")"; pwd -P)")"
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
export GITEA_GITHUB_REPO=go-gitea/gitea
# finds current installed version
@ -60,7 +60,7 @@ declare OPTARG
declare OPTION
declare OPTIND=0
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(readlink -f "$BASH_SOURCE")"; pwd -P)")"
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
[[ ! $GITEA_DIR ]] && echo main directory not set, aborting && return 2
while getopts 'tiud:' OPTION; do
@ -95,7 +95,7 @@ export GITEA_DATA_DIR
# generates .ini from corresponding .tmpl file
function ini_gen () {
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(readlink -f "$BASH_SOURCE")"; pwd -P)")"
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
local Ini
local Lock=true
@ -149,8 +149,8 @@ function download_bin () {
# dependencies, jq
[[ $(command -v jq &> /dev/null) ]] && echo jq is required, install via \'sudo apt install jq\' && exit
echo passed stuff: $@
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(dirname "$BASH_SOURCE")"; pwd -P)")"
# echo passed stuff: $@
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
[[ ! $GITEA_BIN ]] && set_env "$@"
[[ ! $GITEA_BIN ]] && echo a Gitea binary path not set, aborting && exit 1

View File

@ -1,6 +1,5 @@
#!/bin/bash
# $1 ini file, $2 arch
echo 'restarting gitea after change'
DIR=$(dirname "$(readlink -f "$0")") || exit
$DIR/stop
$DIR/start $1 $2
echo 'restarting gitea'
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
$GITEA_DIR/scripts/stop
$GITEA_DIR/scripts/start "$@"

View File

@ -1,5 +1,5 @@
#!/bin/bash
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(readlink -f "$BASH_SOURCE")"; pwd -P)")"
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
source $GITEA_DIR/scripts/library
declare Ini
@ -10,6 +10,8 @@ declare OPTARG
declare OPTION
declare OPTIND=0
Saved=("$*")
while getopts 'itu' OPTION; do
case "$OPTION" in
u) Upgrade=true ;;
@ -19,16 +21,15 @@ while getopts 'itu' OPTION; do
esac
done
# echo upgrade: $Upgrade
# echo passed $@
set_env "$@"
# echo passed $@
shift $(( $OPTIND - 1 ))
set_env $Saved
echo "#### running instance: $GITEA_INSTANCE with environment ####"
env | grep GITEA
echo "##################################"
[[ $Upgrade = true ]] && $GITEA_DIR/scripts/fetch-bin "$@"
[[ $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; }

View File

@ -1,22 +1,14 @@
#!/bin/bash
DIR="$(dirname "$(cd "$(dirname "$(readlink -f "$0")")";pwd -P)")"|| exit
COMMAND=$DIR/scripts/run "$@"
echo $DIR $COMMAND
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
PIDFILE="$DIR/gitea.pid"
# echo $PIDFILE
# read -r PID < $PIDFILE
# echo PID $PID
# echo "$(ps -ea | grep $PID)"
PIDFILE="$GITEA_DIR/gitea.pid"
if [ -e ${PIDFILE} ]; then
read -r PID < $PIDFILE
if (ps -ea | grep $PID); then
if (ps -ea | grep $PID) &> /dev/null; then
echo "start aborted gitea is already running."
exit 1;
fi
fi
echo starting gitea sending log to gitea.log
$COMMAND > $DIR/gitea.log &
echo PID of gitea process is $!
echo starting gitea detached sending log to $GITEA_LOG/gitea.log
$GITEA_DIR/scripts/run "$@" > $GITEA_DIR/gitea.log &
echo $! > $PIDFILE

View File

@ -1,16 +1,16 @@
#!/bin/bash
DIR=$(dirname "$(readlink -f "$0")") || exit
PIDFILE="$DIR/gitea.pid"
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
PIDFILE="$GITEA_DIR/gitea.pid"
if [ ! -e ${PIDFILE} ]; then
# echo "gitea is not running."
echo "can't find PID file $PIDFILE process state unknown"
exit 1;
fi
read -r PID < $PIDFILE
if ( ! ps -ea | grep $PID ); then
if ( ! ps -ea | grep $PID ) &> /dev/null; then
echo "gitea is not running. ignoring stop request"
exit 1;
exit 0;
fi
CHILD_PIDS=$(pgrep -P $PID);

View File

@ -1,8 +1,28 @@
#!/bin/bash
declare OPTARG
declare OPTION
declare OPTIND=0
state=enable
while getopts 'd' OPTION; do
case "$OPTION" in
d) state=disable;;
esac
done
shift $(( $OPTIND - 1 ))
Instance=$1
ServiceName=gitea
Instance=$1
[[ ! $1 ]] && echo warning no instance supplied using default && Instance=default
Service=$ServiceName@$Instance
systemctl is-active --quiet $Service && \
sudo systemctl enable $Service || \
if systemctl is-active --quiet $Service; then
sudo systemctl $state $Service
systemctl is-enabled --quiet $Service && \
echo $Service boot persistance is enabled || \
echo $Service boot persistance is disabled
else
echo "can't persist $Instance as it must be running first"
fi

View File

@ -1,5 +1,5 @@
#!/bin/bash
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(dirname "$BASH_SOURCE")"; pwd -P)")"
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
source $GITEA_DIR/scripts/library
download_bin "$@"

View File

@ -1,20 +1,43 @@
#!/bin/bash
DEBOUNCE=1.0
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(readlink -f "$BASH_SOURCE")"; pwd -P)")"
# export WATCH_DIR="$DIR/frontend/"
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
fext=ini
declare OPTARG
declare OPTION
declare OPTIND=0
Saved=("$*")
while getopts 'fg:itud:' OPTION; do
case "$OPTION" in
t) fext=tmpl ;;
*) ;;
esac
done
shift $(( $OPTIND - 1 ))
echo stopping any systemd process
$GITEA_DIR/scripts/systemd/stop $1
# $GITEA_DIR/scripts/start $Saved
# LOGFILE="$GITEA_DIR/watch.log"
COMMAND="$GITEA_DIR/scripts/restart $Saved"
$COMMAND
echo "watching: $GITEA_DIR/frontend/ $GITEA_DIR/config/$1.$fext, running: $COMMAND"
# export WATCH_DIR="$GITEA_DIR/frontend/"
# export WATCH_VERBOSE=1
COMMAND=$GITEA_DIR/scripts/restart "$@"
# LOGFILE="$DIR/watch.log"
echo "watching $DIR/frontend/ $DIR/config/$1.ini with $COMMAND"
inotifywait -mqr -e MODIFY $DIR/frontend/ $DIR/config/$1.ini |
inotifywait -mqr -e MODIFY $GITEA_DIR/frontend/ $GITEA_DIR/config/$1.$fext |
while read ; do
# debounce extra events
currentTime=$(date +'%H%M%S.%N')
delta=$(bc <<< "$lastRunTime - $currentTime")
# echo "$currentTime, $lastRunTime, $delta"
if (( $(echo "$delta < -$DEBOUNCE" | bc -l) )); then
echo $COMMAND
echo File Changes Detected - restarting
# echo $COMMAND
$COMMAND
lastRunTime=$(date +'%H%M%S.%N')
echo "!Restarted - Refresh The Browser To See Changes"
fi
done