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

Update install and remove scripts

This commit is contained in:
SylvainCecchetto 2017-10-28 17:47:13 +02:00
parent ddb81927bb
commit cda089d3a8
3 changed files with 38 additions and 63 deletions

View file

@ -8,7 +8,7 @@
}, },
"version": "17.3", "version": "17.3",
"url": "https://kodi.tv", "url": "https://kodi.tv",
"license": "GPLv2", "license": "GPL-2.0",
"maintainer": { "maintainer": {
"name": "Sylvain Cecchetto", "name": "Sylvain Cecchetto",
"email": "cecchetto.sylvain@me.com", "email": "cecchetto.sylvain@me.com",

View file

@ -17,11 +17,12 @@ ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
launch_on_boot=$YNH_APP_ARG_LAUNCH_ON_BOOT launch_on_boot=$YNH_APP_ARG_LAUNCH_ON_BOOT
open_webserver_port=$YNH_APP_ARG_OPEN_WEBSERVER_PORT open_webserver_port=$YNH_APP_ARG_OPEN_WEBSERVER_PORT
app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# GLOBAL VARS # GLOBAL VARS
@ -34,32 +35,32 @@ chorus2_package="https://github.com/xbmc/chorus2/releases/download/2.4.4/webinte
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax # Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url) 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"
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_app_setting_set $app domain $domain ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set "$app" path_url "$path_url"
ynh_app_setting_set $app launch_on_boot $launch_on_boot ynh_app_setting_set "$app" final_path "$final_path"
ynh_app_setting_set $app open_webserver_port $open_webserver_port 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 # CREATE KODI USER
#================================================= #=================================================
# sudo mkdir /home/$app ynh_system_user_create "$app" "$final_path"
ynh_system_user_create $app $final_path sudo mkdir "$final_path"
sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input $app sudo chown -R "$app":"$app" "$final_path"
sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input "$app"
#================================================= #=================================================
@ -67,56 +68,52 @@ sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input $app
#================================================= #=================================================
ynh_add_systemd_config ynh_add_systemd_config
if [ $launch_on_boot -eq 0 ] if [ "$launch_on_boot" -eq 0 ]
then then
sudo systemctl disable $app sudo systemctl disable "$app"
fi fi
#================================================= #=================================================
# INSTALL DEPENDENCIES AND KODI # INSTALL DEPENDENCIES AND KODI
#================================================= #=================================================
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"
ynh_package_update ynh_package_update
ynh_package_install xorg xinit dbus-x11 kodi ynh_package_install xorg xinit dbus-x11 kodi
else else
ynh_package_update
ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi
fi fi
#================================================= #=================================================
# X11 SETTINGS # X11 SETTINGS
#================================================= #=================================================
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 # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add $app --log "$final_path/.kodi/temp/kodi.log" yunohost service add "$app" --log "$final_path/.kodi/temp/kodi.log"
#================================================= #=================================================
# CONTROL WEB INTERFACE # CONTROL WEB INTERFACE
#================================================= #=================================================
sudo mkdir -p $final_path/.kodi/userdata/ sudo mkdir -p "$final_path/.kodi/userdata/"
sudo cp ../conf/advancedsettings.xml $final_path/.kodi/userdata/advancedsettings.xml sudo cp ../conf/advancedsettings.xml "$final_path/.kodi/userdata/advancedsettings.xml"
sudo chown -R $app:$app $final_path sudo chown -R "$app":"$app" "$final_path"
if [[ $arch != arm* ]]; then if [[ $arch != arm* ]]; then
sudo wget $chorus2_package -P /tmp sudo wget -q $chorus2_package -P /tmp
sudo unzip /tmp/webinterface.default.2.4.4.zip -d /tmp/ sudo unzip /tmp/webinterface.default.2.4.4.zip -d /tmp/
sudo mkdir -p $final_path/.kodi/addons/ sudo mkdir -p "$final_path/.kodi/addons/"
sudo mv /tmp/webinterface.default/ $final_path/.kodi/addons/webinterface.chorus2/ sudo mv /tmp/webinterface.default/ "$final_path/.kodi/addons/webinterface.chorus2/"
fi fi
if [ $open_webserver_port -eq 1 ] if [ "$open_webserver_port" -eq 1 ]
then then
yunohost firewall allow --no-upnp TCP 8080 2>&1 yunohost firewall allow --no-upnp TCP 8080 2>&1
fi fi
@ -125,7 +122,6 @@ fi
#================================================= #=================================================
# NGINX # NGINX
#================================================= #=================================================
#ynh_add_nginx_config
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf" finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalnginxconf" ynh_backup_if_checksum_is_different "$finalnginxconf"
sudo cp ../conf/nginx.conf "$finalnginxconf" sudo cp ../conf/nginx.conf "$finalnginxconf"
@ -136,10 +132,10 @@ else
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf" ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
fi fi
ynh_app_setting_set $app protected_uris "/" ynh_app_setting_set "$app" protected_uris "/"
domainregex=$(echo "$domain" | sed 's/-/\%&/g') domainregex=$(echo "$domain" | sed 's/-/\%&/g')
ynh_app_setting_set $app skipped_regex "$domainregex/jsonrpc.*$,$domainregex/image.*$" ynh_app_setting_set "$app" skipped_regex "$domainregex/jsonrpc.*$,$domainregex/image.*$"
# Reload SSOwat config # Reload SSOwat config
yunohost app ssowatconf yunohost app ssowatconf
@ -148,11 +144,7 @@ yunohost app ssowatconf
systemctl reload nginx systemctl reload nginx
#================================================= #=================================================
# START KODI # START KODI
#================================================= #=================================================
sudo systemctl start $app sudo systemctl start "$app"

View file

@ -14,11 +14,11 @@ source /usr/share/yunohost/helpers
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get "$app" path)
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)
open_webserver_port=$(ynh_app_setting_get $app open_webserver_port) open_webserver_port=$(ynh_app_setting_get "$app" open_webserver_port)
#================================================= #=================================================
# GLOBAL VARS # GLOBAL VARS
@ -34,43 +34,38 @@ arch=$(uname -m)
ynh_remove_systemd_config ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
# CLOSE WEB SERVER PORT # CLOSE WEB SERVER PORT
#================================================= #=================================================
if [ $open_webserver_port -eq 1 ] if [ "$open_webserver_port" -eq 1 ]
then then
yunohost firewall disallow TCP 8080 2>&1 yunohost firewall disallow TCP 8080 2>&1
fi fi
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE FROM ADMIN PANEL
#================================================= #=================================================
if yunohost service status | grep -q $app if yunohost service status | grep -q "$app"
then then
echo "Remove $app service" echo "Remove $app service"
yunohost service remove $app yunohost service remove "$app"
fi fi
sudo systemctl daemon-reload sudo systemctl daemon-reload
#================================================= #=================================================
# X11 SETTINGS # X11 SETTINGS
#================================================= #=================================================
sudo sed -i 's/allowed_users=anybody/allowed_users=console/' /etc/X11/Xwrapper.config sudo sed -i 's/allowed_users=anybody/allowed_users=console/' /etc/X11/Xwrapper.config
#================================================= #=================================================
# REMOVE DEPENDENCIES AND KODI # REMOVE DEPENDENCIES AND KODI
#================================================= #=================================================
@ -83,14 +78,6 @@ else
fi fi
#=================================================
# REMOVE SYSTEMD CONFIG
#=================================================
ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -98,11 +85,7 @@ ynh_remove_systemd_config
ynh_secure_remove "$final_path" ynh_secure_remove "$final_path"
#================================================= #=================================================
# REMOVE KODI USER # REMOVE KODI USER
#================================================= #=================================================
ynh_system_user_delete "$app" ynh_system_user_delete "$app"