2021-04-06 13:20:29 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2023-09-21 14:28:37 +02:00
|
|
|
ynh_script_progression --message="Installing dependencies..."
|
2021-04-06 13:20:29 +02:00
|
|
|
|
|
|
|
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..."
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-09-21 14:16:44 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2021-04-06 13:20:29 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2022-02-05 11:16:18 +01:00
|
|
|
ynh_script_progression --message="Configuring NGINX web server..."
|
2021-04-06 13:20:29 +02:00
|
|
|
|
2022-02-05 11:16:18 +01:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2021-04-06 13:20:29 +02:00
|
|
|
|
2023-09-21 14:28:37 +02:00
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
|
|
|
yunohost service add $app --description="The news reader that doesn't know you"
|
|
|
|
|
2021-04-06 13:20:29 +02:00
|
|
|
#=================================================
|
2022-02-05 11:16:18 +01:00
|
|
|
# SPECIFIC SETUP
|
2021-04-06 13:20:29 +02:00
|
|
|
#=================================================
|
2021-04-06 15:48:32 +02:00
|
|
|
# INSTALL PETROLETTE
|
2021-04-06 13:20:29 +02:00
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installing application using node..."
|
|
|
|
|
2023-09-21 14:16:44 +02:00
|
|
|
pushd $install_dir
|
2021-06-23 16:35:45 +02:00
|
|
|
# set port in configuration file
|
|
|
|
sed -i "/HTTP_PORT/s/[0-9]*[0-9]/$port/" package.json
|
2023-09-21 14:40:21 +02:00
|
|
|
sed -i "/HTTPS_PORT/s/[0-9]*[0-9]/$port_https/" package.json
|
2022-02-05 11:16:18 +01:00
|
|
|
# use custom home value to avoid bower storing values in root and have right errors
|
2022-11-17 23:19:45 +01:00
|
|
|
if [ $mono_user -eq 1 ] ; then
|
|
|
|
ynh_add_config --template="petrolette.config.json" --destination="petrolette.config.json"
|
|
|
|
fi
|
2023-09-21 14:16:44 +02:00
|
|
|
if [ "$path" != "/" ] ; then
|
2022-11-17 23:19:45 +01:00
|
|
|
sed -i "s|\$.get(\"/feed\", {|\$.get(\"feed\", {|" public/js/PTL.feed.js
|
|
|
|
fi
|
2021-04-20 08:55:38 +02:00
|
|
|
[[ -v HOME ]] && TMP_HOME=$HOME
|
2021-04-12 19:37:18 +02:00
|
|
|
HOME=$(pwd)
|
2021-04-06 13:20:29 +02:00
|
|
|
ynh_use_nodejs
|
2023-09-21 15:55:45 +02:00
|
|
|
ynh_exec_warn_less $ynh_npm install --ignore-scripts
|
2021-04-20 08:55:38 +02:00
|
|
|
[[ -v TMP_HOME ]] && HOME=$TMP_HOME || unset HOME
|
2021-04-06 13:20:29 +02:00
|
|
|
popd
|
|
|
|
|
2023-09-21 14:16:44 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:$app "$install_dir"
|
2021-04-06 13:20:29 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
|
|
|
|
|
|
|
# Start a systemd service
|
2022-11-17 23:19:45 +01:00
|
|
|
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Pétrolette HTTP Server running on port"
|
2021-04-06 13:20:29 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed"
|