1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/piwigo_ynh.git synced 2024-09-03 20:06:03 +02:00

Uniformize data_dir creation

This commit is contained in:
Salamandar 2024-03-23 00:00:04 +01:00
parent fddc622514
commit a1d68a915c
3 changed files with 13 additions and 43 deletions

View file

@ -8,6 +8,16 @@
# PERSONAL HELPERS
#=================================================
_create_data_dirs_if_required() {
dirs=(_data galleries upload)
for dir in "${dirs[@]}"; do
if [ ! -d "$data_dir/$dir" ]; then
rsync -a "$install_dir/$dir/" "$data_dir/$dir/"
fi
ynh_secure_remove "$install_dir/$dir"
done
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -21,31 +21,11 @@ ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --dest_dir="$install_dir/plugins/Ldap_Login" --source_id=ldap_plugin
ynh_setup_source --dest_dir="$install_dir/plugins" --source_id=log_failed_logins_plugin
_create_data_dirs_if_required
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# CONFIGURE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Initializing data directory..." --weight=1
# Move data dirs to $data_dir unless they already exist
if [ -d "$install_dir/_data" ]; then
ynh_secure_remove "$install_dir/_data"
else
mv "$install_dir/_data" "$data_dir/_data"
fi
if [ -d "$install_dir/galleries" ]; then
ynh_secure_remove "$install_dir/galleries"
else
mv "$install_dir/galleries" "$data_dir/galleries"
fi
if [ -d "$install_dir/upload" ]; then
ynh_secure_remove "$install_dir/upload"
else
mv "$install_dir/upload" "$data_dir/upload"
fi
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"

View file

@ -20,17 +20,6 @@ if [ -z "${password:-}" ]; then
ynh_app_setting_set --app=$app --key=password --value="$password"
fi
# Get rid of legacy symlinks
if [ -L "$install_dir/_data" ]; then
ynh_secure_remove "$install_dir/_data"
fi
if [ -L "$install_dir/galleries" ]; then
ynh_secure_remove "$install_dir/galleries"
fi
if [ -L "$install_dir/upload" ]; then
ynh_secure_remove "$install_dir/upload"
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -40,16 +29,7 @@ ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --dest_dir="$install_dir/plugins/Ldap_Login" --source_id=ldap_plugin
ynh_setup_source --dest_dir="$install_dir/plugins" --source_id=log_failed_logins_plugin
# We don't want to keep those in the install dir, they already are in $data_dir
if [ -d "$install_dir/_data" ] && [ ! -L "$install_dir/_data" ]; then
ynh_secure_remove "$install_dir/_data"
fi
if [ -d "$install_dir/galleries" ] && [ ! -L "$install_dir/galleries" ]; then
ynh_secure_remove "$install_dir/galleries"
fi
if [ -d "$install_dir/upload" ] && [ ! -L "$install_dir/upload" ]; then
ynh_secure_remove "$install_dir/upload"
fi
_create_data_dirs_if_required
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"