Compare commits

..

12 Commits

4 changed files with 47 additions and 25 deletions

View File

@@ -25,7 +25,7 @@ cd www
Then in a web browser, navigate to `localhost:8080`. Then in a web browser, navigate to `localhost:8080`.
## TODO ## TODO Items
All goals are currently completed. All goals are currently completed.

View File

@@ -16,28 +16,51 @@ function log {
echo -e "`date` : $NAME - $1" echo -e "`date` : $NAME - $1"
} }
function kill-project {
# Kill node.js which will complete run.sh and restart any Docker containers.
# This is more intended towards Development and Stage sites since Production
# will only see git changes when a pull request is manually completed.
log "Stopping continuous processes!"
pkill node
}
function reload-project { function reload-project {
## Kill node.js which will complete run.sh and restart any Docker containers. # Nothing to do, run.sh and main.js automatically uses the latest files.
#pkill node
# Do not kill program, just use the new files and if run.sh or main.js were
# changed then they can get reloaded manually or by the nightly backup.
log "Project reloaded successfully!" log "Project reloaded successfully!"
} }
## Main ## ## Main ##
log "Checking for updates..."
cd $DIR
# Pull any updates, and if the project is already up to date, exit successfully. # Pull any updates, and if the project is already up to date, exit successfully.
git pull | grep -v "up to date" output="`git pull`"
status="$?" git_status="$?"
log "Pull status is '$status'."
if [[ $status != 0 ]]; then echo "$output" | grep -v "up to date"
log "Site is already up to date, exiting." grep_status="$?"
exit 0
else log "Pull status is '$git_status', checking for changes is '$grep_status'."
# Check whether the continuously running jobs have been updated.
echo "$output" | grep "main.js"
main_changed="$?"
echo "$output" | grep "run.sh"
run_changed="$?"
# Determine where we've landed and whether we need to do anything.
if [[ $git_status != 0 ]]; then
log "*** ERROR: Git reported a failure! ***"
exit 1
elif [[ $git_status == 0 && ($main_changed == 0 || $run_changed == 0) ]]; then
log "Either main ('$main_changed'), or run ('$run_changed') were changed!"
kill-project
elif [[ $git_status == 0 && $grep_status == 0 ]]; then
reload-project reload-project
elif [[ $git_status == 0 && $grep_status != 0 ]]; then
log "Nothing to do. '$output'"
else
log "*** WARNING: Unknown Situation ***"
fi fi
## Success! ##
exit 0 exit 0

View File

@@ -6,11 +6,6 @@
} }
$show_pics = $GLOBALS["SHOW_BANNER_PICS"]; $show_pics = $GLOBALS["SHOW_BANNER_PICS"];
$banner_width = $show_pics ? 6 : 12; $banner_width = $show_pics ? 6 : 12;
// TBD / TODO:
// Check if user has vertical screen?
// Is that possible in this environment?
//$image_width = $vertical_screen ? 6 : 3;
?> ?>
<a href='/about/'> <a href='/about/'>
<div class="row"> <div class="row">

14
run.sh
View File

@@ -79,25 +79,29 @@ if [[ $LOGNAME != "root" ]]; then
fi fi
log "Check if any system dependencies need installed." log "Check if any system dependencies need installed."
progs=""
if [[ ! `which php` ]]; then if [[ ! `which php` ]]; then
echo "- Installing PHP" echo "- Installing PHP"
$sudo apt-get install -y php-cli progs="$progs php-cli"
fi fi
if [[ ! `which node` ]]; then if [[ ! `which node` ]]; then
echo "- Installing Node" echo "- Installing Node"
$sudo apt-get install -y nodejs progs="$progs nodejs"
fi fi
if [[ ! `which npm` ]]; then if [[ ! `which npm` ]]; then
echo "- Installing NPM" echo "- Installing NPM"
$sudo apt-get install -y npm progs="$progs npm"
fi fi
if [[ ! `which curl` ]]; then if [[ ! `which curl` ]]; then
echo "- Installing Curl" echo "- Installing Curl"
$sudo apt-get install -y curl progs="$progs curl"
fi fi
if [[ ! `which ps` ]]; then if [[ ! `which ps` ]]; then
echo "- Installing PS" echo "- Installing PS"
$sudo apt-get install -y procps progs="$progs procps"
fi
if [[ -n "$progs" ]]; then
$sudo apt-get install -y $progs
fi fi
# Directories and allowed page types are executable, others are not. # Directories and allowed page types are executable, others are not.