From cda089d3a891126b5d9a27860fc377e35097fc70 Mon Sep 17 00:00:00 2001 From: SylvainCecchetto Date: Sat, 28 Oct 2017 17:47:13 +0200 Subject: [PATCH] Update install and remove scripts --- manifest.json | 2 +- scripts/install | 66 ++++++++++++++++++++++--------------------------- scripts/remove | 33 ++++++------------------- 3 files changed, 38 insertions(+), 63 deletions(-) diff --git a/manifest.json b/manifest.json index bf4bdf3..6f018ff 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ }, "version": "17.3", "url": "https://kodi.tv", - "license": "GPLv2", + "license": "GPL-2.0", "maintainer": { "name": "Sylvain Cecchetto", "email": "cecchetto.sylvain@me.com", diff --git a/scripts/install b/scripts/install index e992703..2f09b7d 100644 --- a/scripts/install +++ b/scripts/install @@ -17,11 +17,12 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +app=$YNH_APP_INSTANCE_NAME 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 + #================================================= # 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" # 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 -ynh_webpath_available $domain $path_url +ynh_webpath_available "$domain" "$path_url" # Register (book) web path -ynh_webpath_register $app $domain $path_url - +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 +ynh_app_setting_set "$app" domain "$domain" +ynh_app_setting_set "$app" path_url "$path_url" +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 $final_path -sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input $app - +ynh_system_user_create "$app" "$final_path" +sudo mkdir "$final_path" +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 -if [ $launch_on_boot -eq 0 ] +if [ "$launch_on_boot" -eq 0 ] then - sudo systemctl disable $app + sudo systemctl disable "$app" fi - #================================================= # INSTALL DEPENDENCIES AND KODI #================================================= 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_install xorg xinit dbus-x11 kodi else + ynh_package_update 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 "$final_path/.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 +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 wget -q $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/ + 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 ] +if [ "$open_webserver_port" -eq 1 ] then yunohost firewall allow --no-upnp TCP 8080 2>&1 fi @@ -125,7 +122,6 @@ fi #================================================= # NGINX #================================================= -#ynh_add_nginx_config finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup_if_checksum_is_different "$finalnginxconf" sudo cp ../conf/nginx.conf "$finalnginxconf" @@ -136,10 +132,10 @@ else ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf" fi -ynh_app_setting_set $app protected_uris "/" +ynh_app_setting_set "$app" protected_uris "/" 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 yunohost app ssowatconf @@ -148,11 +144,7 @@ yunohost app ssowatconf systemctl reload nginx - #================================================= # START KODI #================================================= -sudo systemctl start $app - - - +sudo systemctl start "$app" diff --git a/scripts/remove b/scripts/remove index 8d5910e..b48b1f1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -14,11 +14,11 @@ 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) +domain=$(ynh_app_setting_get "$app" domain) +path_url=$(ynh_app_setting_get "$app" path) +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 @@ -34,43 +34,38 @@ arch=$(uname -m) ynh_remove_systemd_config - #================================================= # REMOVE NGINX CONFIGURATION #================================================= ynh_remove_nginx_config - #================================================= # CLOSE WEB SERVER PORT #================================================= -if [ $open_webserver_port -eq 1 ] +if [ "$open_webserver_port" -eq 1 ] then yunohost firewall disallow TCP 8080 2>&1 fi - #================================================= # REMOVE SERVICE FROM ADMIN PANEL #================================================= -if yunohost service status | grep -q $app +if yunohost service status | grep -q "$app" then echo "Remove $app service" - yunohost service remove $app + yunohost service remove "$app" fi sudo systemctl daemon-reload - #================================================= # X11 SETTINGS #================================================= sudo sed -i 's/allowed_users=anybody/allowed_users=console/' /etc/X11/Xwrapper.config - #================================================= # REMOVE DEPENDENCIES AND KODI #================================================= @@ -83,14 +78,6 @@ else fi - -#================================================= -# REMOVE SYSTEMD CONFIG -#================================================= -ynh_remove_systemd_config - - - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -98,11 +85,7 @@ ynh_remove_systemd_config ynh_secure_remove "$final_path" - #================================================= # REMOVE KODI USER #================================================= ynh_system_user_delete "$app" - - -