diff --git a/manifest.toml b/manifest.toml index bce8eef..c5a3b38 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,8 @@ admindoc = "https://vikunja.io/docs/" code = "https://kolaente.dev/vikunja/vikunja" [integration] -yunohost = ">= 11.2.21" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = false diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..3d7f008 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,5 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index c711f03..587b47d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,42 +1,33 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app.service" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." +ynh_print_info "Backing up the PostgreSQL database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index e8cbf6f..7c11dd8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -17,45 +11,41 @@ secret=$(ynh_string_random --length=32) timezone="$(cat /etc/timezone)" redis_db=$(ynh_redis_get_free_db) -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action=stop --log_path="systemd" +ynh_systemctl --service=$app --action=stop --log_path="systemd" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." domain="$new_domain" path="$new_path" -ynh_add_config --template="config.yml" --destination="$install_dir/config.yml" +ynh_config_add --template="config.yml" --destination="$install_dir/config.yml" -chmod 600 "$install_dir/config.yml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/config.yml" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action=start --log_path=systemd +ynh_systemctl --service=$app --action=start --log_path=systemd #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index a3fae88..fd5b202 100644 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -31,20 +25,20 @@ maxitemsperpage=50 # STORE SETTINGS FROM MANIFEST #================================================= -ynh_app_setting_set --app=$app --key=set_motd --value=$set_motd -ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration -ynh_app_setting_set --app=$app --key=enable_linksharing --value=$enable_linksharing -ynh_app_setting_set --app=$app --key=enable_taskattachments --value=$enable_taskattachments -ynh_app_setting_set --app=$app --key=enable_taskcomments --value=$enable_taskcomments -ynh_app_setting_set --app=$app --key=enable_emailreminders --value=$enable_emailreminders -ynh_app_setting_set --app=$app --key=enable_userdeletion --value=$enable_userdeletion -ynh_app_setting_set --app=$app --key=maxavatarsize --value=$maxavatarsize -ynh_app_setting_set --app=$app --key=maxitemsperpage --value=$maxitemsperpage +ynh_app_setting_set --key=set_motd --value=$set_motd +ynh_app_setting_set --key=enable_registration --value=$enable_registration +ynh_app_setting_set --key=enable_linksharing --value=$enable_linksharing +ynh_app_setting_set --key=enable_taskattachments --value=$enable_taskattachments +ynh_app_setting_set --key=enable_taskcomments --value=$enable_taskcomments +ynh_app_setting_set --key=enable_emailreminders --value=$enable_emailreminders +ynh_app_setting_set --key=enable_userdeletion --value=$enable_userdeletion +ynh_app_setting_set --key=maxavatarsize --value=$maxavatarsize +ynh_app_setting_set --key=maxitemsperpage --value=$maxitemsperpage #================================================= # INSTALL Vikunja #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" @@ -52,40 +46,39 @@ executable="$(find $install_dir -name "vikunja-*" \! -name "*.sha256")" mv "$executable" "$install_dir/vikunja" chmod +x "$install_dir/vikunja" -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." -ynh_add_config --template="config.yml" --destination="$install_dir/config.yml" +ynh_config_add --template="config.yml" --destination="$install_dir/config.yml" -chmod 400 "$install_dir/config.yml" -chown "$app:$app" "$install_dir/config.yml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config.yml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/config.yml" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." -ynh_add_nginx_config +ynh_config_add_nginx -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add $app --description="Self-hosted To-Do list application" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app's systemd service..." --weight=2 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action=start --log_path=systemd #--line_match="server started on" +ynh_systemctl --service="$app" --action=start --log_path=systemd #--wait_until="server started on" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index e63c3ec..e518524 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -14,25 +8,25 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null +if ynh_hide_warnings yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service..." --weight=1 + ynh_script_progression "Removing $app service..." yunohost service remove $app fi # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd ynh_redis_remove_db "$redis_db" # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 72d6098..b25afff 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,58 +1,49 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring $app main directory..." --weight=4 +ynh_script_progression "Restoring $app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chmod -R o-rwx "$install_dir" -chown -R "$app:www-data" "$install_dir" +ynh_restore "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 +ynh_script_progression "Restoring the PostgreSQL database..." -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_db_shell < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable $app.service --quiet yunohost service add $app --description="Self-hosted To-Do list application" --log="/var/log/$app/$app.log" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="server started on" +ynh_systemctl --service=$app --action=start --log_path=systemd --wait_until="server started on" -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 7c5da08..122d28b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -20,117 +14,124 @@ redis_db=$(ynh_redis_get_free_db) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=set_motd --value="" if [ -z "${set_motd:-}" ]; then set_motd="" - ynh_app_setting_set --app="$app" --key="set_motd" --value="$set_motd" + ynh_app_setting_set --key="set_motd" --value="$set_motd" fi +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=enable_registration --value="true" if [ -z "${enable_registration:-}" ]; then enable_registration="true" - ynh_app_setting_set --app="$app" --key="enable_registration" --value="$enable_registration" + ynh_app_setting_set --key="enable_registration" --value="$enable_registration" fi +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=enable_linksharing --value="true" if [ -z "${enable_linksharing:-}" ]; then enable_linksharing="true" - ynh_app_setting_set --app="$app" --key="enable_linksharing" --value="$enable_linksharing" + ynh_app_setting_set --key="enable_linksharing" --value="$enable_linksharing" fi +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=enable_taskattachments --value="true" if [ -z "${enable_taskattachments:-}" ]; then enable_taskattachments="true" - ynh_app_setting_set --app="$app" --key="enable_taskattachments" --value="$enable_taskattachments" + ynh_app_setting_set --key="enable_taskattachments" --value="$enable_taskattachments" fi +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=enable_taskcomments --value="true" if [ -z "${enable_taskcomments:-}" ]; then enable_taskcomments="true" - ynh_app_setting_set --app="$app" --key="enable_taskcomments" --value="$enable_taskcomments" + ynh_app_setting_set --key="enable_taskcomments" --value="$enable_taskcomments" fi +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=enable_emailreminders --value="true" if [ -z "${enable_emailreminders:-}" ]; then enable_emailreminders="true" - ynh_app_setting_set --app="$app" --key="enable_emailreminders" --value="$enable_emailreminders" + ynh_app_setting_set --key="enable_emailreminders" --value="$enable_emailreminders" fi +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=enable_userdeletion --value="true" if [ -z "${enable_userdeletion:-}" ]; then enable_userdeletion="true" - ynh_app_setting_set --app="$app" --key="enable_userdeletion" --value="$enable_userdeletion" + ynh_app_setting_set --key="enable_userdeletion" --value="$enable_userdeletion" fi +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=maxavatarsize --value=1024 if [ -z "${maxavatarsize:-}" ]; then maxavatarsize=1024 - ynh_app_setting_set --app="$app" --key="maxavatarsize" --value="$maxavatarsize" + ynh_app_setting_set --key="maxavatarsize" --value="$maxavatarsize" fi +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=maxitemsperpage --value=50 if [ -z "${maxitemsperpage:-}" ]; then maxitemsperpage=50 - ynh_app_setting_set --app="$app" --key="maxitemsperpage" --value="$maxitemsperpage" + ynh_app_setting_set --key="maxitemsperpage" --value="$maxitemsperpage" fi +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=language --value="en" if [ -z "${language:-}" ]; then language="en" - ynh_app_setting_set --app="$app" --key="language" --value="$language" + ynh_app_setting_set --key="language" --value="$language" fi -if ynh_compare_current_package_version --comparison lt --version "0.23.0~ynh1"; then +if ynh_app_upgrading_from_version_before 0.23.0~ynh1; then mv "$backend_path/config.yml" "$install_dir/config.yml" - ynh_secure_remove "$backend_path" - ynh_app_setting_delete --app="$app" --key="backend_path" + ynh_safe_rm "$backend_path" + ynh_app_setting_delete --key="backend_path" fi -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action=stop --log_path=systemd +ynh_systemctl --service=$app --action=stop --log_path=systemd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=5 +ynh_script_progression "Upgrading source files..." -ynh_setup_source --dest_dir="$install_dir" --full_replace=1 +ynh_setup_source --dest_dir="$install_dir" --full_replace executable="$(find $install_dir -name "vikunja-*" \! -name "*.sha256")" mv "$executable" "$install_dir/vikunja" chmod +x "$install_dir/vikunja" -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating $app's configuration files..." --weight=1 +ynh_script_progression "Updating $app's configuration files..." -ynh_add_config --template="config.yml" --destination="$install_dir/config.yml" +ynh_config_add --template="config.yml" --destination="$install_dir/config.yml" -chmod 400 "$install_dir/config.yml" -chown $app:$app "$install_dir/config.yml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config.yml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config.yml" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." -ynh_add_nginx_config +ynh_config_add_nginx -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add $app --description="Self-hosted To-Do list application" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="server started on" +ynh_systemctl --service=$app --action=start --log_path=systemd --wait_until="server started on" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"