peertube-search-index_ynh/scripts/install

86 lines
2.8 KiB
Text
Raw Normal View History

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
# INSTALL NODEJS
2020-10-31 14:18:46 +01:00
#=================================================
2024-02-28 12:03:57 +01:00
ynh_script_progression --message="Installing 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
systemctl enable elasticsearch.service --quiet
2020-11-01 11:56:46 +01:00
systemctl start elasticsearch.service
2021-04-09 23:48:21 +02:00
2020-10-31 14:18:46 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
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"
2021-04-09 23:48:21 +02:00
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
# ADD A CONFIGURATION
2020-10-31 14:18:46 +01:00
#=================================================
2021-04-09 23:48:21 +02:00
ynh_script_progression --message="Adding 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
# SYSTEM CONFIGURATION
2021-04-11 20:47:47 +02:00
#=================================================
2024-02-28 12:03:57 +01:00
ynh_script_progression --message="Adding 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 application logfile(s)
ynh_use_logrotate
#=================================================
# 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
# Start a systemd service
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="Installation of $app completed"