2017-10-19 22:06:59 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-11-04 22:45:12 +01:00
|
|
|
# MEMO TO TEST THIS SCRIPT
|
|
|
|
# yunohost backup create --ignore-system --apps kodi
|
|
|
|
# yunohost app remove kodi
|
|
|
|
# yunohost backup restore backup.tar
|
|
|
|
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ ! -e _common.sh ]; then
|
|
|
|
# Get the _common.sh file if it's not in the current directory
|
|
|
|
cp ../settings/scripts/_common.sh ./_common.sh
|
|
|
|
chmod a+rx _common.sh
|
|
|
|
fi
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-11-04 22:45:12 +01:00
|
|
|
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
# GLOBAL VARS
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
arch=$(uname -m)
|
2017-10-19 22:06:59 +02:00
|
|
|
|
2017-11-04 22:45:12 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
2017-10-19 22:06:59 +02:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-11-04 22:45:12 +01:00
|
|
|
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2017-11-04 22:45:12 +01:00
|
|
|
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)
|
2017-10-19 22:06:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE RESTORED
|
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
ynh_webpath_available "$domain" "$path_url" \
|
2017-10-19 22:06:59 +02:00
|
|
|
|| ynh_die "Path not available: ${domain}${path_url}"
|
2017-11-04 22:45:12 +01:00
|
|
|
test ! -d "$final_path" \
|
2017-10-19 22:06:59 +02:00
|
|
|
|| ynh_die "There is already a directory: $final_path "
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
# CREATE KODI USER
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01: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 22:06:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
ynh_restore_file "$final_path"
|
2017-11-04 22:45:12 +01:00
|
|
|
# Restore permissions on app files
|
|
|
|
chown -R "$app":"$app" "$final_path"
|
2017-10-19 22:06:59 +02:00
|
|
|
|
|
|
|
|
2017-11-04 22:45:12 +01:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2017-10-19 22:06:59 +02:00
|
|
|
|
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
# RESTORE SYSTEMD
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
|
|
|
|
2017-10-19 22:06:59 +02:00
|
|
|
|
2017-11-04 22:45:12 +01:00
|
|
|
#=================================================
|
|
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
|
|
#=================================================
|
|
|
|
yunohost service add "$app" --log "$final_path/.kodi/temp/kodi.log"
|
2017-10-19 22:06:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
# RESTORE LAUNCH ON BOOT
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
if [ "$launch_on_boot" -eq 0 ]
|
|
|
|
then
|
2021-01-23 21:57:24 +01:00
|
|
|
systemctl disable "$app"
|
2017-11-04 22:45:12 +01:00
|
|
|
else
|
|
|
|
systemctl enable "$app".service
|
|
|
|
fi
|
2017-10-19 22:06:59 +02:00
|
|
|
|
|
|
|
|
2017-11-04 22:45:12 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES AND KODI
|
|
|
|
#=================================================
|
2021-01-23 22:18:57 +01:00
|
|
|
dependencies=""
|
2017-11-04 22:45:12 +01:00
|
|
|
if [[ $arch != arm* ]]; then
|
2021-01-23 22:18:57 +01:00
|
|
|
dependencies = "xorg xinit dbus-x11 kodi"
|
2017-11-04 22:45:12 +01:00
|
|
|
else
|
2021-01-23 22:18:57 +01:00
|
|
|
dependencies = "xserver-xorg-legacy xorg dbus-x11 kodi"
|
2017-11-04 22:45:12 +01:00
|
|
|
fi
|
2017-10-19 22:06:59 +02:00
|
|
|
|
2021-01-23 22:18:57 +01:00
|
|
|
ynh_package_update
|
|
|
|
ynh_install_app_dependencies "$dependencies"
|
|
|
|
|
2017-10-19 22:06:59 +02:00
|
|
|
|
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
# X11 SETTINGS
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
2021-01-23 21:57:24 +01:00
|
|
|
ynh_replace_string "allowed_users=console" "allowed_users=anybody" /etc/X11/Xwrapper.config
|
2017-10-19 22:06:59 +02:00
|
|
|
|
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
# CONTROL WEB INTERFACE
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
if [ "$open_webserver_port" -eq 1 ]
|
2017-10-19 22:06:59 +02:00
|
|
|
then
|
2017-11-04 22:45:12 +01:00
|
|
|
yunohost firewall allow --no-upnp TCP 8080 2>&1
|
2017-10-19 22:06:59 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2017-11-04 22:45:12 +01:00
|
|
|
# Reload SSOwat config
|
|
|
|
yunohost app ssowatconf
|
|
|
|
|
|
|
|
# Reload Nginx
|
|
|
|
systemctl reload nginx
|
|
|
|
|
|
|
|
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
2017-11-04 22:45:12 +01:00
|
|
|
# START KODI
|
2017-10-19 22:06:59 +02:00
|
|
|
#=================================================
|
2021-01-23 21:57:24 +01:00
|
|
|
systemctl start "$app"
|