diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..a6c1912 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,16 @@ +#!/bin/bash + +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + +# Retrieve arguments +app="shellinabox" +domain=$(sudo yunohost app setting $app domain) + +# Backup directory location for the app from where the script is executed and +# which will be compressed afterward +backup_dir=$YNH_APP_BACKUP_DIR + +# Copy the conf files +sudo mkdir -p ./conf +sudo cp -a "/etc/nginx/conf.d/${domain}.d/${app}.conf" ./conf/nginx.conf \ No newline at end of file diff --git a/scripts/install b/scripts/install index 83e7e30..96f0382 100644 --- a/scripts/install +++ b/scripts/install @@ -7,10 +7,12 @@ domain=$1 path=$2 # Check domain/path availability -sudo yunohost app checkurl $domain$path -a shellinabox +sudo yunohost app checkurl $domain$path -a shellinabox \ + || (echo "Path not available: $domain$path" && exit 1) # Check port availability -sudo yunohost app checkport 4200 +sudo yunohost app checkport 4200 \ + || (echo "Port not available: 4200" && exit 1) # Remove trailing "/" for next commands if [[ ! "$path" == "/" ]]; then diff --git a/scripts/remove b/scripts/remove index 3b4f819..67d585a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,4 +19,5 @@ sudo yunohost service remove shellinabox # Remove Nginx proxy configuration sudo rm -f /etc/nginx/conf.d/$domain.d/shellinabox.conf +# Restart nginx sudo service nginx reload diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..9e4029f --- /dev/null +++ b/scripts/restore @@ -0,0 +1,33 @@ +#!/bin/bash + +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + +# Retrieve arguments +app="shellinabox" +domain=$(sudo yunohost app setting $app domain) +path=$(sudo yunohost app setting $app path) + +# Remove trailing slash to path +path=${path%/} + +# Check domain/path availability +sudo yunohost app checkurl $domain$path -a $app \ + || (echo "Path not available: $domain$path" && exit 1) + +# Check port availability +sudo yunohost app checkport 4200 \ + || (echo "Port not available: 4200" && exit 1) + +# Check configuration files +NGINX_CONF="/etc/nginx/conf.d/${domain}.d/${app}.conf" +[[ -f $NGINX_CONF ]] && die \ +"The NGINX configuration already exists at '${NGINX_CONF}'. + You should safely delete it before restoring this app." + +# Restore configuration files +sudo cp -a ./conf/nginx.conf "$NGINX_CONF" + +# Reload Nginx and regenerate SSOwat conf +sudo service nginx reload +sudo yunohost app ssowatconf