2018-11-21 16:11:09 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2020-05-21 12:49:24 +02:00
|
|
|
source _common.sh
|
2018-11-21 16:11:09 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2020-05-21 12:49:24 +02:00
|
|
|
# INSTALL DEPENDENCIES
|
2020-06-13 16:12:37 +02:00
|
|
|
#=================================================
|
2020-05-21 12:49:24 +02:00
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=20
|
2019-03-13 16:48:29 +01:00
|
|
|
|
2020-05-21 12:49:24 +02:00
|
|
|
# Install Nodejs
|
2020-05-29 22:31:43 +02:00
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
2018-11-21 16:35:21 +01:00
|
|
|
|
2018-11-21 19:24:30 +01:00
|
|
|
#=================================================
|
2019-03-13 16:48:29 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2018-11-21 19:24:30 +01:00
|
|
|
#=================================================
|
2020-05-21 12:49:24 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=2
|
2018-11-21 19:24:30 +01:00
|
|
|
|
2019-03-13 16:48:29 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-04-27 18:37:24 +02:00
|
|
|
ynh_setup_source --dest_dir=$install_dir
|
2020-05-21 12:49:24 +02:00
|
|
|
|
2023-04-27 18:37:24 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
chmod +x $install_dir/app.js
|
2021-06-13 10:41:28 +02:00
|
|
|
|
2020-05-21 12:49:24 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2020-10-12 22:05:07 +02:00
|
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
|
2020-05-21 12:49:24 +02:00
|
|
|
|
2020-10-12 22:05:07 +02:00
|
|
|
# Create a dedicated NGINX config
|
2020-05-21 12:49:24 +02:00
|
|
|
ynh_add_nginx_config
|
2018-11-21 16:11:09 +01:00
|
|
|
|
2020-06-13 16:12:37 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
2023-04-27 18:37:24 +02:00
|
|
|
#=================================================
|
2020-06-13 16:12:37 +02:00
|
|
|
# INSTALL CODIMD
|
2023-04-27 18:37:24 +02:00
|
|
|
#=================================================
|
2020-12-14 10:15:40 +01:00
|
|
|
ynh_script_progression --message="Building CodiMD... (this will take some time and resources!)" --weight=24
|
2020-06-13 16:12:37 +02:00
|
|
|
|
2023-04-27 18:37:24 +02:00
|
|
|
pushd $install_dir
|
2020-06-13 16:12:37 +02:00
|
|
|
ynh_use_nodejs
|
2022-07-12 09:55:00 +02:00
|
|
|
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH bin/setup
|
|
|
|
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run build
|
2021-06-13 11:14:42 +02:00
|
|
|
popd
|
2020-06-13 16:12:37 +02:00
|
|
|
|
2018-11-21 16:11:09 +01:00
|
|
|
#=================================================
|
2022-02-05 08:22:52 +01:00
|
|
|
# ADD A CONFIGURATION
|
2018-11-21 16:11:09 +01:00
|
|
|
#=================================================
|
2022-03-08 11:45:16 +01:00
|
|
|
ynh_script_progression --message="Modifying a config file..." --weight=1
|
2018-11-21 16:11:09 +01:00
|
|
|
|
2023-04-27 18:37:24 +02:00
|
|
|
ynh_add_config --template="../conf/config.json.example" --destination="$install_dir/config.json"
|
|
|
|
ynh_add_config --template="../conf/.sequelizerc.example" --destination="$install_dir/.sequelizerc"
|
2020-04-27 01:08:36 +02:00
|
|
|
|
2023-04-27 18:37:24 +02:00
|
|
|
chmod 600 $install_dir/config.json
|
|
|
|
chmod 600 $install_dir/.sequelizerc
|
2021-06-13 10:11:00 +02:00
|
|
|
|
2021-05-08 15:31:11 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
|
|
|
|
2022-02-05 08:22:52 +01:00
|
|
|
# Create a dedicated systemd config
|
2021-05-08 15:31:11 +02:00
|
|
|
ynh_add_systemd_config
|
|
|
|
|
2019-03-13 16:46:11 +01:00
|
|
|
#=================================================
|
2020-06-13 16:12:37 +02:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2018-11-21 16:11:09 +01:00
|
|
|
#=================================================
|
2022-03-08 11:45:16 +01:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
2018-11-21 16:11:09 +01:00
|
|
|
|
2020-12-04 09:52:22 +01:00
|
|
|
yunohost service add $app --description="Collaborative Markdown notes" --log="/var/log/$app/$app.log"
|
2018-11-21 16:11:09 +01:00
|
|
|
|
|
|
|
#=================================================
|
2019-11-28 02:05:34 +01:00
|
|
|
# START SYSTEMD SERVICE
|
2018-11-21 16:11:09 +01:00
|
|
|
#=================================================
|
2020-06-13 16:12:37 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
2019-03-13 16:48:29 +01:00
|
|
|
|
2020-06-13 16:12:37 +02:00
|
|
|
# Start a systemd service
|
2021-05-08 12:13:28 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="HTTP Server listening"
|
2018-11-21 16:11:09 +01:00
|
|
|
|
2019-11-28 02:05:34 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-02-05 08:22:52 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|