2017-11-04 22:45:12 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
path_url=$(ynh_app_setting_get "$app" path)
|
|
|
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
|
|
|
launch_on_boot=$(ynh_app_setting_get "$app" launch_on_boot)
|
|
|
|
open_webserver_port=$(ynh_app_setting_get "$app" open_webserver_port)
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GLOBAL VARS
|
|
|
|
#=================================================
|
|
|
|
arch=$(uname -m)
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
# Fix launch_on_boot as a boolean value
|
|
|
|
if [ "$launch_on_boot" = "Yes" ]; then
|
|
|
|
ynh_app_setting_set "$app" launch_on_boot 1
|
|
|
|
launch_on_boot=1
|
|
|
|
elif [ "$launch_on_boot" = "No" ]; then
|
|
|
|
ynh_app_setting_set "$app" launch_on_boot 0
|
|
|
|
launch_on_boot=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Fix launch_on_boot as a boolean value
|
|
|
|
if [ "$open_webserver_port" = "Yes" ]; then
|
|
|
|
ynh_app_setting_set "$app" open_webserver_port 1
|
|
|
|
open_webserver_port=1
|
|
|
|
elif [ "$open_webserver_port" = "No" ]; then
|
|
|
|
ynh_app_setting_set "$app" open_webserver_port 0
|
|
|
|
open_webserver_port=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STOP KODI
|
|
|
|
#=================================================
|
2021-01-23 21:57:24 +01:00
|
|
|
systemctl stop "$app"
|
2017-11-04 22:45:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
|
|
|
# Backup the current version of the app
|
|
|
|
ynh_backup_before_upgrade
|
|
|
|
ynh_clean_setup () {
|
|
|
|
# restore it if the upgrade fails
|
|
|
|
ynh_restore_upgradebackup
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REPLACE SYSTEMD CONFIG
|
|
|
|
#=================================================
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES AND KODI
|
|
|
|
#=================================================
|
2021-01-23 22:18:57 +01:00
|
|
|
dependencies=""
|
|
|
|
if [[ $arch != arm* ]]; then
|
|
|
|
dependencies = "xorg xinit dbus-x11 kodi"
|
2017-11-04 22:45:12 +01:00
|
|
|
else
|
2021-01-23 22:18:57 +01:00
|
|
|
dependencies = "xserver-xorg-legacy xorg dbus-x11 kodi"
|
2017-11-04 22:45:12 +01:00
|
|
|
fi
|
|
|
|
|
2021-01-23 22:18:57 +01:00
|
|
|
ynh_package_update
|
|
|
|
ynh_install_app_dependencies "$dependencies"
|
|
|
|
|
2017-11-04 22:45:12 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# X11 SETTINGS
|
|
|
|
#=================================================
|
2021-01-23 21:57:24 +01:00
|
|
|
ynh_replace_string "allowed_users=console" "allowed_users=anybody" /etc/X11/Xwrapper.config
|
2017-11-04 22:45:12 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CONTROL WEB INTERFACE
|
|
|
|
#=================================================
|
|
|
|
if [ $open_webserver_port -eq 1 ]
|
|
|
|
then
|
|
|
|
yunohost firewall allow --no-upnp TCP 8080 2>&1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX
|
|
|
|
#=================================================
|
|
|
|
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
ynh_backup_if_checksum_is_different "$finalnginxconf"
|
2021-01-23 21:57:24 +01:00
|
|
|
cp ../conf/nginx.conf "$finalnginxconf"
|
2017-11-04 22:45:12 +01:00
|
|
|
|
|
|
|
if [ "$path_url" == "/" ]; then
|
|
|
|
ynh_replace_string "__PATH__/" "/" "$finalnginxconf"
|
|
|
|
else
|
|
|
|
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
|
|
|
|
fi
|
|
|
|
|
|
|
|
ynh_app_setting_set "$app" protected_uris "/"
|
|
|
|
|
|
|
|
domainregex=$(echo "$domain" | sed 's/-/\%&/g')
|
|
|
|
ynh_app_setting_set "$app" skipped_regex "$domainregex/jsonrpc.*$,$domainregex/image.*$"
|
|
|
|
|
|
|
|
# Reload SSOwat config
|
|
|
|
yunohost app ssowatconf
|
|
|
|
|
|
|
|
# Reload Nginx
|
|
|
|
systemctl reload nginx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START KODI
|
|
|
|
#=================================================
|
2021-01-23 21:57:24 +01:00
|
|
|
systemctl start "$app"
|
2017-11-04 22:45:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|