mirror of
https://github.com/YunoHost-Apps/kodi_ynh.git
synced 2024-09-03 19:26:34 +02:00
Clean install and remove scripts, add option to open 8080 port
This commit is contained in:
parent
625121a6bc
commit
9971d16d32
5 changed files with 116 additions and 51 deletions
|
@ -25,10 +25,9 @@ Kodi for YunoHost
|
|||
## To do
|
||||
* Test control web interface on Raspberry
|
||||
* Switch from skipped_uri to protected_uri and try if it still works for jsonrpc and image location
|
||||
* Add missing elements in remove script
|
||||
* Add option in manifest to open 8080 port to be able to use Kodi remote smartphone app
|
||||
* Check if a "/" path still works
|
||||
* Write the upgrade script
|
||||
* Write the upgrade and backup script
|
||||
* Check if webserver port (8080) is free
|
||||
|
||||
## Links
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ After = systemd-user-sessions.service network.target sound.target
|
|||
# Wants = mysql.service
|
||||
|
||||
[Service]
|
||||
User = #KODIUSER#
|
||||
Group = #KODIGROUP#
|
||||
User = __APP__
|
||||
Group = __APP__
|
||||
Type = simple
|
||||
#PAMName = login # you might want to try this one, did not work on all systems
|
||||
ExecStart = /usr/bin/xinit /usr/bin/dbus-launch --exit-with-session /usr/bin/kodi-standalone -- :0 -nolisten tcp vt7
|
|
@ -50,6 +50,15 @@
|
|||
"fr": "Démarrer Kodi au démarrage du serveur YunoHost"
|
||||
},
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "open_webserver_port",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Open port 8080 in order to use a smartphone Kodi remote app on your local network",
|
||||
"fr": "Ouvrir le port 8080 afin de pouvoir utiliser une application smartphone de télécommande Kodi sur le réseau local"
|
||||
},
|
||||
"default": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -20,9 +20,17 @@ ynh_abort_if_errors
|
|||
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
|
||||
|
||||
app=kodi
|
||||
#=================================================
|
||||
# GLOBAL VARS
|
||||
#=================================================
|
||||
arch=$(uname -m)
|
||||
final_path=/var/www/$app
|
||||
chorus2_package="https://github.com/xbmc/chorus2/releases/download/2.4.4/webinterface.default.2.4.4.zip"
|
||||
|
||||
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Normalize the url path syntax
|
||||
|
@ -34,66 +42,83 @@ 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
|
||||
ynh_app_setting_set $app open_webserver_port $open_webserver_port
|
||||
|
||||
|
||||
#=================================================
|
||||
# CREATE KODI USER
|
||||
#=================================================
|
||||
sudo mkdir /home/$app
|
||||
ynh_system_user_create "$app" "/home/$app"
|
||||
# sudo mkdir /home/$app
|
||||
ynh_system_user_create $app $final_path
|
||||
sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input $app
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# ADD SYSTEMD SCRIPT (SERVICE)
|
||||
# ADD SYSTEMD CONFIG
|
||||
#=================================================
|
||||
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
|
||||
ynh_add_systemd_config
|
||||
|
||||
if [ $launch_on_boot -eq 0 ]
|
||||
then
|
||||
sudo systemctl disable $app
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
ynh_package_update
|
||||
ynh_package_install xorg xinit dbus-x11 kodi
|
||||
else
|
||||
ynh_package_install xorg xinit dbus-x11 kodi
|
||||
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
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
yunohost service add $app --log "$final_path/.kodi/temp/kodi.log"
|
||||
|
||||
|
||||
yunohost service add $app --log "/home/$app/.kodi/temp/kodi.log"
|
||||
|
||||
#=================================================
|
||||
# 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 "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/
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
#=================================================
|
||||
|
@ -102,11 +127,10 @@ sudo chown -R $app:$app /home/$app
|
|||
ynh_add_nginx_config
|
||||
|
||||
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
|
||||
|
||||
|
@ -114,15 +138,11 @@ yunohost app ssowatconf
|
|||
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
|
||||
sudo systemctl start $app
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,21 +9,49 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
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)
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEMD SCRIPT (SERVICE)
|
||||
#=================================================
|
||||
# Stop and diasble Kodi service
|
||||
# Remove kodi.service file
|
||||
ynh_remove_systemd_config
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_remove_nginx_config
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# CLOSE WEB SERVER PORT
|
||||
#=================================================
|
||||
if [ $open_webserver_port -eq 1 ]
|
||||
then
|
||||
yunohost firewall disallow TCP 8080 2>&1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE SERVICE FROM ADMIN PANEL
|
||||
#=================================================
|
||||
|
@ -35,17 +63,32 @@ fi
|
|||
sudo systemctl daemon-reload
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
# X11 SETTINGS
|
||||
#=================================================
|
||||
# Remove metapackage and its dependencies
|
||||
sudo sed -i 's/allowed_users=anybody/allowed_users=console/' /etc/X11/Xwrapper.config
|
||||
ynh_package_autoremove kodi xorg dbus-x11 xserver-xorg-legacy
|
||||
arch=$(uname -m)
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES AND KODI
|
||||
#=================================================
|
||||
if [[ $arch != arm* ]]; then
|
||||
sudo rm -f "/etc/apt/sources.list.d/${app}.list"
|
||||
ynh_package_remove xorg xinit dbus-x11 kodi
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/${app}.list"
|
||||
ynh_package_update
|
||||
else
|
||||
ynh_package_remove xserver-xorg-legacy xorg dbus-x11 kodi
|
||||
fi
|
||||
ynh_package_update
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEMD CONFIG
|
||||
#=================================================
|
||||
ynh_remove_systemd_config
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
|
@ -55,17 +98,11 @@ ynh_package_update
|
|||
ynh_secure_remove "$final_path"
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE KODI USER
|
||||
#=================================================
|
||||
ynh_system_user_delete "$app"
|
||||
sudo rm -rf "/home/$app"
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_remove_nginx_config
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue