diff --git a/.gitignore b/.gitignore index af27749..ea8c0d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ html/bin/*.txt +install/conf.php diff --git a/README.md b/README.md index 8411462..fd94660 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,20 @@ html anchor [mount(8)](https://man.openbsd.org/mount.8)) +### Project directory structure ```sh -/bin/bash + +backup-commander +└─html All web code. You can create a symlink to this directory for your web-server + ├─bin Binary scripts runnable via bash. This directory is NOT served + ├─css All CSS files + ├─img All image files + ├─inc All php files. This directory is NOT served + └─js All JS files +└─install Install and update scripts + ``` -```bat -ls -l -``` TODO: diff --git a/html/index.php b/html/index.php index 3232869..a4349e9 100644 --- a/html/index.php +++ b/html/index.php @@ -16,7 +16,7 @@
-
Executive Backup Panel
+
Executive Backup Panel Version 0.9.0
Login
diff --git a/install/install.php b/install/install.php new file mode 100644 index 0000000..e60611a --- /dev/null +++ b/install/install.php @@ -0,0 +1,23 @@ +>> NOTE:\n>>> The file conf.php must be edited specifically for this system\n"; + echo ">>> The default file has been created for you.\n>>> Please edit the file to match your system\n"; + $data = ""; + file_put_contents( "conf.php", $data); + exit; +} + +include "conf.php"; + +if(!isset($path_website)){ + echo ">>> ERROR:\n"; + echo "The path to the website must be set. Please edit/correct conf.php\n"; + exit; +} + +?> diff --git a/install/install.sh b/install/install.sh new file mode 100755 index 0000000..c97b417 --- /dev/null +++ b/install/install.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# This script must be run as the web user which must be specified as the first parameter +# You may also need to use sudo to invoke the script unless you already have the correct +# permissions to switch user (su) + +# Params check +if [ $# != 1 ]; then + echo "There must be 1 args. Usage:" + echo "./install.sh www-user" + exit; +fi + +webuser=$1 + +prompt_confirm() { + while true; do + read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY + case $REPLY in + [yY]) echo ; return 0 ;; + [nN]) echo ; return 1 ;; + *) printf " \033[31m %s \n\033[0m" "invalid input" + esac + done +} + +echo +echo "This script will git-pull and apply the latest changes" +prompt_confirm "Do you wish to update?" || exit 0 + +echo "Switching user to $webuser" +# won't work on its own. Need sudo and feed it a command string +# su -s /bin/bash $webuser + +sudo su -s /bin/bash $webuser << EOF +git pull +echo "Running install.php" +php install.php +EOF +