diff --git a/conf/systemd.service b/conf/systemd.service index cc4a9bf..a1b91b8 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,7 +6,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ -ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/Headphones.py --config __DATA_DIR__/headphones.ini --datadir __DATA_DIR__ --nolaunch +ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/Headphones.py --config /etc/__APP__/headphones.ini --datadir __DATA_DIR__ --nolaunch # Sandboxing options to harden security # Depending on specificities of your service/app, you may need to tweak these diff --git a/scripts/change_url b/scripts/change_url index ebed8b9..740c329 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -34,10 +34,10 @@ ynh_script_progression --message="Updating a configuration file..." path=$new_path domain=$new_domain -ynh_add_config --template="../conf/headphones.ini" --destination="$data_dir/headphones.ini" +ynh_add_config --template="../conf/headphones.ini" --destination="/etc/$app/headphones.ini" -chmod 600 "$data_dir/headphones.ini" -chown $app:$app "$data_dir/headphones.ini" +chmod 600 "/etc/$app/headphones.ini" +chown $app:$app "/etc/$app/headphones.ini" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 312f9a6..45dd356 100644 --- a/scripts/install +++ b/scripts/install @@ -43,10 +43,11 @@ python3 -m venv $install_dir/venv #================================================= ynh_script_progression --message="Adding a configuration file..." -ynh_add_config --template="../conf/headphones.ini" --destination="$data_dir/headphones.ini" +mkdir -p "/etc/$app" +ynh_add_config --template="../conf/headphones.ini" --destination="/etc/$app/headphones.ini" -chmod 600 "$data_dir/headphones.ini" -chown $app:$app "$data_dir/headphones.ini" +chmod 600 "/etc/$app/headphones.ini" +chown $app:$app "/etc/$app/headphones.ini" #================================================= # SETUP SYSTEMD diff --git a/scripts/restore b/scripts/restore index 2f5c1b0..981394c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,6 +26,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$install_dir" +chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" chmod +x "$install_dir/Headphones.py" @@ -39,6 +40,16 @@ ynh_restore_file --origin_path="$data_dir" --not_mandatory chown -R $app:$app "$data_dir" +#================================================= +# RESTORE VARIOUS FILES +#================================================= +ynh_script_progression --message="Restoring various files..." + +ynh_restore_file --origin_path="/etc/$app/" + +chmod 600 "/etc/$app/headphones.ini" +chown $app:$app "/etc/$app/headphones.ini" + #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 7005890..3f08fb8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -63,8 +63,11 @@ python3 -m venv $install_dir/venv #================================================= ynh_script_progression --message="Updating a configuration file..." -ynh_secure_remove --file="/etc/$app" -ynh_add_config --template="../conf/headphones.ini" --destination="$data_dir/headphones.ini" +if [ -z "/etc/$app/headphones.ini" ]; then + mv /etc/$app/headphones.ini $data_dir/headphones.ini +#else + ynh_add_config --template="../conf/headphones.ini" --destination="$data_dir/headphones.ini" +fi chmod 600 "$data_dir/headphones.ini" chown $app:$app "$data_dir/headphones.ini"