mirror of
https://github.com/YunoHost-Apps/kodi_ynh.git
synced 2024-09-03 19:26:34 +02:00
128 lines
No EOL
4 KiB
Bash
128 lines
No EOL
4 KiB
Bash
#!/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
|
|
|
|
app=kodi
|
|
final_path=/var/www/$app
|
|
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
|
|
|
|
# Register (book) web path
|
|
ynh_webpath_register $app $domain $path_url
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
#=================================================
|
|
# CREATE KODI USER
|
|
#=================================================
|
|
sudo mkdir /home/$app
|
|
ynh_system_user_create "$app" "/home/$app"
|
|
sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input $app
|
|
|
|
#=================================================
|
|
# ADD SYSTEMD SCRIPT (SERVICE)
|
|
#=================================================
|
|
sed -i "s@#KODIUSER#@${app}@g" ../conf/kodi.service
|
|
sed -i "s@#KODIGROUP#@${app}@g" ../conf/kodi.service
|
|
sudo cp ../conf/kodi.service /etc/systemd/system/kodi.service
|
|
sudo systemctl daemon-reload
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES AND KODI
|
|
#=================================================
|
|
arch=$(uname -m)
|
|
if [[ $arch != arm* ]]; then
|
|
sudo cp ../conf/kodi.list /etc/apt/sources.list.d/${app}.list
|
|
fi
|
|
ynh_package_update
|
|
if [[ $arch == arm* ]]; then
|
|
ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi
|
|
else
|
|
ynh_package_install xorg xinit dbus-x11 kodi
|
|
fi
|
|
|
|
#=================================================
|
|
# X11 SETTINGS
|
|
#=================================================
|
|
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
|
|
|
|
|
|
#=================================================
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
#=================================================
|
|
|
|
yunohost service add $app --log "/home/$app/.kodi/temp/kodi.log"
|
|
|
|
#=================================================
|
|
# CONTROL WEB INTERFACE
|
|
#=================================================
|
|
if [[ $arch != arm* ]]; then
|
|
sudo wget "https://github.com/xbmc/chorus2/releases/download/2.4.4/webinterface.default.2.4.4.zip" -P /tmp
|
|
sudo unzip "/tmp/webinterface.default.2.4.4.zip" -d /tmp/
|
|
sudo mkdir -p /home/kodi/.kodi/addons/
|
|
sudo mv /tmp/webinterface.default/ /home/kodi/.kodi/addons/webinterface.chorus2/
|
|
fi
|
|
sudo mkdir -p /home/$app/.kodi/userdata/
|
|
sudo cp ../conf/advancedsettings.xml /home/$app/.kodi/userdata/advancedsettings.xml
|
|
sudo chown -R $app:$app /home/$app
|
|
|
|
|
|
#=================================================
|
|
# NGINX
|
|
#=================================================
|
|
ynh_add_nginx_config
|
|
|
|
ynh_app_setting_set $app skipped_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
|
|
|
|
|
|
#=================================================
|
|
# LAUNCH KODI AT STARTUP?
|
|
#=================================================
|
|
if [ $launch_on_boot -eq 1 ]
|
|
then
|
|
sudo systemctl enable $app
|
|
fi
|
|
|
|
#=================================================
|
|
# START KODI
|
|
#=================================================
|
|
sudo systemctl start $app |