2019-05-29 00:20:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2024-01-24 12:25:21 +01:00
|
|
|
# INSTALL NODEJS
|
2019-05-29 00:20:58 +02:00
|
|
|
#=================================================
|
2024-01-24 12:25:21 +01:00
|
|
|
ynh_script_progression --message="Installing NodeJS..."
|
2019-05-29 00:20:58 +02:00
|
|
|
|
2024-01-24 12:25:21 +01:00
|
|
|
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
2022-01-27 00:17:52 +01:00
|
|
|
|
2019-05-29 00:20:58 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2021-09-18 17:20:18 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=2
|
2019-05-29 00:20:58 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-01-24 12:25:21 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2019-05-29 00:20:58 +02:00
|
|
|
|
2024-01-24 12:25:21 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2019-10-13 19:50:59 +02:00
|
|
|
|
2022-01-27 00:17:52 +01:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
2019-05-29 00:20:58 +02:00
|
|
|
#=================================================
|
|
|
|
# Install through npm
|
|
|
|
#=================================================
|
2021-09-18 17:20:18 +02:00
|
|
|
ynh_script_progression --message="Installing Node-RED..." --weight=5
|
2019-05-29 00:20:58 +02:00
|
|
|
|
2021-05-25 10:41:05 +02:00
|
|
|
ynh_use_nodejs
|
|
|
|
|
2024-01-24 12:25:21 +01:00
|
|
|
pushd "$install_dir"
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install --production
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install node-red-dashboard
|
2019-05-29 00:20:58 +02:00
|
|
|
popd
|
|
|
|
|
|
|
|
#=================================================
|
2022-01-27 00:17:52 +01:00
|
|
|
# ADD A CONFIGURATION
|
2019-05-29 00:20:58 +02:00
|
|
|
#=================================================
|
2022-01-27 00:17:52 +01:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2021-05-23 15:45:29 +02:00
|
|
|
|
2021-05-24 15:26:59 +02:00
|
|
|
# Set up the settings file
|
2024-01-24 12:25:21 +01:00
|
|
|
mkdir -p "$install_dir/data"
|
|
|
|
ynh_add_config --template="../conf/settings.js" --destination="$install_dir/data/settings.js"
|
|
|
|
ynh_add_config --template="../conf/settings.user.js" --destination="$install_dir/data/settings.user.js"
|
2019-05-29 00:20:58 +02:00
|
|
|
|
2021-09-22 21:51:09 +02:00
|
|
|
# Small hack to have the "/" path answer with a 200 code to satisfy the CI
|
|
|
|
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then
|
2024-01-24 12:25:21 +01:00
|
|
|
ynh_add_config --template="../conf/flows.json" --destination="$install_dir/data/flows.json"
|
2021-09-22 21:51:09 +02:00
|
|
|
fi
|
|
|
|
|
2024-01-24 12:25:21 +01:00
|
|
|
chmod 400 "$install_dir/data/settings.js"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2021-07-24 13:51:38 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-24 12:25:21 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2019-05-29 00:20:58 +02:00
|
|
|
#=================================================
|
2024-01-24 12:25:21 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2019-05-29 00:20:58 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2024-01-24 12:25:21 +01:00
|
|
|
yunohost service add "$app" --description="Low-code programming for event-driven applications"
|
2019-05-29 00:20:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2021-09-18 17:20:18 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
2019-05-29 00:20:58 +02:00
|
|
|
|
|
|
|
# Start a systemd service
|
2024-01-24 12:25:21 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="start"
|
2019-05-29 00:20:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-01-27 00:17:52 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|