Add Static Resource Hosting (#8)
* Add ability to host files from web API rather than using the static site files.hyperling.com. * Add details. * Prevent further files from being committed in the static resource folder. * Beginnings of a photo share from the website to replace PhotoPrism. * Fix log message for files route. * Allow customization of ports via shell script. * Update README goals and fix URLs. * FInalize the PHOTOS page, complete with video controls! * Moe enhancements, such as displaying README's and adding [VIDEO] tag. * Clean file a little. * Remove TODO.
This commit is contained in:
51
run.sh
51
run.sh
@ -2,12 +2,46 @@
|
||||
# 2022-09-14 Hyperling
|
||||
# Ensure dependencies are met and start the webserver.
|
||||
|
||||
# Ensure we are executing from this file's directory.
|
||||
cd `dirname $0`
|
||||
## Setup ##
|
||||
|
||||
### Can docker-compose do this rather than running a sh file on the host OS?
|
||||
# Look at Dockerfile-ADD for doing git clones into a docker environment.
|
||||
# Out of scope for this project, this project is just the site, leave for now.
|
||||
DIR=`dirname $0`
|
||||
PROG=`basename $0`
|
||||
|
||||
## Functions ##
|
||||
|
||||
function usage {
|
||||
cat <<- EOF
|
||||
$PROG calls the main Node.js program after ensuring the project can run.
|
||||
(PORTS)
|
||||
-p : Pass the port numbers that the API/website should listen at.
|
||||
Example: $PROG -p 80 -p 443 -p 8080
|
||||
(HELP)
|
||||
-h : Show this usage output and exit successfully.
|
||||
EOF
|
||||
exit $1
|
||||
}
|
||||
|
||||
## Parameters ##
|
||||
|
||||
while getopts ':p:h' opt; do
|
||||
case "$opt" in
|
||||
p) (( OPTARG < 1024 )) && [[ $LOGNAME != "root" ]] && {
|
||||
echo "WARNING: Port $OPTARG is privileged. Will need to be root."
|
||||
exit 1
|
||||
}
|
||||
ports="$ports $OPTARG" ;;
|
||||
h) usage 0 ;;
|
||||
*) echo "ERROR: Option $OPTARG not recognized." >&2
|
||||
usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
## Build Environment ##
|
||||
|
||||
# Ensure we are executing from this file's directory.
|
||||
cd $DIR
|
||||
|
||||
# Check if any dependencies need installed.
|
||||
if [[ ! `which php` || ! `which node`|| ! `which npm` ]]; then
|
||||
sudo apt install -y php-fpm nodejs npm
|
||||
fi
|
||||
@ -25,7 +59,10 @@ done
|
||||
|
||||
npm install
|
||||
|
||||
./main.js
|
||||
###
|
||||
## Main ##
|
||||
|
||||
./main.js $ports
|
||||
|
||||
## Finish ##
|
||||
|
||||
exit $?
|
||||
|
Reference in New Issue
Block a user