2016-03-23 19:30:43 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
2016-09-05 21:11:16 +02:00
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
2016-04-04 22:35:43 +02:00
|
|
|
|
2016-09-05 21:11:16 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
2016-05-23 21:40:55 +02:00
|
|
|
|
|
|
|
#retrieve arguments
|
2016-09-05 21:11:16 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
2016-05-23 21:40:55 +02:00
|
|
|
|
2016-04-04 20:01:54 +02:00
|
|
|
# definie useful vars
|
|
|
|
parent_path=/var/www
|
2016-10-11 20:16:36 +02:00
|
|
|
final_path="$parent_path"/"$app"
|
|
|
|
data_path=/home/yunohost.app/"$app"
|
2016-09-05 21:11:16 +02:00
|
|
|
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_install_from_equivs ../conf/${app}-deps.control || ynh_die "Unable to install dependencies"
|
2016-04-04 20:01:54 +02:00
|
|
|
|
2016-04-05 20:03:26 +02:00
|
|
|
# restore sources & data
|
2016-09-05 21:11:16 +02:00
|
|
|
sudo cp -a ./www "$final_path"
|
|
|
|
sudo mkdir -p "$data_path"
|
|
|
|
sudo cp -a ./data/. "$data_path"
|
2016-04-04 20:01:54 +02:00
|
|
|
|
|
|
|
# restore permissions
|
2016-10-11 20:16:36 +02:00
|
|
|
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
|
2016-03-23 19:30:43 +01:00
|
|
|
|
2016-09-05 21:11:16 +02:00
|
|
|
# restore Nginx & php-fpm
|
|
|
|
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
|
|
|
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
2016-05-23 20:59:08 +02:00
|
|
|
|
|
|
|
# Restart services
|
|
|
|
sudo service php5-fpm restart || true
|
|
|
|
sudo service nginx restart || true
|