mirror of
https://github.com/YunoHost-Apps/pelican_ynh.git
synced 2024-09-03 19:46:35 +02:00
51 lines
1.3 KiB
Bash
51 lines
1.3 KiB
Bash
#!/bin/bash
|
||
|
||
# Exit on command errors and treat access to unset variables as an error
|
||
set -eu
|
||
|
||
# Source app helpers and functions
|
||
source /usr/share/yunohost/helpers
|
||
|
||
app=$YNH_APP_INSTANCE_NAME
|
||
|
||
# Retrieve arguments
|
||
domain=$(ynh_app_setting_get "$app" domain)
|
||
path=$(ynh_app_setting_get "$app" path)
|
||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||
|
||
# is_public is now a boolean field
|
||
if [ "$is_public" = "Yes" ];
|
||
then
|
||
is_public=1
|
||
fi
|
||
|
||
# Check domain/path availability
|
||
sudo yunohost app checkurl $domain$path -a $app \
|
||
|| ynh_die "The path ${domain}${path} is not available for app installation."
|
||
|
||
# Check destination directory
|
||
DESTDIR="/var/www/$app"
|
||
[[ -d $DESTDIR ]] && ynh_die \
|
||
"The destination directory '$DESTDIR' already exists.\
|
||
You should safely delete it before restoring this app."
|
||
|
||
# Check configuration files
|
||
NGINX_CONF="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||
[[ -f $NGINX_CONF ]] && ynh_die \
|
||
"The NGINX configuration already exists at '${NGINX_CONF}'.
|
||
You should safely delete it before restoring this app."
|
||
|
||
# Restore the app files
|
||
sudo cp -a ./www "$DESTDIR"
|
||
|
||
# Restore configuration files
|
||
sudo cp -a ./conf/nginx.conf "$NGINX_CONF"
|
||
|
||
# Make app public if necessary
|
||
[[ $is_public -eq 1 ]] \
|
||
&& ynh_app_setting_set "$app" unprotected_uris "/"
|
||
|
||
fi
|
||
|
||
# Reload Nginx and regenerate SSOwat conf
|
||
sudo service nginx reload
|