2020-08-17 17:29:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=2
|
|
|
|
|
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=5
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-08-18 12:17:59 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
mkdir -p $install_dir/config
|
2022-06-02 00:45:50 +02:00
|
|
|
|
2023-08-18 12:17:59 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:$app "$install_dir"
|
2020-08-17 17:29:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
2022-06-02 00:45:50 +02:00
|
|
|
#=================================================
|
|
|
|
# BUILD APP
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=26
|
2020-08-17 17:29:58 +02:00
|
|
|
|
2023-08-18 12:17:59 +02:00
|
|
|
pushd "$install_dir"
|
2020-08-17 17:29:58 +02:00
|
|
|
ynh_use_nodejs
|
2022-06-02 00:45:50 +02:00
|
|
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install
|
2021-11-07 23:19:46 +01:00
|
|
|
popd
|
2020-08-17 17:29:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-02 00:45:50 +02:00
|
|
|
# ADD A CONFIGURATION
|
2020-08-17 17:29:58 +02:00
|
|
|
#=================================================
|
2022-06-02 00:45:50 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
2021-11-07 23:19:46 +01:00
|
|
|
|
2023-08-18 12:17:59 +02:00
|
|
|
ynh_add_config --template="../conf/config.json.example" --destination="$install_dir/config/config.json"
|
2020-08-17 17:29:58 +02:00
|
|
|
|
2023-08-18 12:17:59 +02:00
|
|
|
chmod 600 "$install_dir/config/config.json"
|
|
|
|
chown $app:$app "$install_dir/config/config.json"
|
2021-11-07 23:19:46 +01:00
|
|
|
|
2022-06-02 00:45:50 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
|
|
|
|
2023-08-18 12:17:59 +02:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2022-06-02 00:45:50 +02:00
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2021-11-07 23:19:46 +01:00
|
|
|
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate
|
2020-08-17 17:29:58 +02:00
|
|
|
|
2023-08-18 12:17:59 +02:00
|
|
|
yunohost service add $app --description="File storage server" --log="/var/log/$app/$app.log"
|
2020-08-17 17:29:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=40
|
|
|
|
|
|
|
|
# Start a systemd service
|
2021-04-17 19:35:31 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Ready for requests!"
|
2020-08-17 17:29:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|