1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/turtl_ynh.git synced 2024-09-03 20:26:35 +02:00
turtl_ynh/scripts/install

90 lines
2.9 KiB
Text
Raw Normal View History

2017-07-28 12:35:26 +02:00
#!/bin/bash
2021-11-25 10:08:00 +01:00
#=================================================
# GENERIC START
2017-07-28 12:35:26 +02:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
2021-11-25 11:53:18 +01:00
hash=$(ynh_string_random --length=128)
2021-11-25 10:08:00 +01:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2023-12-09 20:50:53 +01:00
ynh_script_progression --message="Installing dependencies..." --weight=20
2017-07-28 12:35:26 +02:00
2021-11-25 10:08:00 +01:00
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
2017-07-28 12:35:26 +02:00
2021-11-25 10:08:00 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2021-11-25 11:53:18 +01:00
ynh_script_progression --message="Setting up source files..." --weight=3
2017-07-28 12:35:26 +02:00
2022-02-22 00:35:52 +01:00
# Download, check integrity, uncompress and patch the source from app.src
2023-12-09 20:44:45 +01:00
ynh_setup_source --dest_dir="$install_dir"
2021-11-25 10:08:00 +01:00
2023-12-09 20:44:45 +01:00
mkdir -p $install_dir/plugins
2021-11-25 12:39:30 +01:00
2023-12-09 20:44:45 +01:00
chmod 700 $install_dir/plugins
chown $app:$app $install_dir/plugins
2021-11-25 13:08:18 +01:00
2023-12-09 20:44:45 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2021-11-25 10:08:00 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2021-11-25 11:43:47 +01:00
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
2021-11-25 10:08:00 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2023-12-09 20:50:53 +01:00
# Create a dedicated systemd config
ynh_add_systemd_config
yunohost service add $app --description="Share notes, bookmarks, and documents"
2021-11-25 10:08:00 +01:00
#=================================================
# SPECIFIC SETUP
#=================================================
2022-02-22 00:35:52 +01:00
# BUILD TURTLE
2021-11-25 10:08:00 +01:00
#=================================================
2023-12-10 11:03:47 +01:00
ynh_script_progression --message="Building $app..." --weight=20
2021-11-25 10:08:00 +01:00
2023-12-09 20:44:45 +01:00
pushd $install_dir
2021-11-25 10:08:00 +01:00
ynh_use_nodejs
2023-12-09 20:50:53 +01:00
ynh_exec_as $app env $ynh_node_load_PATH npm install --unsafe-perm
2021-11-25 10:08:00 +01:00
popd
2017-07-28 12:35:26 +02:00
2021-11-25 10:08:00 +01:00
#=================================================
# ADD A CONFIGURATION
#=================================================
2021-11-25 11:43:47 +01:00
ynh_script_progression --message="Adding a configuration file..." --weight=1
2017-07-28 12:35:26 +02:00
2023-12-09 20:50:53 +01:00
ynh_add_config --template="config.yaml.default" --destination="$install_dir/config/config.yaml"
2017-07-28 12:35:26 +02:00
2023-12-09 20:44:45 +01:00
chmod 400 "$install_dir/config/config.yaml"
chown $app:$app "$install_dir/config/config.yaml"
2017-07-28 12:35:26 +02:00
#=================================================
2021-11-25 10:08:00 +01:00
# START SYSTEMD SERVICE
2017-07-28 12:35:26 +02:00
#=================================================
2021-11-25 11:53:18 +01:00
ynh_script_progression --message="Starting a systemd service..." --weight=5
2021-11-25 10:08:00 +01:00
# Start a systemd service
2022-02-22 00:35:52 +01:00
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Listening for turtls on IP"
2017-07-28 12:35:26 +02:00
2021-11-25 10:08:00 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2021-11-25 11:43:47 +01:00
ynh_script_progression --message="Installation of $app completed" --last