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

Launch on startup now works

This commit is contained in:
SylvainCecchetto 2017-10-16 22:48:13 +02:00
parent 66afd8c122
commit 1bdc7d5e83
4 changed files with 71 additions and 21 deletions

View file

@ -15,11 +15,12 @@ Kodi for YunoHost
* The scprit use jessie backports to install Kodi 16 (We have to wait for Debian Strech officialy install Kodi 17) * The scprit use jessie backports to install Kodi 16 (We have to wait for Debian Strech officialy install Kodi 17)
* A dedicated kodi user is create * A dedicated kodi user is create
* Use of systemd * Use of systemd
* You can launch Kodi with the ```sudo systemctl start kodi``` command * You can launch Kodi with the ```sudo systemctl start kodi``` command or stop Kodi with ```sudo systemctl stop kodi```
* You can choose if you want that Kodi start at YunoHost server statup
* You can access to the control web interface only if you choose a "/" path (Reverse proxy issue)
* Kodi directly start after package installation
## To do ## To do
* Test package on Raspberry
* Add option to launch Kodi at server startup
* Add the control web interface to YunoHost user interface * Add the control web interface to YunoHost user interface
* Maybe we can launch Kodi from YunoHost web interface instead of SSH * Maybe we can launch Kodi from YunoHost web interface instead of SSH

View file

@ -1,10 +1,21 @@
location __PATH__/ { location __PATH__ {
proxy_pass http://127.0.0.1:8080/; proxy_pass http://127.0.0.1:8080$uri;
proxy_set_header Host $host; rewrite ^ $request_uri;
rewrite ^([^.]*[^/])$ $1/ permanent;
rewrite ^__PATH__(.*) /$1 break;
proxy_redirect http://127.0.0.1:8080 __PATH__;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-Host $server_name; proxy_set_header Upgrade $http_upgrade;
proxy_http_version 1.1; proxy_set_header Connection "upgrade";
}
# For kodi
# Shouldn't need this when proxy headers are turned on. No idea why it does not work (Settings -> Web interface -> Reverse proxy support)
location ~ ^/(image|jsonrpc) {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
} }

View file

@ -30,6 +30,7 @@ path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability # Check web path availability
ynh_webpath_available $domain $path_url ynh_webpath_available $domain $path_url
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register $app $domain $path_url
@ -53,14 +54,14 @@ sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input $app
sed -i "s@#KODIUSER#@${app}@g" ../conf/kodi.service sed -i "s@#KODIUSER#@${app}@g" ../conf/kodi.service
sed -i "s@#KODIGROUP#@${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 cp ../conf/kodi.service /etc/systemd/system/kodi.service
sudo systemctl daemon-reload
#================================================= #=================================================
# INSTALL DEPENDENCIES AND KODI # INSTALL DEPENDENCIES AND KODI
#================================================= #=================================================
arch=$(uname -m) arch=$(uname -m)
if [[ $arch != arm* ]]; then if [[ $arch != arm* ]]; then
sudo cp ../conf/kodi.list /etc/apt/sources.list.d/${app}.list sudo cp ../conf/kodi.list /etc/apt/sources.list.d/${app}.list
fi fi
ynh_package_update ynh_package_update
ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi
@ -71,6 +72,12 @@ ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config 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 # CONTROL WEB INTERFACE
#================================================= #=================================================
@ -78,3 +85,25 @@ sudo mkdir -p /home/$app/.kodi/userdata/
sudo cp ../conf/advancedsettings.xml /home/$app/.kodi/userdata/advancedsettings.xml sudo cp ../conf/advancedsettings.xml /home/$app/.kodi/userdata/advancedsettings.xml
sudo chown -R $app:$app /home/$app sudo chown -R $app:$app /home/$app
ynh_add_nginx_config ynh_add_nginx_config
ynh_app_setting_set $app protected_uris "/"
# 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

View file

@ -19,6 +19,21 @@ domain=$(ynh_app_setting_get $app domain)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
launch_on_boot=$(ynh_app_setting_get $app launch_on_boot) launch_on_boot=$(ynh_app_setting_get $app launch_on_boot)
#=================================================
# REMOVE SYSTEMD SCRIPT (SERVICE)
#=================================================
ynh_remove_systemd_config
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
if yunohost service status | grep -q $app
then
echo "Remove $app service"
yunohost service remove $app
fi
sudo systemctl daemon-reload
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
@ -28,7 +43,7 @@ sudo sed -i 's/allowed_users=anybody/allowed_users=console/' /etc/X11/Xwrapper.c
ynh_package_autoremove kodi xorg dbus-x11 xserver-xorg-legacy ynh_package_autoremove kodi xorg dbus-x11 xserver-xorg-legacy
arch=$(uname -m) arch=$(uname -m)
if [[ $arch != arm* ]]; then if [[ $arch != arm* ]]; then
sudo rm -f "/etc/apt/sources.list.d/${app}.list" sudo rm -f "/etc/apt/sources.list.d/${app}.list"
fi fi
ynh_package_update ynh_package_update
@ -40,12 +55,6 @@ ynh_package_update
ynh_secure_remove "$final_path" ynh_secure_remove "$final_path"
#=================================================
# REMOVE SYSTEMD SCRIPT (SERVICE)
#=================================================
ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE KODI USER # REMOVE KODI USER
#================================================= #=================================================