mirror of
https://github.com/YunoHost-Apps/bozon_ynh.git
synced 2024-09-03 18:16:09 +02:00
Fix restore script
This commit is contained in:
parent
ac27164f80
commit
5164e14019
4 changed files with 19 additions and 24 deletions
|
@ -72,6 +72,17 @@ myynh_add_fpm_config () {
|
||||||
sudo systemctl reload php5-fpm
|
sudo systemctl reload php5-fpm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myynh_set_permissions () {
|
||||||
|
[ $(sudo find "$final_path" -type f | wc -l) -gt 0 ] && sudo find "$final_path" -type f | xargs sudo chmod 0644
|
||||||
|
[ $(sudo find "$final_path" -type d | wc -l) -gt 0 ] && sudo find "$final_path" -type d | xargs sudo chmod 0755
|
||||||
|
[ $(sudo find "$data_path" -type f | wc -l) -gt 0 ] && sudo find "$data_path" -type f | xargs sudo chmod 0644
|
||||||
|
[ $(sudo find "$data_path" -type d | wc -l) -gt 0 ] && sudo find "$data_path" -type d | xargs sudo chmod 0755
|
||||||
|
sudo chown -R root:"$app" "$final_path"
|
||||||
|
sudo chown -R "$app": "$final_path/private"
|
||||||
|
sudo chown -R "$app": "$data_path"
|
||||||
|
sudo chown root: "$data_path"
|
||||||
|
}
|
||||||
|
|
||||||
# Remove the dedicated php-fpm config
|
# Remove the dedicated php-fpm config
|
||||||
myynh_remove_fpm_config () {
|
myynh_remove_fpm_config () {
|
||||||
ynh_secure_remove "$phpfpm_conf"
|
ynh_secure_remove "$phpfpm_conf"
|
||||||
|
|
|
@ -74,13 +74,7 @@ sudo ln -s "$data_path/uploads" "$final_path/uploads"
|
||||||
sudo ln -s "$data_path/thumbs" "$final_path/thumbs"
|
sudo ln -s "$data_path/thumbs" "$final_path/thumbs"
|
||||||
|
|
||||||
# set permissions
|
# set permissions
|
||||||
sudo find "$final_path" -type f | xargs sudo chmod 0644
|
myynh_set_permissions
|
||||||
sudo find "$final_path" -type d | xargs sudo chmod 0755
|
|
||||||
sudo find "$data_path" -type d | xargs sudo chmod 0755
|
|
||||||
sudo chown -R root:"$app" "$final_path"
|
|
||||||
sudo chown -R "$app": "$final_path/private"
|
|
||||||
sudo chown -R "$app": "$data_path/uploads"
|
|
||||||
sudo chown -R "$app": "$data_path/thumbs"
|
|
||||||
|
|
||||||
# configure nginx settings
|
# configure nginx settings
|
||||||
myynh_add_nginx_config
|
myynh_add_nginx_config
|
||||||
|
|
|
@ -25,11 +25,10 @@ backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
||||||
final_path="/var/www/$app"
|
final_path="/var/www/$app"
|
||||||
data_path="/home/yunohost.app/$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
phpfpm_conf="/etc/php5/fpm/pool.d/$app}.conf"
|
phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
# check domain/path availability
|
# check domain/path availability
|
||||||
ynh_webpath_available "$domain" "$path_url"
|
ynh_webpath_available "$domain" "$path_url"
|
||||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
|
||||||
myynh_check_path "$final_path"
|
myynh_check_path "$final_path"
|
||||||
|
|
||||||
# add required packages
|
# add required packages
|
||||||
|
@ -42,26 +41,24 @@ ynh_system_user_create "$app"
|
||||||
ynh_restore_file "$nginx_conf"
|
ynh_restore_file "$nginx_conf"
|
||||||
ynh_restore_file "$phpfpm_conf"
|
ynh_restore_file "$phpfpm_conf"
|
||||||
|
|
||||||
# restore source & their permissions
|
# restore source
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file "$final_path"
|
||||||
sudo chown -R "$app": "$final_path"
|
|
||||||
sudo chmod 755 "$final_path"
|
|
||||||
|
|
||||||
# restore data & their permissions only if there is no data
|
# restore data only if there is no data
|
||||||
if [ ! -d "$data_path" ]; then
|
if [ ! -d "$data_path" ]; then
|
||||||
if [ $backup_core_only -eq 0 ]; then
|
if [ $backup_core_only -eq 0 ]; then
|
||||||
ynh_restore_file "$data_path"
|
ynh_restore_file "$data_path"
|
||||||
sudo chown -R "$app": "$data_path"
|
|
||||||
else
|
else
|
||||||
myynh_create_dir "$data_path/uploads"
|
myynh_create_dir "$data_path/uploads"
|
||||||
sudo chown -R "$app": "$data_path/uploads"
|
|
||||||
myynh_create_dir "$data_path/thumbs"
|
myynh_create_dir "$data_path/thumbs"
|
||||||
sudo chown -R "$app": "$data_path/thumbs"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "$data_path already exists and will not be overwritten" >&2
|
echo "$data_path already exists and will not be overwritten" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# set permissions
|
||||||
|
myynh_set_permissions
|
||||||
|
|
||||||
# restart services
|
# restart services
|
||||||
sudo systemctl reload php5-fpm
|
sudo systemctl reload php5-fpm
|
||||||
sudo systemctl reload nginx
|
sudo systemctl reload nginx
|
||||||
|
|
|
@ -74,14 +74,7 @@ sudo cp -a "$TMPDIR/." "$final_path"
|
||||||
sudo rm -R "$TMPDIR"
|
sudo rm -R "$TMPDIR"
|
||||||
|
|
||||||
# set permissions
|
# set permissions
|
||||||
sudo find "$final_path" -type f | xargs sudo chmod 0644
|
myynh_set_permissions
|
||||||
sudo find "$final_path" -type d | xargs sudo chmod 0755
|
|
||||||
sudo find "$data_path" -type f | xargs sudo chmod 0644
|
|
||||||
sudo find "$data_path" -type d | xargs sudo chmod 0755
|
|
||||||
sudo chown -R root:"$app" "$final_path"
|
|
||||||
sudo chown -R "$app": "$final_path/private"
|
|
||||||
sudo chown -R "$app": "$data_path/uploads"
|
|
||||||
sudo chown -R "$app": "$data_path/thumbs"
|
|
||||||
|
|
||||||
# configure nginx settings
|
# configure nginx settings
|
||||||
myynh_add_nginx_config
|
myynh_add_nginx_config
|
||||||
|
|
Loading…
Reference in a new issue