#!/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 #================================================= systemctl stop "$app" #================================================= # 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 #================================================= if [[ "$arch" != arm* ]]; then cp ../conf/kodi.list "/etc/apt/sources.list.d/${app}.list" ynh_package_update ynh_package_install xorg xinit dbus-x11 kodi else ynh_package_update ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi fi #================================================= # X11 SETTINGS #================================================= ynh_replace_string "allowed_users=console" "allowed_users=anybody" /etc/X11/Xwrapper.config #================================================= # 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" cp ../conf/nginx.conf "$finalnginxconf" 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 #================================================= systemctl start "$app"