1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/facilmap_ynh.git synced 2024-09-03 18:36:07 +02:00
facilmap_ynh/scripts/install
2024-07-05 15:47:51 +02:00

90 lines
3.1 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing NodeJS..." --weight=6
ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_setup_source --dest_dir="$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Configuring a MySQL database..." --weight=2
ynh_mysql_execute_as_root --database="$db_name" --sql="ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
#=================================================
# SPECIFIC SETUP
#=================================================
# BUILD NODE DEPENDENCIES
#=================================================
ynh_script_progression --message="Building $app..." --weight=10
pushd "$install_dir"
ynh_use_nodejs
ynh_exec_warn_less env $ynh_node_load_PATH yarn install
ynh_exec_warn_less env $ynh_node_load_PATH yarn build:frontend:app
ynh_exec_warn_less env $ynh_node_load_PATH yarn build:server
popd
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding configuration..." --weight=2
ynh_add_config --template="config.env" --destination="$install_dir/config.env"
chown -R "$app:www-data" "$install_dir/config.env"
chmod 400 "$install_dir/config.env"
#=================================================
# 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="Collaborative maps and routing" --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=7
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server started"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last