mirror of
https://github.com/YunoHost-Apps/privatebin_ynh.git
synced 2024-09-03 20:15:56 +02:00
63 lines
No EOL
2.1 KiB
Bash
63 lines
No EOL
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
|
set -eu
|
|
|
|
# Source app helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# This is a multi-instance app, meaning it can be installed several times independently
|
|
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
# The app instance name is probably what you are interested the most, since this is
|
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
# db names, ...
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
# Retrieve arguments
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
path=$(ynh_app_setting_get "$app" path)
|
|
user=$(ynh_app_setting_get $app allowed_users)
|
|
is_public=$(ynh_app_setting_get $app is_public)
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
|
|| ynh_die "Path not available: ${domain}${path}"
|
|
|
|
# Check $final_path
|
|
final_path="/var/www/${app}"
|
|
if [ -d $final_path ]; then
|
|
ynh_die "There is already a directory: $final_path"
|
|
fi
|
|
|
|
# Check configuration files
|
|
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
|
|
|
|
# Restore sources & data
|
|
sudo cp -a "./sources" $final_path
|
|
|
|
# Set permissions
|
|
sudo chown -R root:root $final_path
|
|
sudo chown -R www-data:root $final_path/{data,tmp}
|
|
sudo chmod -R 700 $final_path/{data,tmp}
|
|
|
|
# Restore configuration files
|
|
sudo cp -a ./conf/nginx.conf "${nginx_conf}"
|
|
|
|
# Set ssowat config
|
|
if [ "$is_public" = "No" ];
|
|
then
|
|
ynh_app_setting_delete $app skipped_uris
|
|
fi
|
|
|
|
# Reload service
|
|
sudo systemctl reload nginx
|
|
sudo yunohost app ssowatconf |