kloeckner.com.ar

a backup of my entire webpage
Index Commits Files Refs README LICENSE
commit 62aac7c4c0817b0909bcea942d76435ee718e54c
parent c08ad69e87d3ffca4f03272b6bac267426d1d854
Author: mjkloeckner <martinjkloeckner@gmail.com>
Date:   Tue,  9 May 2023 15:23:55 -0300

prompt before overwriting html folder

Diffstat:
Mscripts/deploy_local.sh | 15+++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/scripts/deploy_local.sh b/scripts/deploy_local.sh
@@ -1,18 +1,25 @@
 #!/bin/sh
 
 root_folder="$1"
+html_folder="/var/www/html"
 
 if [ "$(id -u)" -ne "0" ] ; then
     echo "This script must be executed with root privileges."
     exit 1
 fi
 
-set -xe
+echo -n "override folder $html_folder with $root_folder? (Y/n)? "
+read answer
 
-rm -drf /var/www/html >/dev/null 2>&1 ||:
+if [ "$answer" != "${answer#[Yy]}" ] || [ "$answer" = "" ]; then
+    rm -drf "$html_folder" >/dev/null 2>&1 ||:
+    cp -rf "$root_folder" "$html_folder"
+else
+    echo "skipping ..."
+fi
 
-cp -rf "$root_folder" /var/www/html
+set -xe
 
-rm /var/www/html/README.md &>/dev/null 2>&1 ||:
+rm "$html_folder"/README.md &>/dev/null 2>&1 ||:
 
 systemctl restart nginx