2020-09-29 16:25:50 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
# INSTALL NODEJS
|
2020-09-29 16:25:50 +02:00
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_script_progression --message="Installing NodeJS..." --weight=20
|
2020-09-29 16:25:50 +02:00
|
|
|
|
|
|
|
# Install Nodejs
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
2021-05-27 13:24:40 +02:00
|
|
|
|
2020-09-29 16:25:50 +02:00
|
|
|
#=================================================
|
|
|
|
# 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
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir/source"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2022-06-16 03:06:21 +02:00
|
|
|
#=================================================
|
|
|
|
# BUILD APP
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=20
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
pushd "$install_dir/source"
|
|
|
|
ynh_use_nodejs
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install gulp -g
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build
|
2021-11-21 19:43:21 +01:00
|
|
|
popd
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_exec_as "$app" mv "$install_dir/source/dist" "$install_dir/live"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_secure_remove --file="$install_dir/source"
|
2022-06-16 03:06:21 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-16 04:10:16 +02:00
|
|
|
# ADD A CONFIGURATION
|
2020-09-29 16:25:50 +02:00
|
|
|
#=================================================
|
2022-06-16 04:10:16 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_add_config --template="config.example.js" --destination="$install_dir/live/config.js"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
chmod 400 "$install_dir/live/config.js"
|
|
|
|
chown "$app:$app" "$install_dir/live/config.js"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2020-09-29 16:25:50 +02:00
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2020-09-29 16:25:50 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-06-16 03:06:21 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|