1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/trilium_ynh.git synced 2024-10-01 13:34:49 +02:00
trilium_ynh/scripts/install

113 lines
3.9 KiB
Text
Raw Normal View History

2021-03-29 16:24:15 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
# Install parameters are automatically saved as settings
#
# Settings are automatically loaded as bash variables
# in every app script context, therefore typically these will exist:
# - $domain
# - $path
# - $language
# ... etc
#
# Resources defined in the manifest are provisioned prior to this script
# and corresponding settings are also available, such as:
# - $install_dir
# - $port
# - $db_name
# ...
#
# $app is the app id (i.e. 'example' for first install,
# or 'example__2', '__3', ... for multi-instance installs)
#
#=================================================
# 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
#=================================================
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
2021-03-29 16:24:15 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
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
ynh_setup_source --dest_dir="$install_dir"
2022-01-03 17:54:48 +01:00
grep -v electron "$install_dir/package.json" > "$install_dir/server-package.json"
mv "$install_dir/server-package.json" "$install_dir/package.json"
# $install_dir will automatically be initialized with some decent
# permission by default ... however, you may need to recursively reapply
# ownership to all files such as after the ynh_setup_source step
chmod 750 "$install_dir"
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
pushd "$install_dir"
2022-07-03 23:32:02 +02:00
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 rebuild ./
2022-07-03 23:32:02 +02:00
popd
2021-03-29 16:24:15 +02:00
#=================================================
# SYSTEM CONFIGURATION
2021-03-29 16:24:15 +02:00
#=================================================
ynh_script_progression --message="Adding system configurations related to $app ..." --weight=1
# 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
yunohost service add $app --description="Trilium Notes app" --log="systemd"
#=================================================
# APP INITIAL CONFIGURATION
2021-03-29 16:24:15 +02:00
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
2021-03-29 16:24:15 +02:00
### You can add specific configuration files.
2022-07-03 23:32:02 +02: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
chmod 400 "$install_dir/config.ini"
chown $app:$app "$install_dir/config.ini"
2021-03-29 16:24:15 +02: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
# 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
#=================================================
ynh_script_progression --message="Installation of $app completed" --last