diff options
Moved shell scripts and apache config to their own folder; Updated bash scripts to have checks for root and apps
6 files changed, 42 insertions, 25 deletions
| -rw-r--r-- | configs/devrix-job-board.conf (renamed from devrix-job-board.conf) | 0 | ||||
| -rwxr-xr-x | move-to-www.sh | 10 | ||||
| -rw-r--r-- | src/index.php | 3 | ||||
| -rwxr-xr-x | tools/move-to-www.sh | 16 | ||||
| -rwxr-xr-x | tools/watch-move-to-www.sh | 24 | ||||
| -rwxr-xr-x | watch-move-to-www.sh | 14 |
diff --git a/devrix-job-board.conf b/configs/devrix-job-board.conf index 49356f2..49356f2 100644 --- a/devrix-job-board.conf +++ b/configs/devrix-job-board.conf diff --git a/move-to-www.sh b/move-to-www.sh deleted file mode 100755 index c427606..0000000 --- a/move-to-www.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DEFAULT_DIR="/var/www/devrix-job-board/" - -if [ ! -d "$DEFAULT_DIR" ]; then - sudo -u www-data mkdir $DEFAULT_DIR -fi - -sudo cp -R ./src/. $DEFAULT_DIR -sudo chown -R www-data:www-data $DEFAULT_DIR* diff --git a/src/index.php b/src/index.php index 70da9a1..8dcef32 100644 --- a/src/index.php +++ b/src/index.php @@ -3,7 +3,8 @@ <?php include_once("controllers/LandingController.php"); -/* The landing page practically acts as our page router +/* The landing page practically acts as our page router. + * All request get redirected to here (look at the devrix-job-board.conf) * Thanks https://www.taniarascia.com/the-simplest-php-router/ */ diff --git a/tools/move-to-www.sh b/tools/move-to-www.sh new file mode 100755 index 0000000..ee13725 --- /dev/null +++ b/tools/move-to-www.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit +fi + +DEFAULT_DIR="/var/www/devrix-job-board/" + +if [ ! -d "$DEFAULT_DIR" ]; then + mkdir $DEFAULT_DIR + chown www-data:www-data $DEFAULT_DIR +fi + +cp -R ../src/. $DEFAULT_DIR +chown -R www-data:www-data $DEFAULT_DIR* diff --git a/tools/watch-move-to-www.sh b/tools/watch-move-to-www.sh new file mode 100755 index 0000000..db120b8 --- /dev/null +++ b/tools/watch-move-to-www.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if ! type "inotifywait" > /dev/null; then + echo "You'll need to install inotify-tools!" +fi + +if [ "$EUID" -ne 0 ]; then + echo "Please run as root!" + exit +fi + +DEFAULT_DIR="/var/www/devrix-job-board/" + +if [ ! -d "$DEFAULT_DIR" ]; then + mkdir $DEFAULT_DIR + chown www-data:www-data $DEFAULT_DIR +fi + +inotifywait -m ../src/ -r -e attrib -e create -e move -e delete | + while read dir action file; do + echo "[`date +"%Y-%m-%d %T"`] Updated folder" + cp -R ../src/. $DEFAULT_DIR + chown -R www-data:www-data $DEFAULT_DIR* + done diff --git a/watch-move-to-www.sh b/watch-move-to-www.sh deleted file mode 100755 index a67bc44..0000000 --- a/watch-move-to-www.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -DEFAULT_DIR="/var/www/devrix-job-board/" - -if [ ! -d "$DEFAULT_DIR" ]; then - -u www-data mkdir $DEFAULT_DIR -fi - -inotifywait -m ./src/ -r -e attrib -e create -e move -e delete | - while read dir action file; do - echo "[`date +"%Y-%m-%d %T"`] Updated folder" - cp -R ./src/. $DEFAULT_DIR - chown -R www-data:www-data $DEFAULT_DIR* - done |
