mirror of
https://github.com/YunoHost-Apps/bozon_ynh.git
synced 2024-09-03 18:16:09 +02:00
16ef7053e6
* Correct restore script `ynh_package_install_from_equivs` * Change in each script `#! /bin/bash` with `#!/bin/bash` * Correct `pathluaregex` in case of a installation on root
64 lines
2.1 KiB
Bash
64 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
set -eu
|
|
|
|
# Source YunoHost helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#retrieve arguments
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
path=$(ynh_app_setting_get "$app" path)
|
|
|
|
# definie useful vars
|
|
parent_path=/var/www
|
|
final_path="$parent_path"/"$app"
|
|
data_path=/home/yunohost.app/"$app"
|
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
|
|
# check domain/path availability with app helper
|
|
sudo yunohost app checkurl $domain$path -a $app \
|
|
|| ynh_die "The path ${domain}${path} is not available for app installation."
|
|
|
|
# check directories availability
|
|
[[ -d $final_path ]] && ynh_die \
|
|
"The path '${final_path}' already exists.
|
|
You should safely delete it before restoring this app."
|
|
[[ -d $data_path ]] && ynh_die \
|
|
"The path '${data_path}' already exists.
|
|
You should safely delete it before restoring this app."
|
|
|
|
# check configuration files
|
|
[[ -f $nginx_conf ]] && ynh_die \
|
|
"The NGINX configuration already exists at '${nginx_conf}'.
|
|
You should safely delete it before restoring this app."
|
|
[[ -f $phpfpm_conf ]] && ynh_die \
|
|
"The PHP FPM configuration already exists at '${phpfpm_conf}'.
|
|
You should safely delete it before restoring this app."
|
|
|
|
# add required packages
|
|
ynh_package_is_installed "php5-curl" || ynh_package_install "php5-curl"
|
|
ynh_package_is_installed "php5-gd" || ynh_package_install "php5-gd"
|
|
|
|
# restore sources & data
|
|
sudo cp -a ./www "$final_path"
|
|
sudo mkdir -p "$data_path"
|
|
sudo cp -a ./data/. "$data_path"
|
|
|
|
# restore permissions
|
|
sudo chown -R root: "$final_path"
|
|
sudo find "$final_path" -type f | xargs sudo chmod 644
|
|
sudo find "$final_path" -type d | xargs sudo chmod 755
|
|
sudo chown -R www-data: "$final_path"/private
|
|
sudo chown -R www-data: "$data_path"/uploads
|
|
sudo chown -R www-data: "$data_path"/thumbs
|
|
|
|
# restore Nginx & php-fpm
|
|
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
|
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
|
|
|
# Restart services
|
|
sudo service php5-fpm restart || true
|
|
sudo service nginx restart || true
|