mirror of
https://github.com/YunoHost-Apps/kodi_ynh.git
synced 2024-09-03 19:26:34 +02:00
139 lines
No EOL
4 KiB
Bash
139 lines
No EOL
4 KiB
Bash
#!/bin/bash
|
|
|
|
# MEMO TO TEST THIS SCRIPT
|
|
# yunohost backup create --ignore-system --apps kodi
|
|
# yunohost app remove kodi
|
|
# yunohost backup restore backup.tar
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
|
|
#=================================================
|
|
# GLOBAL VARS
|
|
#=================================================
|
|
arch=$(uname -m)
|
|
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
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)
|
|
|
|
|
|
#=================================================
|
|
# CHECK IF THE APP CAN BE RESTORED
|
|
#=================================================
|
|
ynh_webpath_available "$domain" "$path_url" \
|
|
|| ynh_die "Path not available: ${domain}${path_url}"
|
|
test ! -d "$final_path" \
|
|
|| ynh_die "There is already a directory: $final_path "
|
|
|
|
|
|
#=================================================
|
|
# CREATE KODI USER
|
|
#=================================================
|
|
ynh_system_user_create "$app" "$final_path"
|
|
mkdir "$final_path"
|
|
chown -R "$app":"$app" "$final_path"
|
|
usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev "$app"
|
|
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_restore_file "$final_path"
|
|
# Restore permissions on app files
|
|
chown -R "$app":"$app" "$final_path"
|
|
|
|
|
|
#=================================================
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEMD
|
|
#=================================================
|
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
|
|
|
|
|
#=================================================
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
#=================================================
|
|
yunohost service add "$app" --log "$final_path/.kodi/temp/kodi.log"
|
|
|
|
|
|
#=================================================
|
|
# RESTORE LAUNCH ON BOOT
|
|
#=================================================
|
|
if [ "$launch_on_boot" -eq 0 ]
|
|
then
|
|
systemctl disable "$app"
|
|
else
|
|
systemctl enable "$app".service
|
|
fi
|
|
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES AND KODI
|
|
#=================================================
|
|
if [[ $arch != arm* ]]; then
|
|
ynh_restore_file "/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
|
|
#=================================================
|
|
ynh_replace_string "allowed_users=console" "allowed_users=anybody" /etc/X11/Xwrapper.config
|
|
|
|
#=================================================
|
|
# CONTROL WEB INTERFACE
|
|
#=================================================
|
|
if [ "$open_webserver_port" -eq 1 ]
|
|
then
|
|
yunohost firewall allow --no-upnp TCP 8080 2>&1
|
|
fi
|
|
|
|
|
|
# Reload SSOwat config
|
|
yunohost app ssowatconf
|
|
|
|
# Reload Nginx
|
|
systemctl reload nginx
|
|
|
|
|
|
#=================================================
|
|
# START KODI
|
|
#=================================================
|
|
systemctl start "$app" |