diff --git a/main.js b/main.js index 8fb93ce..7e3f8c3 100755 --- a/main.js +++ b/main.js @@ -1,4 +1,4 @@ -#!/usr/bin/node +#!/usr/bin/env node 'use strict'; /* 2022-09-14 Hyperling diff --git a/package.json b/package.json index f609c55..8b81125 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,8 @@ { "dependencies": { "express": ">=4.18.1" + }, + "scripts": { + "start": "./run.sh" } } diff --git a/pages/helpers/body_open.php b/pages/helpers/body_open.php index 1bf89fd..b8f2767 100755 --- a/pages/helpers/body_open.php +++ b/pages/helpers/body_open.php @@ -8,6 +8,6 @@ diff --git a/run.sh b/run.sh index 11ea491..5df6188 100755 --- a/run.sh +++ b/run.sh @@ -41,9 +41,24 @@ done # Ensure we are executing from this file's directory. cd $DIR -echo "`date` - Check if any dependencies need installed." -if [[ ! `which php` || ! `which node`|| ! `which npm` ]]; then - sudo apt install -y php-fpm nodejs npm +sudo="" +if [[ $LOGNAME != "root" ]]; then + echo "`date` - Using sudo since user is '$LOGNAME'." + sudo="sudo" +fi + +echo "`date` - Check if any system dependencies need installed." +if [[ ! `which php` ]]; then + echo "- Installing PHP" + $sudo apt-get install -y php-cli +fi +if [[ ! `which node` ]]; then + echo "- Installing Node" + $sudo apt-get install -y nodejs +fi +if [[ ! `which npm` ]]; then + echo "- Installing NPM" + $sudo apt-get install -y npm fi # Directories and allowed page types are executable, others are not. @@ -57,13 +72,13 @@ find ./pages/ | while read file; do chmod -c $mode $file done -echo "`date` - Check if any modules need updated/installed." +echo "`date` - Check if any node modules need updated/installed." npm install ## Main ## echo "`date` - Start website API." -./main.js $ports +node ./main.js $ports status=$? ## Finish ##