watch script working now for realtime edits of UI and config
fixed bug where passed arguments need to be saved for reuse further in scriptmaster
parent
9755e5d08e
commit
d2551161d2
|
@ -4,3 +4,4 @@
|
||||||
/bin/amd64/custom/
|
/bin/amd64/custom/
|
||||||
/frontend/current/
|
/frontend/current/
|
||||||
*.bin
|
*.bin
|
||||||
|
/scripts/addrs=127.0.0.1:6379 db=0/
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/3115.ini
|
1028
config/3115.ini
1028
config/3115.ini
File diff suppressed because it is too large
Load Diff
|
@ -3,7 +3,7 @@
|
||||||
; see https://docs.gitea.io/en-us/config-cheat-sheet/ for additional documentation.
|
; see https://docs.gitea.io/en-us/config-cheat-sheet/ for additional documentation.
|
||||||
;
|
;
|
||||||
; App name that shows in every page title
|
; 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
|
; Change it if you run locally
|
||||||
RUN_USER = sysadmin
|
RUN_USER = sysadmin
|
||||||
; Either "dev", "prod" or "test", default is "dev"
|
; Either "dev", "prod" or "test", default is "dev"
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
<div><h1>McCarty Git Server<h1></div>
|
|
|
@ -0,0 +1 @@
|
||||||
|
<div><h1>{{ AppName }}<h1></div>
|
|
@ -1 +1 @@
|
||||||
<div>Default Body Inner Pre </div>
|
<div><h1>{{ AppName }}<h1></div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/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
|
source $GITEA_DIR/scripts/library
|
||||||
|
|
||||||
ini_gen "$@"
|
ini_gen "$@"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/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
|
export GITEA_GITHUB_REPO=go-gitea/gitea
|
||||||
|
|
||||||
# finds current installed version
|
# finds current installed version
|
||||||
|
@ -60,7 +60,7 @@ declare OPTARG
|
||||||
declare OPTION
|
declare OPTION
|
||||||
declare OPTIND=0
|
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
|
[[ ! $GITEA_DIR ]] && echo main directory not set, aborting && return 2
|
||||||
|
|
||||||
while getopts 'tiud:' OPTION; do
|
while getopts 'tiud:' OPTION; do
|
||||||
|
@ -95,7 +95,7 @@ export GITEA_DATA_DIR
|
||||||
# generates .ini from corresponding .tmpl file
|
# generates .ini from corresponding .tmpl file
|
||||||
function ini_gen () {
|
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 Ini
|
||||||
local Lock=true
|
local Lock=true
|
||||||
|
@ -149,8 +149,8 @@ function download_bin () {
|
||||||
|
|
||||||
# dependencies, jq
|
# dependencies, jq
|
||||||
[[ $(command -v jq &> /dev/null) ]] && echo jq is required, install via \'sudo apt install jq\' && exit
|
[[ $(command -v jq &> /dev/null) ]] && echo jq is required, install via \'sudo apt install jq\' && exit
|
||||||
echo passed stuff: $@
|
# echo passed stuff: $@
|
||||||
[[ ! $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))
|
||||||
[[ ! $GITEA_BIN ]] && set_env "$@"
|
[[ ! $GITEA_BIN ]] && set_env "$@"
|
||||||
[[ ! $GITEA_BIN ]] && echo a Gitea binary path not set, aborting && exit 1
|
[[ ! $GITEA_BIN ]] && echo a Gitea binary path not set, aborting && exit 1
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# $1 ini file, $2 arch
|
echo 'restarting gitea'
|
||||||
echo 'restarting gitea after change'
|
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
|
||||||
DIR=$(dirname "$(readlink -f "$0")") || exit
|
$GITEA_DIR/scripts/stop
|
||||||
$DIR/stop
|
$GITEA_DIR/scripts/start "$@"
|
||||||
$DIR/start $1 $2
|
|
||||||
|
|
13
scripts/run
13
scripts/run
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/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
|
source $GITEA_DIR/scripts/library
|
||||||
|
|
||||||
declare Ini
|
declare Ini
|
||||||
|
@ -10,6 +10,8 @@ declare OPTARG
|
||||||
declare OPTION
|
declare OPTION
|
||||||
declare OPTIND=0
|
declare OPTIND=0
|
||||||
|
|
||||||
|
Saved=("$*")
|
||||||
|
|
||||||
while getopts 'itu' OPTION; do
|
while getopts 'itu' OPTION; do
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
u) Upgrade=true ;;
|
u) Upgrade=true ;;
|
||||||
|
@ -19,16 +21,15 @@ while getopts 'itu' OPTION; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# echo upgrade: $Upgrade
|
shift $(( $OPTIND - 1 ))
|
||||||
# echo passed $@
|
|
||||||
set_env "$@"
|
set_env $Saved
|
||||||
# echo passed $@
|
|
||||||
|
|
||||||
echo "#### running instance: $GITEA_INSTANCE with environment ####"
|
echo "#### running instance: $GITEA_INSTANCE with environment ####"
|
||||||
env | grep GITEA
|
env | grep GITEA
|
||||||
echo "##################################"
|
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
|
[[ ! $(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; }
|
mkdir -p $GITEA_DATA_DIR 2>/dev/null || { echo "unable to make repos directory at $GITEA_DATA_DIR, exiting"; exit; }
|
||||||
|
|
|
@ -1,22 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
DIR="$(dirname "$(cd "$(dirname "$(readlink -f "$0")")";pwd -P)")"|| exit
|
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
|
||||||
COMMAND=$DIR/scripts/run "$@"
|
|
||||||
echo $DIR $COMMAND
|
|
||||||
|
|
||||||
PIDFILE="$DIR/gitea.pid"
|
PIDFILE="$GITEA_DIR/gitea.pid"
|
||||||
# echo $PIDFILE
|
|
||||||
# read -r PID < $PIDFILE
|
|
||||||
# echo PID $PID
|
|
||||||
# echo "$(ps -ea | grep $PID)"
|
|
||||||
if [ -e ${PIDFILE} ]; then
|
if [ -e ${PIDFILE} ]; then
|
||||||
read -r PID < $PIDFILE
|
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."
|
echo "start aborted gitea is already running."
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo starting gitea detached sending log to $GITEA_LOG/gitea.log
|
||||||
echo starting gitea sending log to gitea.log
|
$GITEA_DIR/scripts/run "$@" > $GITEA_DIR/gitea.log &
|
||||||
$COMMAND > $DIR/gitea.log &
|
|
||||||
echo PID of gitea process is $!
|
|
||||||
echo $! > $PIDFILE
|
echo $! > $PIDFILE
|
||||||
|
|
10
scripts/stop
10
scripts/stop
|
@ -1,16 +1,16 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
DIR=$(dirname "$(readlink -f "$0")") || exit
|
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
|
||||||
PIDFILE="$DIR/gitea.pid"
|
|
||||||
|
|
||||||
|
PIDFILE="$GITEA_DIR/gitea.pid"
|
||||||
if [ ! -e ${PIDFILE} ]; then
|
if [ ! -e ${PIDFILE} ]; then
|
||||||
# echo "gitea is not running."
|
echo "can't find PID file $PIDFILE process state unknown"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -r PID < $PIDFILE
|
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"
|
echo "gitea is not running. ignoring stop request"
|
||||||
exit 1;
|
exit 0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CHILD_PIDS=$(pgrep -P $PID);
|
CHILD_PIDS=$(pgrep -P $PID);
|
||||||
|
|
|
@ -1,8 +1,28 @@
|
||||||
#!/bin/bash
|
#!/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
|
ServiceName=gitea
|
||||||
Instance=$1
|
Instance=$1
|
||||||
[[ ! $1 ]] && echo warning no instance supplied using default && Instance=default
|
[[ ! $1 ]] && echo warning no instance supplied using default && Instance=default
|
||||||
Service=$ServiceName@$Instance
|
Service=$ServiceName@$Instance
|
||||||
systemctl is-active --quiet $Service && \
|
if systemctl is-active --quiet $Service; then
|
||||||
sudo systemctl enable $Service || \
|
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"
|
echo "can't persist $Instance as it must be running first"
|
||||||
|
fi
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/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
|
source $GITEA_DIR/scripts/library
|
||||||
|
|
||||||
download_bin "$@"
|
download_bin "$@"
|
||||||
|
|
|
@ -1,20 +1,43 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
DEBOUNCE=1.0
|
DEBOUNCE=1.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))
|
||||||
# export WATCH_DIR="$DIR/frontend/"
|
|
||||||
|
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
|
# export WATCH_VERBOSE=1
|
||||||
COMMAND=$GITEA_DIR/scripts/restart "$@"
|
inotifywait -mqr -e MODIFY $GITEA_DIR/frontend/ $GITEA_DIR/config/$1.$fext |
|
||||||
# LOGFILE="$DIR/watch.log"
|
|
||||||
echo "watching $DIR/frontend/ $DIR/config/$1.ini with $COMMAND"
|
|
||||||
inotifywait -mqr -e MODIFY $DIR/frontend/ $DIR/config/$1.ini |
|
|
||||||
while read ; do
|
while read ; do
|
||||||
# debounce extra events
|
# debounce extra events
|
||||||
currentTime=$(date +'%H%M%S.%N')
|
currentTime=$(date +'%H%M%S.%N')
|
||||||
delta=$(bc <<< "$lastRunTime - $currentTime")
|
delta=$(bc <<< "$lastRunTime - $currentTime")
|
||||||
# echo "$currentTime, $lastRunTime, $delta"
|
# echo "$currentTime, $lastRunTime, $delta"
|
||||||
if (( $(echo "$delta < -$DEBOUNCE" | bc -l) )); then
|
if (( $(echo "$delta < -$DEBOUNCE" | bc -l) )); then
|
||||||
echo $COMMAND
|
echo File Changes Detected - restarting
|
||||||
|
# echo $COMMAND
|
||||||
$COMMAND
|
$COMMAND
|
||||||
lastRunTime=$(date +'%H%M%S.%N')
|
lastRunTime=$(date +'%H%M%S.%N')
|
||||||
|
echo "!Restarted - Refresh The Browser To See Changes"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue