Improve data dir management and use find to optimize permission set

This commit is contained in:
Josué Tille 2023-10-26 10:14:27 +02:00
parent 2139b5d744
commit cf66fcf714
No known key found for this signature in database
GPG key ID: 716A6C99B04194EF
5 changed files with 17 additions and 8 deletions

View file

@ -22,7 +22,7 @@ This app use now the core-only feature of the backup. To keep the integrity of t
`yunohost backup create --app seafile`
- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is stored in `/home/yunohost.app/seafile-data`.
- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is stored in `/home/yunohost.app/seafile`.
- Restart the seafile service with theses command:
`systemctl start seafile.service seahub.service`

View file

@ -71,7 +71,7 @@ ram.runtime = "500M"
subdirs = ["installed", "logs"]
[resources.data_dir]
dir = "/home/yunohost.app/seafile-data"
dir = "/home/yunohost.app/__APP__"
[resources.permissions]
main.url = "/"

View file

@ -75,11 +75,11 @@ set_permission() {
test -e $install_dir/seafile-server-latest/seahub/media && setfacl -R -m user:www-data:rX $install_dir/seafile-server-latest/seahub/media
test -e $install_dir/seahub-data && setfacl -R -m user:www-data:rX $install_dir/seahub-data
# We also check at the install time when data directory is not already initialised
if [ -e /home/yunohost.app/seafile-data ]; then
chown -R $YNH_APP_ID /home/yunohost.app/seafile-data
chmod -R o= /home/yunohost.app/seafile-data
fi
find $data_dir \( \! -perm -o= \
-o \! -user $YNH_APP_ID \
-o \! -group $YNH_APP_ID \) \
-exec chown $YNH_APP_ID:$YNH_APP_ID {} \; \
-exec chmod o= {} \;
}
clean_url_in_db_config() {

View file

@ -26,7 +26,7 @@ fi
ynh_print_info --message="Backing up code..."
ynh_backup --src_path $install_dir
ynh_print_info --message="Backing up user data..."
ynh_backup --src_path=/home/yunohost.app/seafile-data --dest_path="data" --is_big=1
ynh_backup --src_path=$data_dir --dest_path="data" --is_big=1
ynh_print_info --message="Backing up configuration..."
ynh_backup --src_path /etc/nginx/conf.d/$domain.d/${app}.conf
ynh_backup --src_path /etc/systemd/system/seafile.service

View file

@ -64,6 +64,15 @@ if [ -z ${seahub_secret_key:-} ]; then
ynh_app_setting_set --app $app --key seahub_secret_key --value $seahub_secret_key
fi
# Update data dir if needed
if [ $(readlink $install_dir/seafile-data) == '/home/yunohost.app/seafile-data' ]; then
rm $install_dir/seafile-data
ln -s $data_dir $install_dir/seafile-data
fi
if [ -e /home/yunohost.app/seafile-data ]; then
mv /home/yunohost.app/seafile-data $data_dir
fi
ynh_script_progression --message="Upgrading source files..." --weight=6
# Download new version from sources