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

83 lines
2.7 KiB
Text
Raw Normal View History

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
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
2021-04-06 13:20:29 +02: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
#=================================================
# 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
# 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
# use custom home value to avoid bower storing values in root and have right errors
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
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
HOME=$(pwd)
2023-09-21 16:29:43 +02:00
export NODE_ENV=production
2021-04-06 13:20:29 +02:00
ynh_use_nodejs
2023-09-21 17:40:07 +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
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"