Clean Log Warnings, Enhance Runnability (#25)
* Only check the variable if it is set, avoid a log error. * Pipe errors to SDOUT in case that's why Docker is not showing NPM progress. * Two messages seemed very similar. Differentiate them. * Check and install each dependency separately in case a lighter version is already installed. * Don't require sudo if running as root. * Use node instead of relying on shebang. * Allow doing "npm start". * Remove redirects, did not help see progress. * Add a note when sudo is used. * Fix node interpretor location to be arbitrary. * Woops, need to keep advisories if the value is not set to false. * Remove warning about apt CLI. Allow npm start to do dependencies. * `npm start` is not magic, still need to run the install. * Have `npm start` execute the main run script rather than bypassing dependency checks. * Use PHP-CLI, smaller install size and more appropriate since only running local scripts.
This commit is contained in:
parent
9cdb6b47cb
commit
8bf7981b90
2
main.js
2
main.js
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/node
|
#!/usr/bin/env node
|
||||||
'use strict';
|
'use strict';
|
||||||
/*
|
/*
|
||||||
2022-09-14 Hyperling
|
2022-09-14 Hyperling
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": ">=4.18.1"
|
"express": ">=4.18.1"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "./run.sh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@
|
|||||||
<?php
|
<?php
|
||||||
include "banner.php";
|
include "banner.php";
|
||||||
include "menu.php";
|
include "menu.php";
|
||||||
if ($GLOBALS["ADVISORY"] !== false)
|
if (!isset($GLOBALS["ADVISORY"]) || $GLOBALS["ADVISORY"] !== false)
|
||||||
include "advisory.php";
|
include "advisory.php";
|
||||||
?>
|
?>
|
||||||
|
25
run.sh
25
run.sh
@ -41,9 +41,24 @@ done
|
|||||||
# Ensure we are executing from this file's directory.
|
# Ensure we are executing from this file's directory.
|
||||||
cd $DIR
|
cd $DIR
|
||||||
|
|
||||||
echo "`date` - Check if any dependencies need installed."
|
sudo=""
|
||||||
if [[ ! `which php` || ! `which node`|| ! `which npm` ]]; then
|
if [[ $LOGNAME != "root" ]]; then
|
||||||
sudo apt install -y php-fpm nodejs npm
|
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
|
fi
|
||||||
|
|
||||||
# Directories and allowed page types are executable, others are not.
|
# Directories and allowed page types are executable, others are not.
|
||||||
@ -57,13 +72,13 @@ find ./pages/ | while read file; do
|
|||||||
chmod -c $mode $file
|
chmod -c $mode $file
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "`date` - Check if any modules need updated/installed."
|
echo "`date` - Check if any node modules need updated/installed."
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
## Main ##
|
## Main ##
|
||||||
|
|
||||||
echo "`date` - Start website API."
|
echo "`date` - Start website API."
|
||||||
./main.js $ports
|
node ./main.js $ports
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
## Finish ##
|
## Finish ##
|
||||||
|
Loading…
x
Reference in New Issue
Block a user