1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kodi_ynh.git synced 2024-09-03 19:26:34 +02:00
kodi_ynh/scripts/install

149 lines
4.1 KiB
Text
Raw Normal View History

2017-09-27 23:15:40 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
launch_on_boot=$YNH_APP_ARG_LAUNCH_ON_BOOT
open_webserver_port=$YNH_APP_ARG_OPEN_WEBSERVER_PORT
app=$YNH_APP_INSTANCE_NAME
2017-09-27 23:15:40 +02:00
#=================================================
# GLOBAL VARS
#=================================================
arch=$(uname -m)
2017-09-27 23:15:40 +02:00
final_path=/var/www/$app
chorus2_package="https://github.com/xbmc/chorus2/releases/download/2.4.4/webinterface.default.2.4.4.zip"
2017-09-27 23:15:40 +02:00
test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available $domain $path_url
2017-10-16 22:48:13 +02:00
2017-09-27 23:15:40 +02:00
# Register (book) web path
ynh_webpath_register $app $domain $path_url
2017-09-27 23:15:40 +02:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app final_path $final_path
ynh_app_setting_set $app launch_on_boot $launch_on_boot
ynh_app_setting_set $app open_webserver_port $open_webserver_port
2017-09-27 23:15:40 +02:00
#=================================================
# CREATE KODI USER
#=================================================
# sudo mkdir /home/$app
ynh_system_user_create $app $final_path
2017-09-27 23:15:40 +02:00
sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input $app
2017-09-27 23:15:40 +02:00
#=================================================
# ADD SYSTEMD CONFIG
2017-09-27 23:15:40 +02:00
#=================================================
ynh_add_systemd_config
if [ $launch_on_boot -eq 0 ]
then
sudo systemctl disable $app
fi
2017-09-27 23:15:40 +02:00
#=================================================
2017-09-28 07:54:48 +02:00
# INSTALL DEPENDENCIES AND KODI
2017-09-27 23:15:40 +02:00
#=================================================
2017-09-28 07:54:48 +02:00
if [[ $arch != arm* ]]; then
2017-10-16 22:48:13 +02:00
sudo 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_install xserver-xorg-legacy xorg dbus-x11 kodi
fi
#=================================================
# X11 SETTINGS
#=================================================
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
2017-09-27 23:15:40 +02:00
2017-10-16 22:48:13 +02:00
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --log "$final_path/.kodi/temp/kodi.log"
2017-10-16 22:48:13 +02:00
2017-09-30 11:56:47 +02:00
#=================================================
# CONTROL WEB INTERFACE
#=================================================
sudo mkdir -p $final_path/.kodi/userdata/
sudo cp ../conf/advancedsettings.xml $final_path/.kodi/userdata/advancedsettings.xml
sudo chown -R $app:$app $final_path
if [[ $arch != arm* ]]; then
sudo wget $chorus2_package -P /tmp
sudo unzip /tmp/webinterface.default.2.4.4.zip -d /tmp/
sudo mkdir -p $final_path/.kodi/addons/
sudo mv /tmp/webinterface.default/ $final_path/.kodi/addons/webinterface.chorus2/
fi
if [ $open_webserver_port -eq 1 ]
then
yunohost firewall allow --no-upnp TCP 8080 2>&1
fi
#=================================================
# NGINX
#=================================================
2017-09-30 11:56:47 +02:00
ynh_add_nginx_config
2017-10-16 22:48:13 +02:00
ynh_app_setting_set $app protected_uris "/"
domainregex=$(echo "$domain" | sed 's/-/\%&/g')
ynh_app_setting_set $app skipped_regex "$domainregex/jsonrpc.*$,$domainregex/image.*$"
2017-10-16 22:48:13 +02:00
# Reload SSOwat config
yunohost app ssowatconf
# Reload Nginx
systemctl reload nginx
#=================================================
# START KODI
#=================================================
sudo systemctl start $app