2021-03-29 16:24:15 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2023-02-24 20:00:57 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL NODEJS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installing nodejs..." --weight=10
|
2021-03-29 16:24:15 +02:00
|
|
|
|
2022-07-03 23:32:02 +02:00
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
|
|
|
|
|
|
#=================================================
|
2023-02-24 20:00:57 +01:00
|
|
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
2021-03-29 16:24:15 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2023-02-24 20:00:57 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=10
|
|
|
|
|
2022-07-03 23:32:02 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-02-24 20:00:57 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2022-01-03 17:54:48 +01:00
|
|
|
|
2023-02-24 20:00:57 +01:00
|
|
|
grep -v electron "$install_dir/package.json" > "$install_dir/server-package.json"
|
|
|
|
mv "$install_dir/server-package.json" "$install_dir/package.json"
|
2023-04-02 22:12:31 +02:00
|
|
|
|
2023-02-24 20:00:57 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2022-07-03 23:32:02 +02:00
|
|
|
|
2021-03-29 16:24:15 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
2021-03-31 19:55:10 +02:00
|
|
|
# INSTALL NODE PACKAGES
|
2021-03-29 16:24:15 +02:00
|
|
|
#=================================================
|
2021-03-31 19:55:10 +02:00
|
|
|
ynh_script_progression --message="Installing Node.js packages ..." --weight=45
|
|
|
|
|
2023-02-24 20:00:57 +01:00
|
|
|
pushd "$install_dir"
|
2022-07-03 23:32:02 +02:00
|
|
|
ynh_use_nodejs
|
2023-02-24 20:00:57 +01:00
|
|
|
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 rebuild ./
|
2022-07-03 23:32:02 +02:00
|
|
|
popd
|
2021-03-29 16:24:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
2023-02-24 20:00:57 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2021-03-29 16:24:15 +02:00
|
|
|
#=================================================
|
2023-03-04 00:05:08 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
2023-02-24 20:00:57 +01:00
|
|
|
|
|
|
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2022-07-03 23:32:02 +02:00
|
|
|
|
2023-02-24 20:00:57 +01:00
|
|
|
yunohost service add $app --description="Trilium Notes app" --log="systemd"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# APP INITIAL CONFIGURATION
|
2021-03-29 16:24:15 +02:00
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
2023-02-28 08:51:31 +01:00
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
2021-03-29 16:24:15 +02:00
|
|
|
|
2023-02-24 20:00:57 +01:00
|
|
|
ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
|
|
|
|
ln -sf $install_dir/config.ini $data_dir/config.ini
|
2021-03-29 16:24:15 +02:00
|
|
|
|
2023-02-24 20:00:57 +01:00
|
|
|
chmod 400 "$install_dir/config.ini"
|
|
|
|
chown $app:$app "$install_dir/config.ini"
|
2021-03-29 16:24:15 +02:00
|
|
|
|
2023-02-24 20:00:57 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
2021-03-29 16:24:15 +02:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2021-03-31 19:55:10 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2021-03-29 16:24:15 +02:00
|
|
|
|
2023-02-24 20:00:57 +01:00
|
|
|
# Start a systemd service
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
2021-03-29 16:24:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2023-02-24 20:00:57 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|