From a37de1795cf58af1aaf8a8d9291117e223f05d7e Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Mon, 10 Oct 2022 21:38:11 +0200 Subject: [PATCH] fix wrong configuration script order --- scripts/install | 70 +++++++++++++++++++++++++------------------------ scripts/restore | 7 +++-- scripts/upgrade | 2 +- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/scripts/install b/scripts/install index b88eb6b..b86e3aa 100755 --- a/scripts/install +++ b/scripts/install @@ -216,6 +216,42 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf" # ... #================================================= +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --time --weight=1 + +### You can add specific configuration files. +### +### Typically, put your template conf file in ../conf/your_config_file +### The template may contain strings such as __FOO__ or __FOO_BAR__, +### which will automatically be replaced by the values of $foo and $foo_bar +### +### ynh_add_config will also keep track of the config file's checksum, +### which later during upgrade may allow to automatically backup the config file +### if it's found that the file was manually modified +### +### Check the documentation of `ynh_add_config` for more info. + + ynh_add_config --template="mount_disk.sh" --destination="$final_path/mount_disk.sh" + ynh_add_config --template="umount_disk.sh" --destination="$final_path/umount_disk.sh" + ynh_add_config --template="garage.toml" --destination="$final_path/garage.toml" + chmod +x "$final_path/mount_disk.sh" "$final_path/umount_disk.sh" + +# FIXME: this should be handled by the core in the future +# You may need to use chmod 600 instead of 400, +# for example if the app is expected to be able to modify its own config +chmod 600 "$final_path/garage.toml" +chown $app:$app "$final_path/garage.toml" + +### For more complex cases where you want to replace stuff using regexes, +### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) +### When doing so, you also need to manually call ynh_store_file_checksum +### +### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file" +### ynh_store_file_checksum --file="$final_path/some_config_file" + + #================================================= # CREATE DATA DIRECTORY #================================================= @@ -259,40 +295,6 @@ if [ "$virtualisation" = "true" ] then $final_path/umount_disk.sh $nbd_index fi -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Adding a configuration file..." --time --weight=1 - -### You can add specific configuration files. -### -### Typically, put your template conf file in ../conf/your_config_file -### The template may contain strings such as __FOO__ or __FOO_BAR__, -### which will automatically be replaced by the values of $foo and $foo_bar -### -### ynh_add_config will also keep track of the config file's checksum, -### which later during upgrade may allow to automatically backup the config file -### if it's found that the file was manually modified -### -### Check the documentation of `ynh_add_config` for more info. - - ynh_add_config --template="mount_disk.sh" --destination="$final_path/mount_disk.sh" - ynh_add_config --template="umount_disk.sh" --destination="$final_path/umount_disk.sh" - ynh_add_config --template="garage.toml" --destination="$final_path/garage.toml" - chmod +x "$final_path/mount_disk.sh" "$final_path/umount_disk.sh" - -# FIXME: this should be handled by the core in the future -# You may need to use chmod 600 instead of 400, -# for example if the app is expected to be able to modify its own config -chmod 600 "$final_path/garage.toml" -chown $app:$app "$final_path/garage.toml" - -### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) -### When doing so, you also need to manually call ynh_store_file_checksum -### -### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file" -### ynh_store_file_checksum --file="$final_path/some_config_file" #================================================= # SETUP SYSTEMD diff --git a/scripts/restore b/scripts/restore index 9ef479e..9cb8a3a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -31,7 +31,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir) -weight=$(ynh_app_setting_get --app=$app --key=weight) virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation) @@ -79,6 +78,8 @@ mkdir -p "$datadir/data" if [ "$virtualisation" = "true" ] then + # Define and install dependencies + ynh_install_app_dependencies $pkg_dependencies_virtualisation # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. qemu-img create -f qcow2 $datadir/garage_data.qcow2 "$weight"G nbd_index=$($final_path/mount_disk.sh "$datadir" true) @@ -105,8 +106,6 @@ chown -R $app:$app "$datadir" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies # Open the port ynh_script_progression --message="Configuring firewall..." --time --weight=1 @@ -142,7 +141,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 -yunohost service add --needs_exposed_ports $app --description="s3 storage" --log="/var/log/$app/$app.log" +yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 0f4528b..8e4b74b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -185,7 +185,7 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 -yunohost service add --needs_exposed_ports $app --description="s3 storage" --log="/var/log/$app/$app.log" +yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app #================================================= # START SYSTEMD SERVICE