2021-06-09 22:55:44 +02:00
#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-08-31 01:01:39 +02:00
ynh_script_progression "Setting up source files..."
2021-06-09 22:55:44 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2024-08-31 01:01:39 +02:00
ynh_setup_source --dest_dir="$install_dir"
2023-03-23 23:29:06 +01:00
2024-08-31 01:01:39 +02:00
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir"
2021-06-09 22:55:44 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2024-08-31 01:01:39 +02:00
ynh_script_progression "Configuring NGINX web server..."
2021-06-09 22:55:44 +02:00
# Create a dedicated NGINX config
2024-08-31 01:01:39 +02:00
ynh_config_add_nginx
2021-06-09 22:55:44 +02:00
#=================================================
# SPECIFIC SETUP
#=================================================
# SETUP SYSTEMD
#=================================================
2024-08-31 01:01:39 +02:00
ynh_script_progression "Configuring $app's systemd service..."
2021-06-09 22:55:44 +02:00
# Create a dedicated systemd config
2024-08-31 01:01:39 +02:00
ynh_config_add_systemd
2021-06-09 22:55:44 +02:00
#=================================================
# ADD A CONFIGURATION
#=================================================
2024-08-31 01:01:39 +02:00
ynh_script_progression "Configuring Lidarr..."
2021-06-09 22:55:44 +02:00
api_key=$(ynh_string_random --length=32)
2024-08-31 01:01:39 +02:00
ynh_app_setting_set --key=api_key --value=$api_key
2021-06-09 22:55:44 +02:00
2024-08-31 01:01:39 +02:00
ynh_config_add --template="config.xml" --destination="$data_dir/config.xml"
2021-06-09 22:55:44 +02:00
2024-08-31 01:01:39 +02:00
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$data_dir/config.xml"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$data_dir/config.xml"
2023-03-21 19:25:27 +01:00
2021-06-13 13:28:06 +02:00
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
2024-08-31 01:01:39 +02:00
ynh_script_progression "Adding multimedia directories..."
2021-06-13 13:28:06 +02:00
# Build YunoHost multimedia directories
ynh_multimedia_build_main_dir
# Enable writing into these directories
ynh_multimedia_addaccess $app
2021-06-09 22:55:44 +02:00
#=================================================
# SETUP LOGROTATE
#=================================================
2024-08-31 01:01:39 +02:00
ynh_script_progression "Configuring log rotation..."
2021-06-09 22:55:44 +02:00
# Use logrotate to manage application logfile(s)
2024-08-31 01:01:39 +02:00
ynh_config_add_logrotate "$data_dir/logs"
2021-06-09 22:55:44 +02:00
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
2024-08-31 01:01:39 +02:00
ynh_script_progression "Integrating service in YunoHost..."
2021-06-09 22:55:44 +02:00
2023-03-23 23:22:09 +01:00
yunohost service add $app --description="Lidarr daemon" --log="$data_dir/logs/lidarr.txt"
2021-06-09 22:55:44 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2024-08-31 01:01:39 +02:00
ynh_script_progression "Starting $app's systemd service..."
2021-06-09 22:55:44 +02:00
# Start a systemd service
2024-08-31 01:01:39 +02:00
ynh_systemctl --service=$app --action="start" --log_path="systemd" --wait_until="Application started"
2021-06-09 22:55:44 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2024-08-31 01:01:39 +02:00
ynh_script_progression "Installation of $app completed"