diff --git a/.gitignore b/.gitignore index 783a4ae..8f144f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store diff --git a/manifest.toml b/manifest.toml index 1c27c41..c7c2ce4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -20,7 +20,8 @@ code = "https://github.com/opensearch-project/OpenSearch" cpe = "cpe:2.3:a:amazon:opensearch" [integration] -yunohost = ">= 11.2.20" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = ["amd64", "arm64"] multi_instance = true ldap = "not_relevant" 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 83eba4d..23e6be2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -8,37 +8,34 @@ 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" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$data_dir" --is_big +ynh_backup "$data_dir" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" if [ "${container:-}" != "lxc" ]; then # lxc doesn't allow sysctl to play with kernel options. - ynh_backup --src_path="/etc/sysctl.d/90-max_map_count-opensearch.conf" + ynh_backup "/etc/sysctl.d/90-max_map_count-opensearch.conf" fi -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app.service" #================================================= # 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/config b/scripts/config index 6dbaf67..f4bad92 100644 --- a/scripts/config +++ b/scripts/config @@ -8,15 +8,9 @@ # (validation of several interdependent fields, specific getter/setter for a value, # display dynamic informations or choices, pre-loading of config type .cube... ). -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source /usr/share/yunohost/helpers -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS @@ -29,11 +23,11 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= get__xms() { - ynh_app_setting_get --app=$app --key=xms + ynh_app_setting_get --key=xms } get__xmx() { - ynh_app_setting_get --app=$app --key=xmx + ynh_app_setting_get --key=xmx } #================================================= @@ -45,22 +39,20 @@ get__xmx() { #================================================= regenerate_jvm_options() { - ynh_add_config --template="jvm.options" --destination="$final_path/config/jvm.options.d/yunohost.options" + ynh_config_add --template="jvm.options" --destination="$final_path/config/jvm.options.d/yunohost.options" chown $app:$app "$final_path/config/jvm.options.d/yunohost.options" chmod 400 "$final_path/config/jvm.options.d/yunohost.options" } set__xms() { - ynh_app_setting_set --app=$app --key=xms --value=$xms + ynh_app_setting_set --key=xms --value=$xms regenerate_jvm_options } set__xmx() { - ynh_app_setting_set --app=$app --key=xmx --value=$xmx + ynh_app_setting_set --key=xmx --value=$xmx regenerate_jvm_options } -#================================================= -# GENERIC FINALIZATION #================================================= ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index 77f4389..43a618b 100755 --- a/scripts/install +++ b/scripts/install @@ -12,44 +12,43 @@ source /usr/share/yunohost/helpers #================================================= xms=256m -ynh_app_setting_set --app="$app" --key="xms" --value="$xms" +ynh_app_setting_set --key="xms" --value="$xms" xmx=1g -ynh_app_setting_set --app="$app" --key="xmx" --value="$xmx" +ynh_app_setting_set --key="xmx" --value="$xmx" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=15 +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" -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$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:$app" "$install_dir" chmod -R o-rwx "$data_dir" chown -R "$app:www-data" "$data_dir" #================================================= # ADD CONFIGURATIONS #================================================= -ynh_script_progression --message="Adding $app's configuration files..." --weight=1 +ynh_script_progression "Adding $app's configuration files..." -ynh_add_config --template="opensearch.yml" --destination="$install_dir/config/opensearch.yml" -ynh_add_config --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options" +ynh_config_add --template="opensearch.yml" --destination="$install_dir/config/opensearch.yml" +ynh_config_add --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options" -chmod 400 "$install_dir/config/opensearch.yml" "$install_dir/config/jvm.options.d/yunohost.options" -chown "$app:$app" "$install_dir/config/opensearch.yml" "$install_dir/config/jvm.options.d/yunohost.options" +#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/opensearch.yml" "$install_dir/config/jvm.options.d/yunohost.options" +#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/opensearch.yml" "$install_dir/config/jvm.options.d/yunohost.options" #================================================= # INCREASE MAX_MAP_COUNT #================================================= -ynh_script_progression --message="Increasing maximum map count (sysctl)..." +ynh_script_progression "Increasing maximum map count (sysctl)..." if [ "${container:-}" != "lxc" ]; then # lxc doesn't allow sysctl to play with kernel options. # Increase the maximum number of files inotify can monitor. - ynh_add_config --template="90-max_map_count-opensearch.conf" --destination="/etc/sysctl.d/" + ynh_config_add --template="90-max_map_count-opensearch.conf" --destination="/etc/sysctl.d/" # Then, reload the kernel configuration. sysctl -p /etc/sysctl.d/90-max_map_count-opensearch.conf @@ -58,25 +57,25 @@ fi #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add "$app" --description="OpenSearch - Open source distributed and RESTful search engine" --log="/var/log/$app/$app.log" # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app's 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="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="start" #================================================= # 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 66ce61b..1432baf 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,26 +10,26 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -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; then +if ynh_hide_warnings yunohost service status "$app" >/dev/null; then yunohost service remove "$app" fi # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression "Removing various files..." if [ -e "/etc/sysctl.d/90-max_map_count-opensearch.conf" ]; then - ynh_secure_remove --file="/etc/sysctl.d/90-max_map_count-opensearch.conf" + ynh_safe_rm "/etc/sysctl.d/90-max_map_count-opensearch.conf" # Reload the kernel configuration. if ! [ "${container:-}" = "lxc" ]; then # lxc doesn't allow sysctl to play with kernel options. sysctl --system @@ -40,4 +40,4 @@ fi # 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 8060058..2d1dede 100755 --- a/scripts/restore +++ b/scripts/restore @@ -11,19 +11,18 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the 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 DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" chmod -R o-rwx "$data_dir" chown -R "$app:www-data" "$data_dir" @@ -31,33 +30,33 @@ chown -R "$app:www-data" "$data_dir" #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." +ynh_script_progression "Restoring various files..." if [ "${container:-}" != "lxc" ]; then # lxc doesn't allow sysctl to play with kernel options. - ynh_restore_file --origin_path="/etc/sysctl.d/90-max_map_count-opensearch.conf" + ynh_restore "/etc/sysctl.d/90-max_map_count-opensearch.conf" sysctl -p /etc/sysctl.d/90-max_map_count-opensearch.conf fi #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -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/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet yunohost service add "$app" --description="OpenSearch - Open source distributed and RESTful search engine" --log="/var/log/$app/$app.log" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" #================================================= # 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="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="start" #================================================= # 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 0919e4c..ac97df0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,40 +10,39 @@ source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="stop" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=20 +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config/opensearch.yml config/jvm.options.d/yunohost.conf" - -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$install_dir" +ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="config/opensearch.yml config/jvm.options.d/yunohost.conf" +#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:$app" "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression "Updating configuration..." -ynh_add_config --template="opensearch.yml" --destination="$install_dir/config/opensearch.yml" -ynh_add_config --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options" +ynh_config_add --template="opensearch.yml" --destination="$install_dir/config/opensearch.yml" +ynh_config_add --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options" -chmod 400 "$install_dir/config/opensearch.yml" "$install_dir/config/jvm.options.d/yunohost.options" -chown "$app:$app" "$install_dir/config/opensearch.yml" "$install_dir/config/jvm.options.d/yunohost.options" +#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/opensearch.yml" "$install_dir/config/jvm.options.d/yunohost.options" +#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/opensearch.yml" "$install_dir/config/jvm.options.d/yunohost.options" #================================================= # INCREASE MAX_MAP_COUNT #================================================= -ynh_script_progression --message="Increasing maximum map count (sysctl)..." +ynh_script_progression "Increasing maximum map count (sysctl)..." if [ "${container:-}" != "lxc" ]; then # lxc doesn't allow sysctl to play with kernel options. # Increase the maximum number of files inotify can monitor. - ynh_add_config --template="90-max_map_count-opensearch.conf" --destination="/etc/sysctl.d/" + ynh_config_add --template="90-max_map_count-opensearch.conf" --destination="/etc/sysctl.d/" # Then, reload the kernel configuration. sysctl -p /etc/sysctl.d/90-max_map_count-opensearch.conf @@ -52,24 +51,24 @@ fi #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add "$app" --description="OpenSearch - Open source distributed and RESTful search engine" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate #================================================= # 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="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"