2016-05-04 14:17:07 +02:00
|
|
|
#!/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
|
2016-05-04 14:17:07 +02:00
|
|
|
|
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)
|
2016-05-04 14:17:07 +02:00
|
|
|
|
|
|
|
# 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}"
|
2016-05-04 14:17:07 +02:00
|
|
|
|
|
|
|
# Check port availability
|
|
|
|
sudo yunohost app checkport 4200 \
|
2017-04-20 19:34:26 +02:00
|
|
|
|| ynh_die "Port not available: 4200"
|
2016-05-04 14:17:07 +02:00
|
|
|
|
|
|
|
# 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
|
2016-05-04 14:17:07 +02:00
|
|
|
|
|
|
|
# Restore configuration files
|
2017-04-20 19:34:26 +02:00
|
|
|
sudo cp -a ./conf/nginx.conf "${nginx_conf}"
|
2016-05-04 14:17:07 +02:00
|
|
|
|
2017-04-20 19:34:26 +02:00
|
|
|
# Reload service
|
|
|
|
sudo systemctl reload nginx
|
2016-05-04 14:17:07 +02:00
|
|
|
sudo yunohost app ssowatconf
|