#!/bin/bash

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression "Stopping $app's systemd service..."

ynh_systemctl --service=$app --action="stop"

#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression "Upgrading system configurations related to $app..."

ynh_config_add_nginx

ynh_config_add_systemd

yunohost service add $app --description="Automated video capture and distribution" --log="/var/log/$app/$app.log"

#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression "Updating configuration..."

ynh_config_add --template="custom.properties" --destination="/etc/opencast/custom.properties"

#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."

ynh_systemctl --service=$app --action="start"

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression "Upgrade of $app completed"
