1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/syncthing_ynh.git synced 2024-09-03 20:26:23 +02:00
syncthing_ynh/scripts/install
Éric Gaspar 10054ee94e cleaning
2023-11-12 12:25:17 +01:00

74 lines
2.6 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
yunohost service add $app --description="Continuous File Synchronization" --needs_exposed_ports=$port
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
mkdir -p "$install_dir/.config/syncthing"
config_file="$install_dir/.config/syncthing/config.xml"
ynh_add_config --template="../conf/config.xml" --destination="$config_file"
chmod 400 "$config_file"
chown $app:$app "$config_file"
#=================================================
# FIX LISTENING SERVICE
#=================================================
ynh_script_progression --message="Fixing listening service..."
chown -R $app: $install_dir
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL"
ynh_replace_string --match_string="<listenAddress>tcp://quic:%2F%2F0.0.0.0:$port</listenAddress>" --replace_string="<listenAddress>quic//0.0.0.0:$port</listenAddress>" --target_file="$config_file"
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
ynh_store_file_checksum --file="$config_file"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed"