diff --git a/utils/libre b/utils/libre index e9e7e78d982de26230827e54b35d369fbe0cd1ec..a0ec0da93e44e518a1d1626b1644496c290d7f51 100755 --- a/utils/libre +++ b/utils/libre @@ -29,6 +29,19 @@ function systemctl_param { fi } +function show_usage { + echo "Usage:" + echo " - start|status|enable|disable|restart|stop: command sent to systemctl." + echo " - ps|exec|logs: command sent to docker compose." + echo " - update: to update the current folder." + echo " - stats: show docker stats with names." + echo " - delete : remove a libre.sh service." + exit 1 +} + +if [ $# -eq 0 ]; then + show_usage +fi case "$1" in start|status|enable|disable|restart|stop) @@ -62,7 +75,12 @@ case "$1" in stats) docker stats $(docker ps|grep -v "NAMES"|awk '{ print $NF }'|tr "\n" " ");; delete) - read -p "Are you sure you want to delete ${2}? (yY)" -n 1 -r + if [ $# -ne 2 ]; then + echo "delete requires a domainname argument." + exit 1 + fi + + read -p "Are you sure you want to delete ${2}? (yN)" -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]] then @@ -72,6 +90,9 @@ case "$1" in cd /data/domains tar cvzf ${2}.tgz ./${2} if [ -f ./${2}.tgz ]; then + if [ ! -d /data/domains/to_keep/ ]; then + mkdir /data/domains/to_keep/ + fi mv ${2}.tgz /data/domains/to_keep/ rm -rf /data/domains/${2} rm -rf /system/haproxy/certs/${2} @@ -79,9 +100,5 @@ case "$1" in fi fi;; *) - echo "Usage:" - echo " - start|status|enable|disable|restart|stop: command sent to systemctl." - echo " - ps|exec|logs: command sent to docker compose." - echo " - update: to update the current folder." - echo " - stats: show docker stats with names." + show_usage esac