2020-10-31 14:18:46 +01:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
|
# GENERIC START
|
|
|
|
|
#=================================================
|
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
# STOP SYSTEMD SERVICE
|
2020-10-31 14:18:46 +01:00
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_script_progression --message="Stopping $app's systemd service..."
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --line_match="Stopped $app search index daemon"
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
# INSTALL NODEJS
|
2020-10-31 14:18:46 +01:00
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_script_progression --message="Updating NodeJS..."
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_install_nodejs --nodejs_version="$NODEJS_VERSION"
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
# START ELASTICSEARCH
|
2020-10-31 14:18:46 +01:00
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_script_progression --message="Starting elasticsearch..."
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
2024-02-28 12:03:57 +01:00
|
|
|
|
systemctl enable elasticsearch.service --quiet
|
|
|
|
|
systemctl start elasticsearch.service
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
2022-01-07 04:00:37 +01:00
|
|
|
|
#=================================================
|
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
|
#=================================================
|
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
|
|
2024-02-28 12:03:57 +01:00
|
|
|
|
# Move git repository one step lower
|
|
|
|
|
if [ -d "$install_dir/.git" ]; then
|
|
|
|
|
mkdir "${install_dir}__tmp__"
|
|
|
|
|
mv "$install_dir" "${install_dir}__tmp__"
|
|
|
|
|
mv "${install_dir}__tmp__" "$install_dir"
|
2022-01-07 04:00:37 +01:00
|
|
|
|
fi
|
|
|
|
|
|
2023-08-08 22:31:05 +02:00
|
|
|
|
# Fix upgrade from 0.0.1.2022.06.03~ynh1
|
2024-02-28 12:03:57 +01:00
|
|
|
|
chmod 750 "$install_dir"
|
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
|
chown -R "$app:$app" "$install_dir"
|
2021-04-09 23:48:21 +02:00
|
|
|
|
|
2020-10-31 14:18:46 +01:00
|
|
|
|
#=================================================
|
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_script_progression --message="Upgrading source files..."
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
2024-02-28 12:03:57 +01:00
|
|
|
|
_git_clone_or_pull "$install_dir/sources"
|
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
|
chown -R "$app:$app" "$install_dir"
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
|
|
|
|
#=================================================
|
2022-11-14 21:27:17 +01:00
|
|
|
|
# BUILDING
|
2020-10-31 14:18:46 +01:00
|
|
|
|
#=================================================
|
|
|
|
|
ynh_script_progression --message="Building..."
|
|
|
|
|
|
2024-02-28 12:03:57 +01:00
|
|
|
|
pushd "$install_dir"
|
|
|
|
|
ynh_use_nodejs
|
|
|
|
|
ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn install --pure-lockfile
|
|
|
|
|
ynh_exec_as "$app" mkdir -p "$install_dir/dist"
|
|
|
|
|
ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run build
|
2020-10-31 14:18:46 +01:00
|
|
|
|
popd
|
|
|
|
|
|
|
|
|
|
#=================================================
|
2021-04-09 23:48:21 +02:00
|
|
|
|
# UPDATE A CONFIG FILE
|
2020-10-31 14:18:46 +01:00
|
|
|
|
#=================================================
|
2021-04-09 23:48:21 +02:00
|
|
|
|
ynh_script_progression --message="Updating a config file..."
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_add_config --template="default.yaml" --destination="$install_dir/config/production.yaml"
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
2024-02-28 12:03:57 +01:00
|
|
|
|
chmod 400 "$install_dir/config/production.yaml"
|
|
|
|
|
chown "$app:$app" "$install_dir/config/production.yaml"
|
2021-04-09 23:48:21 +02:00
|
|
|
|
|
2021-04-11 20:47:47 +02:00
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2021-04-11 20:47:47 +02:00
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
|
ynh_add_nginx_config
|
2021-04-11 20:47:47 +02:00
|
|
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
2021-05-13 22:38:50 +02:00
|
|
|
|
ynh_add_systemd_config
|
2024-02-28 12:03:57 +01:00
|
|
|
|
yunohost service add "$app" --description="$app search index daemon"
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
|
#=================================================
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_script_progression --message="Starting $app's systemd service..."
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
2024-02-28 12:03:57 +01:00
|
|
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on port"
|
2020-10-31 14:18:46 +01:00
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
|
# END OF SCRIPT
|
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|