1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/shellinabox_ynh.git synced 2024-09-03 20:26:12 +02:00
shellinabox_ynh/scripts/restore

60 lines
1.6 KiB
Text
Raw Normal View History

#!/bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
2017-04-20 19:34:26 +02:00
set -eu
2017-04-20 19:34:26 +02:00
# Source app helpers
source /usr/share/yunohost/helpers
# Get multi-instances specific variables
app=$YNH_APP_INSTANCE_NAME
2016-05-07 02:00:48 +02:00
2017-04-20 19:34:26 +02:00
# Retrieve arguments
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
# Remove trailing slash to path
path=${path%/}
# Check domain/path availability
2017-04-20 19:34:26 +02:00
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# Check port availability
sudo yunohost app checkport 4200 \
2017-04-20 19:34:26 +02:00
|| ynh_die "Port not available: 4200"
# Check configuration files
2017-04-20 19:34:26 +02:00
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
if [ -f $nginx_conf ]; then
ynh_die "The NGINX configuration already exists at '${nginx_conf}'.
You should safely delete it before restoring this app."
fi
shellinabox_conf="/etc/default/${app}"
if [ -f $shellinabox_conf ]; then
ynh_die "The shellinabox configuration already exists at '${shellinabox_conf}'.
You should safely delete it before restoring this app."
fi
# if shellainbox is installed
shellinabox_bin="/usr/bin/shellinaboxd"
if [ -f $shellinabox_bin ]; then
ynh_die "Good! The shellinabox is installed"
else
sudo apt-get update -qq
sudo apt-get install shellinabox -y -qq
sudo cp -a "./conf/default_${app}" "${shellinabox_conf}"
# Add service into YunoHost
sudo yunohost service add shellinabox
sudo service shellinabox restart
fi
# Restore configuration files
2017-04-20 19:34:26 +02:00
sudo cp -a ./conf/nginx.conf "${nginx_conf}"
2017-04-20 19:34:26 +02:00
# Reload service
sudo systemctl reload nginx
sudo yunohost app ssowatconf