#!/bin/bash

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

email=$(ynh_user_get_info --username=$admin --key=mail)

#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Adding 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"

chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"

#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression "Adding $app's 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" --log_path="systemd"

#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"
