Compare commits
4 Commits
2.0
...
eaf8d2e0bb
| Author | SHA1 | Date | |
|---|---|---|---|
| eaf8d2e0bb | |||
| 616663ffe0 | |||
| 1cd182b3a9 | |||
| ccd4f4d051 |
@@ -25,7 +25,9 @@ function kill-project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reload-project {
|
function reload-project {
|
||||||
# Nothing to do, run.sh and main.js automatically uses the latest files.
|
# Not much to do, run.sh and main.js automatically uses the latest files.
|
||||||
|
rm -v files/photos/index.html
|
||||||
|
# TBD/TODO: Call check_photos.sh once it has been pulled from run.sh.
|
||||||
log "Project reloaded successfully!"
|
log "Project reloaded successfully!"
|
||||||
}
|
}
|
||||||
|
|
||||||
46
check_photos.sh
Executable file
46
check_photos.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# 2025-10-15 Hyperling
|
||||||
|
# Create script which does the photo checking so that it can be called by
|
||||||
|
# scripts other than just run.sh, such as if it needs used in check_git.sh.
|
||||||
|
|
||||||
|
## Setup ##
|
||||||
|
|
||||||
|
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||||
|
PROG="$(basename -- "${BASH_SOURCE[0]}")"
|
||||||
|
cd $DIR
|
||||||
|
DIR="`pwd`"
|
||||||
|
NAME="'$PROG'"
|
||||||
|
|
||||||
|
function log {
|
||||||
|
echo -e "`date` : $NAME - $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
## Parameters ##
|
||||||
|
|
||||||
|
ports="$1"
|
||||||
|
|
||||||
|
## Main ##
|
||||||
|
|
||||||
|
count=1
|
||||||
|
http_code=0
|
||||||
|
port="${ports%% *}"
|
||||||
|
photos_uri=":$port/photos/"
|
||||||
|
beg_time="$SECONDS"
|
||||||
|
while [[ $http_code != "200" ]]; do
|
||||||
|
log "Sleeping for '$count' while waiting for $photos_uri to come up."
|
||||||
|
sleep $count
|
||||||
|
log "Checking if $photos_uri is available."
|
||||||
|
http_code="`curl --silent --fail -w '\n%{http_code}' localhost$photos_uri | tail -n 1`"
|
||||||
|
log "Check for $photos_uri responded with '$http_code'."
|
||||||
|
if (( $count >= 10 )); then
|
||||||
|
log "Giving up on loading $photos_uri after '$count' attempts."
|
||||||
|
break
|
||||||
|
else
|
||||||
|
count=$(( count + 1 ))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
end_time="$SECONDS"
|
||||||
|
time="$(( $end_time - $beg_time ))"
|
||||||
|
log "Finished checking for /photos/ after '$time' seconds."
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 text">
|
<div class="col-12 text">
|
||||||
<p>
|
<p>
|
||||||
Click the link below to download the 4-page PDF:
|
Use the links below to download the 4-page PDF:
|
||||||
</p>
|
</p>
|
||||||
<ul class="indent">
|
<ul class="indent">
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 text">
|
<div class="col-12 text">
|
||||||
<p>
|
<p>
|
||||||
Click the link below to download the 10-page PDF:
|
Use the links below to download the 10-page PDF:
|
||||||
</p>
|
</p>
|
||||||
<ul class="indent">
|
<ul class="indent">
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
28
run.sh
28
run.sh
@@ -123,35 +123,15 @@ log "Removing old index files."
|
|||||||
find files/photos/ -name "*".html -print -delete
|
find files/photos/ -name "*".html -print -delete
|
||||||
{
|
{
|
||||||
check_main photos
|
check_main photos
|
||||||
count=1
|
$DIR/check_photos.sh "$ports"
|
||||||
http_code=0
|
|
||||||
port="${ports%% *}"
|
|
||||||
photos_uri=":$port/photos/"
|
|
||||||
beg_time="$SECONDS"
|
|
||||||
while [[ $http_code != "200" ]]; do
|
|
||||||
log "Sleeping for '$count' while waiting for $photos_uri to come up."
|
|
||||||
sleep $count
|
|
||||||
log "Checking if $photos_uri is available."
|
|
||||||
http_code="`curl --silent --fail -w '\n%{http_code}' localhost$photos_uri | tail -n 1`"
|
|
||||||
log "Check for $photos_uri responded with '$http_code'."
|
|
||||||
if (( $count >= 10 )); then
|
|
||||||
log "Giving up on loading $photos_uri after '$count' attempts."
|
|
||||||
break
|
|
||||||
else
|
|
||||||
count=$(( count + 1 ))
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
end_time="$SECONDS"
|
|
||||||
time="$(( $end_time - $beg_time ))"
|
|
||||||
log "Finished checking for /photos/ after '$time' seconds."
|
|
||||||
} &
|
} &
|
||||||
|
|
||||||
## Main ##
|
## Main ##
|
||||||
|
|
||||||
log "Start local cronjob."
|
log "Start check_git."
|
||||||
while true; do
|
while true; do
|
||||||
check_main cronjob
|
check_main check_git
|
||||||
$DIR/cronjob.sh
|
$DIR/check_git.sh
|
||||||
sleep 30
|
sleep 30
|
||||||
done &
|
done &
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user