Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*~
*.sw[op]
.DS_Store
3 changes: 2 additions & 1 deletion manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ admindoc = "https://www.elastic.co/guide/en/elasticsearch/reference/8.11/elastic
code = "https://github.com/elastic/elasticsearch"

[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64", "arm64"]
multi_instance = true

Expand Down
14 changes: 1 addition & 13 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
#!/bin/bash

#=================================================
# COMMON VARIABLES
#=================================================

#=================================================
# PERSONAL HELPERS
#=================================================

#=================================================
# EXPERIMENTAL HELPERS
#=================================================

#=================================================
# FUTURE OFFICIAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
23 changes: 7 additions & 16 deletions scripts/backup
Original file line number Diff line number Diff line change
@@ -1,54 +1,45 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
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"

#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================

ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"

#=================================================
# BACKUP VARIOUS FILES
#=================================================

ynh_backup --src_path="/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
ynh_backup "/etc/sysctl.d/90-max_map_count-elasticsearch.conf"

#=================================================
# BACKUP SYSTEMD
#=================================================

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)."
20 changes: 6 additions & 14 deletions scripts/config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

#=================================================
Expand All @@ -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
43 changes: 18 additions & 25 deletions scripts/install
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

Expand All @@ -16,35 +10,34 @@ source /usr/share/yunohost/helpers
xms=256m
xmx=1g

ynh_app_setting_set --app=$app --key=xms --value=$xms
ynh_app_setting_set --app=$app --key=xmx --value=$xmx
ynh_app_setting_set --key=xms --value=$xms
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"
ynh_setup_source --dest_dir="$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"
#=================================================
# ADD CONFIGURATIONS
#=================================================
ynh_script_progression --message="Adding the configuration files..." --weight=1
ynh_script_progression "Adding the configuration files..."

ynh_add_config --template="elasticsearch.yml" --destination="$install_dir/config/elasticsearch.yml"
ynh_add_config --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options"
ynh_config_add --template="elasticsearch.yml" --destination="$install_dir/config/elasticsearch.yml"
ynh_config_add --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options"

chmod 400 "$install_dir/config/elasticsearch.yml" "$install_dir/config/jvm.options.d/yunohost.options"
chown $app:$app "$install_dir/config/elasticsearch.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/elasticsearch.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/elasticsearch.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)..."

# Increase the maximum number of files inotify can monitor.
cp -a ../conf/90-max_map_count-elasticsearch.conf /etc/sysctl.d/
Expand All @@ -57,26 +50,26 @@ fi
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_script_progression "Configuring $app's systemd service..."

# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd

# Use logrotate to manage application logfile(s)
ynh_use_logrotate
ynh_config_add_logrotate

yunohost service add $app --description="Distributed and RESTful search engine" --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..."

# 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"
18 changes: 6 additions & 12 deletions scripts/remove
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

Expand All @@ -16,20 +10,20 @@ source /usr/share/yunohost/helpers
#=================================================

# 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 integration..." --weight=1
ynh_script_progression "Removing $app service integration..."
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

if [ -e "/etc/sysctl.d/90-max_map_count-elasticsearch.conf" ]; then
ynh_secure_remove --file="/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
ynh_safe_rm "/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
# Reload the kernel configuration.
if ! [ "${container:-}" = "lxc" ] # lxc doesn't allow sysctl to play with kernel options.
then
Expand All @@ -41,4 +35,4 @@ fi
# END OF SCRIPT
#=================================================

ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"
35 changes: 14 additions & 21 deletions scripts/restore
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1

ynh_restore_file --origin_path="$install_dir"
ynh_script_progression "Restoring the app main directory..."

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"

chown -R $app:www-data "$data_dir"

Expand All @@ -34,9 +27,9 @@ chown -R $app:www-data "$data_dir"
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_script_progression "Restoring various files..."

ynh_restore_file --origin_path="/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
ynh_restore "/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
if ! [ "${container:-}" = "lxc" ] # lxc doesn't allow sysctl to play with kernel options.
then
sysctl -p /etc/sysctl.d/90-max_map_count-elasticsearch.conf
Expand All @@ -45,24 +38,24 @@ fi
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_script_progression "Restoring $app's systemd service..."

ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet

ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"

yunohost service add $app --description="Distributed and RESTful search engine" --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="/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"
Loading