mirror of
https://github.com/YunoHost-Apps/peertube-search-index_ynh.git
synced 2024-09-03 19:56:30 +02:00
108 lines
3.6 KiB
Bash
108 lines
3.6 KiB
Bash
#!/bin/bash
|
||
|
||
#=================================================
|
||
# GENERIC START
|
||
#=================================================
|
||
# IMPORT GENERIC HELPERS
|
||
#=================================================
|
||
|
||
source _common.sh
|
||
source /usr/share/yunohost/helpers
|
||
|
||
#=================================================
|
||
# STOP SYSTEMD SERVICE
|
||
#=================================================
|
||
ynh_script_progression --message="Stopping $app's systemd service..."
|
||
|
||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --line_match="Stopped $app search index daemon"
|
||
|
||
#=================================================
|
||
# INSTALL NODEJS
|
||
#=================================================
|
||
ynh_script_progression --message="Updating NodeJS..."
|
||
|
||
ynh_install_nodejs --nodejs_version="$NODEJS_VERSION"
|
||
|
||
#=================================================
|
||
# START ELASTICSEARCH
|
||
#=================================================
|
||
ynh_script_progression --message="Starting elasticsearch..."
|
||
|
||
systemctl enable elasticsearch.service --quiet
|
||
systemctl start elasticsearch.service
|
||
|
||
#=================================================
|
||
# ENSURE DOWNWARD COMPATIBILITY
|
||
#=================================================
|
||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||
|
||
# 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"
|
||
fi
|
||
|
||
# Fix upgrade from 0.0.1.2022.06.03~ynh1
|
||
chmod 750 "$install_dir"
|
||
chmod -R o-rwx "$install_dir"
|
||
chown -R "$app:$app" "$install_dir"
|
||
|
||
#=================================================
|
||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||
#=================================================
|
||
ynh_script_progression --message="Upgrading source files..."
|
||
|
||
_git_clone_or_pull "$install_dir/sources"
|
||
chmod -R o-rwx "$install_dir"
|
||
chown -R "$app:$app" "$install_dir"
|
||
|
||
#=================================================
|
||
# BUILDING
|
||
#=================================================
|
||
ynh_script_progression --message="Building..."
|
||
|
||
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
|
||
popd
|
||
|
||
#=================================================
|
||
# UPDATE A CONFIG FILE
|
||
#=================================================
|
||
ynh_script_progression --message="Updating a config file..."
|
||
|
||
ynh_add_config --template="default.yaml" --destination="$install_dir/config/production.yaml"
|
||
|
||
chmod 400 "$install_dir/config/production.yaml"
|
||
chown "$app:$app" "$install_dir/config/production.yaml"
|
||
|
||
#=================================================
|
||
# REAPPLY SYSTEM CONFIGURATIONS
|
||
#=================================================
|
||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||
|
||
# Create a dedicated NGINX config
|
||
ynh_add_nginx_config
|
||
|
||
# Create a dedicated systemd config
|
||
ynh_add_systemd_config
|
||
yunohost service add "$app" --description="$app search index daemon"
|
||
|
||
# Use logrotate to manage app-specific logfile(s)
|
||
ynh_use_logrotate --non-append
|
||
|
||
#=================================================
|
||
# START SYSTEMD SERVICE
|
||
#=================================================
|
||
ynh_script_progression --message="Starting $app's systemd service..."
|
||
|
||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on port"
|
||
|
||
#=================================================
|
||
# END OF SCRIPT
|
||
#=================================================
|
||
|
||
ynh_script_progression --message="Upgrade of $app completed"
|