2017-09-27 23:15:40 +02:00
|
|
|
#!/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
|
|
|
|
#=================================================
|
2017-10-28 17:47:13 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2017-09-27 23:15:40 +02:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
launch_on_boot=$YNH_APP_ARG_LAUNCH_ON_BOOT
|
2017-10-19 19:57:17 +02:00
|
|
|
open_webserver_port=$YNH_APP_ARG_OPEN_WEBSERVER_PORT
|
2017-10-28 17:47:13 +02:00
|
|
|
|
2017-09-27 23:15:40 +02:00
|
|
|
|
2017-10-19 19:57:17 +02:00
|
|
|
#=================================================
|
|
|
|
# GLOBAL VARS
|
|
|
|
#=================================================
|
|
|
|
arch=$(uname -m)
|
2017-09-27 23:15:40 +02:00
|
|
|
final_path=/var/www/$app
|
2017-10-19 19:57:17 +02:00
|
|
|
|
|
|
|
|
2017-09-27 23:15:40 +02:00
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
|
|
|
|
|
|
# Normalize the url path syntax
|
2017-10-28 17:47:13 +02:00
|
|
|
path_url=$(ynh_normalize_url_path "$path_url")
|
2017-09-27 23:15:40 +02:00
|
|
|
|
|
|
|
# Check web path availability
|
2017-10-28 17:47:13 +02:00
|
|
|
ynh_webpath_available "$domain" "$path_url"
|
2017-10-16 22:48:13 +02:00
|
|
|
|
2017-09-27 23:15:40 +02:00
|
|
|
# Register (book) web path
|
2017-10-28 17:47:13 +02:00
|
|
|
ynh_webpath_register "$app" "$domain" "$path_url"
|
2017-10-19 19:57:17 +02:00
|
|
|
|
2017-10-19 21:38:10 +02:00
|
|
|
|
2017-09-27 23:15:40 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2017-10-28 17:47:13 +02:00
|
|
|
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"
|
2017-10-19 19:57:17 +02:00
|
|
|
|
2017-09-27 23:15:40 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CREATE KODI USER
|
|
|
|
#=================================================
|
2017-10-28 17:47:13 +02:00
|
|
|
ynh_system_user_create "$app" "$final_path"
|
2021-01-23 21:57:24 +01:00
|
|
|
mkdir "$final_path"
|
|
|
|
chown -R "$app":"$app" "$final_path"
|
|
|
|
usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev "$app"
|
2017-10-19 19:57:17 +02:00
|
|
|
|
|
|
|
|
2017-09-27 23:15:40 +02:00
|
|
|
#=================================================
|
2017-10-19 19:57:17 +02:00
|
|
|
# ADD SYSTEMD CONFIG
|
2017-09-27 23:15:40 +02:00
|
|
|
#=================================================
|
2017-10-19 19:57:17 +02:00
|
|
|
ynh_add_systemd_config
|
|
|
|
|
2017-10-28 17:47:13 +02:00
|
|
|
if [ "$launch_on_boot" -eq 0 ]
|
2017-10-19 19:57:17 +02:00
|
|
|
then
|
2021-01-23 21:57:24 +01:00
|
|
|
systemctl disable "$app"
|
2017-10-19 19:57:17 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2017-09-27 23:15:40 +02:00
|
|
|
#=================================================
|
2017-09-28 07:54:48 +02:00
|
|
|
# INSTALL DEPENDENCIES AND KODI
|
2017-09-27 23:15:40 +02:00
|
|
|
#=================================================
|
2017-09-28 07:54:48 +02:00
|
|
|
if [[ $arch != arm* ]]; then
|
2021-01-23 22:37:16 +01:00
|
|
|
ynh_install_app_dependencies "xorg xinit dbus-x11 kodi"
|
2017-10-19 13:08:22 +02:00
|
|
|
else
|
2021-01-23 22:37:16 +01:00
|
|
|
ynh_install_app_dependencies "xserver-xorg-legacy xorg dbus-x11 kodi"
|
2017-10-17 21:32:10 +02:00
|
|
|
fi
|
2017-09-27 23:24:12 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# X11 SETTINGS
|
|
|
|
#=================================================
|
2021-01-23 21:57:24 +01:00
|
|
|
ynh_replace_string "allowed_users=console" "allowed_users=anybody" /etc/X11/Xwrapper.config
|
2017-09-27 23:24:12 +02:00
|
|
|
|
2017-09-27 23:15:40 +02:00
|
|
|
|
2017-10-16 22:48:13 +02:00
|
|
|
#=================================================
|
|
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
|
|
#=================================================
|
2017-10-28 17:47:13 +02:00
|
|
|
yunohost service add "$app" --log "$final_path/.kodi/temp/kodi.log"
|
2017-10-16 22:48:13 +02:00
|
|
|
|
|
|
|
|
2017-09-30 11:56:47 +02:00
|
|
|
#=================================================
|
|
|
|
# CONTROL WEB INTERFACE
|
|
|
|
#=================================================
|
2021-01-23 21:57:24 +01:00
|
|
|
mkdir -p "$final_path/.kodi/userdata/"
|
|
|
|
cp ../conf/advancedsettings.xml "$final_path/.kodi/userdata/advancedsettings.xml"
|
2017-10-19 19:57:17 +02:00
|
|
|
|
2021-01-23 23:26:21 +01:00
|
|
|
mkdir -p "$final_path/.kodi/addons/"
|
2017-10-19 13:08:22 +02:00
|
|
|
if [[ $arch != arm* ]]; then
|
2021-01-23 23:14:01 +01:00
|
|
|
ynh_setup_source --dest_dir="$final_path/.kodi/addons/" --source_id="arm-chorus2"
|
2017-10-19 19:57:17 +02:00
|
|
|
fi
|
|
|
|
|
2021-01-23 21:57:24 +01:00
|
|
|
chown -R "$app":"$app" "$final_path"
|
2018-01-03 09:03:35 +01:00
|
|
|
|
2017-10-28 17:47:13 +02:00
|
|
|
if [ "$open_webserver_port" -eq 1 ]
|
2017-10-19 19:57:17 +02:00
|
|
|
then
|
|
|
|
yunohost firewall allow --no-upnp TCP 8080 2>&1
|
2017-10-19 13:08:22 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX
|
|
|
|
#=================================================
|
2017-10-19 21:38:10 +02:00
|
|
|
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
ynh_backup_if_checksum_is_different "$finalnginxconf"
|
2021-01-23 21:57:24 +01:00
|
|
|
cp ../conf/nginx.conf "$finalnginxconf"
|
2017-10-19 21:38:10 +02:00
|
|
|
|
|
|
|
if [ "$path_url" == "/" ]; then
|
|
|
|
ynh_replace_string "__PATH__/" "/" "$finalnginxconf"
|
|
|
|
else
|
|
|
|
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
|
|
|
|
fi
|
2017-10-16 22:48:13 +02:00
|
|
|
|
2017-10-28 17:47:13 +02:00
|
|
|
ynh_app_setting_set "$app" protected_uris "/"
|
2017-10-19 13:08:22 +02:00
|
|
|
|
2017-10-19 19:57:17 +02:00
|
|
|
domainregex=$(echo "$domain" | sed 's/-/\%&/g')
|
2017-10-28 17:47:13 +02:00
|
|
|
ynh_app_setting_set "$app" skipped_regex "$domainregex/jsonrpc.*$,$domainregex/image.*$"
|
2017-10-19 13:08:22 +02:00
|
|
|
|
2017-10-16 22:48:13 +02:00
|
|
|
# Reload SSOwat config
|
|
|
|
yunohost app ssowatconf
|
|
|
|
|
|
|
|
# Reload Nginx
|
|
|
|
systemctl reload nginx
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START KODI
|
|
|
|
#=================================================
|
2021-01-23 21:57:24 +01:00
|
|
|
systemctl start "$app"
|