1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nodered_ynh.git synced 2024-09-03 19:46:25 +02:00
nodered_ynh/scripts/install

88 lines
3 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Installing NodeJS..."
ynh_install_nodejs --nodejs_version="$nodejs_version"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=2
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# SPECIFIC SETUP
#=================================================
# Install through npm
#=================================================
ynh_script_progression --message="Installing Node-RED..." --weight=5
ynh_use_nodejs
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
popd
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
# Set up the settings file
mkdir -p "$install_dir/data"
ynh_add_config --template="settings.js" --destination="$install_dir/data/settings.js"
ynh_add_config --template="settings.user.js" --destination="$install_dir/data/settings.user.js"
# Small hack to have the "/" path answer with a 200 code to satisfy the CI
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then
ynh_add_config --template="flows.json" --destination="$install_dir/data/flows.json"
fi
chmod 400 "$install_dir/data/settings.js"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding 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="Low-code programming for event-driven applications"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last