mirror of
https://github.com/YunoHost-Apps/shellinabox_ynh.git
synced 2024-09-03 20:26:12 +02:00
[enh] Add backup/restore scripts; cleanup.
This commit is contained in:
parent
1296c0adeb
commit
7a3a13cda9
4 changed files with 54 additions and 2 deletions
16
scripts/backup
Normal file
16
scripts/backup
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
33
scripts/restore
Normal file
33
scripts/restore
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue