1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/tvheadend_ynh.git synced 2024-10-01 13:34:50 +02:00

Merge pull request #11 from YunoHost-Apps/testing

Testing
This commit is contained in:
yalh76 2022-03-10 19:40:06 +01:00 committed by GitHub
commit ee56a100ea
14 changed files with 285 additions and 227 deletions

55
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,55 @@
---
name: Bug report
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
- *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
### Describe the bug
*A clear and concise description of what the bug is.*
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install the_app
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '...'*
3. *Scroll down to '...'*
4. *See error*
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,16 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)
## Automatic tests
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

66
.gitignore vendored
View file

@ -1,66 +0,0 @@
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*

View file

@ -1,16 +1,21 @@
;; Full test
; Manifest
domain="domain.tld"
path="/path"
superuser="toto"
password="865t5cTNjU8wPpY6"
password="1Strong-Password"
port="9982"
; Checks
pkg_linter=1
setup_root=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=0
setup_public=0
upgrade=1
# 4.3.1979~ynh9
upgrade=1 from_commit=e82643952e5567db826790e1e4a353559f66f112
backup_restore=1
multi_instance=0
port_already_use=1
change_url=1
actions=0
config_panel=0

View file

@ -1,8 +1,5 @@
location __PATH__ {
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__;
proxy_set_header Host $host;
@ -13,4 +10,4 @@ location __PATH__ {
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
}

0
doc/DESCRIPTION.md Normal file
View file

0
doc/DISCLAIMER.md Normal file
View file

View file

@ -10,4 +10,16 @@ pkg_dependencies_rb="libavahi-client3 libavahi-common3 libc6 libdbus-1-3 libdvbc
# deb package URLs
tvheadend_deb_x86="https://github.com/YunoHost-Apps/tvheadend_ynh/raw/debs/4.3.1979/tvheadend_4.3-1979%7Eg8fc2dfa7e%7Estretch_amd64.deb"
tvheadend_deb_arm="https://github.com/YunoHost-Apps/tvheadend_ynh/raw/debs/4.3.1979/tvheadend_4.3-1979%7Eg8fc2dfa7e%7Eraspbianstretch_armhf.deb"
tvheadend_deb_arm="https://github.com/YunoHost-Apps/tvheadend_ynh/raw/debs/4.3.1979/tvheadend_4.3-1979%7Eg8fc2dfa7e%7Eraspbianstretch_armhf.deb"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,6 +14,10 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
@ -22,14 +27,8 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
superuser=$(ynh_app_setting_get --app=$app --key=superuser)
password=$(ynh_app_setting_get --app=$app --key=password)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
conf_dir=$(ynh_app_setting_get --app=$app --key=conf_dir)
port=$(ynh_app_setting_get --app=$app --key=port)
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -37,10 +36,9 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR AND CONFIG FILES
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="/etc/default/tvheadend"
ynh_backup --src_path="$final_path"
#=================================================
@ -49,7 +47,14 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/default/tvheadend"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for Tvheadend. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -5,12 +5,14 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
@ -24,7 +26,9 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
conf_dir=$(ynh_app_setting_get --app=$app --key=conf_dir)
port=$(ynh_app_setting_get --app=$app --key=port)
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
@ -37,6 +41,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
@ -65,9 +70,9 @@ fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP TVHEADEND SERVICE
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping Tvheadend service..." --weight=1
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop"
@ -109,9 +114,34 @@ then
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
# Update Tvheadend configuration file
if [ $change_path -eq 1 ]
then
ynh_script_progression --message="Updating Tvheadend configuration..." --weight=1
if [ "$path_url" = "/" ]
then
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
else
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
fi
fi
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# RELOAD NGINX
#=================================================
@ -119,14 +149,8 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# START TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Starting $app service..." --weight=1
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for Tvheadend" --last
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -5,18 +5,24 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
superuser=$YNH_APP_ARG_SUPERUSER
@ -30,7 +36,7 @@ app=$YNH_APP_INSTANCE_NAME
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/home/hts # Default path for Tvheadend deb package
test ! -e "$final_path" || ynh_die --message="The path $final_path already contains a folder"
test ! -e "$final_path" || ynh_die --message="This path $final_path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -62,9 +68,8 @@ ynh_app_setting_set --app=$app --key=stream_port --value=$stream_port
# Open ports
ynh_script_progression --message="Configuring firewall..." --weight=15
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $stream_port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $stream_port
#=================================================
# INSTALL DEPENDENCIES
@ -78,6 +83,14 @@ else
ynh_install_app_dependencies $pkg_dependencies_x86
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# DOWNLOAD TVHEADEND DEB PACKAGE
#=================================================
@ -93,7 +106,7 @@ else
tvheadend_deb_url="$tvheadend_deb_x86"
fi
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url"
ynh_exec_quiet wget -q -O $tvheadend_deb_dst $tvheadend_deb_url
#=================================================
# INSTALL TVHEADEND DEB PACKAGE
@ -131,18 +144,28 @@ else
fi
#=================================================
# NGINX CONFIGURATION
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
ynh_script_progression --message="Prevent Tvheadend being upgraded throught APT..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
apt-mark hold tvheadend
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $port $stream_port
yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $stream_port
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# SETUP SSOWAT
@ -158,21 +181,8 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
ynh_script_progression --message="Prevent Tvheadend being upgraded throught APT..." --weight=1
apt-mark hold tvheadend
#=================================================
# START TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Starting Tvheadend service..." --weight=1
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of Tvheadend completed, HTTP port is $port and HTSP port is $stream_port" --last
ynh_script_progression --message="Installation of $app completed, HTSP port is $stream_port" --last

View file

@ -5,6 +5,7 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -16,15 +17,25 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get --app=$app --key=port)
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
superuser=$(ynh_app_setting_get --app=$app --key=superuser)
password=$(ynh_app_setting_get --app=$app --key=password)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
#=================================================
# STOP AND DISABLE TVHEADEND SERVICE
#=================================================
@ -48,34 +59,13 @@ ynh_script_progression --message="Removing Tvheadend..." --weight=6
ynh_package_autopurge $app
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=3
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR AND CONFIG FILES
#=================================================
ynh_script_progression --message="Removing Tvheadend main directory and config files..." --weight=2
ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely (/home/hts folder)
## Use rm -r because ynh_secure_remove says that /home/hts is not an acceptable path to delete
rm -r $final_path
ynh_secure_remove --file="/etc/default/tvheadend"
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
@ -86,13 +76,16 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
ynh_remove_nginx_config
#=================================================
# CLOSE PORTS
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=3
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..." --weight=8
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
if yunohost firewall list | grep -q "\- $stream_port$"
then
@ -100,15 +93,25 @@ then
ynh_exec_warn_less yunohost firewall disallow TCP $stream_port
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
ynh_secure_remove --file="/etc/default/tvheadend"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated hts system user..." --weight=1
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=hts
deluser hts --remove-home
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of Tvheadend completed" --last
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -5,12 +5,18 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -36,25 +42,27 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
ynh_script_progression --message="Validating restoration parameters..." --weight=16
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD MODIFICATIONS
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# OPEN TVHEADEND PORTS
#=================================================
ynh_script_progression --message="Configuring firewall..." --weight=15
if yunohost firewall list | grep -q "\- $port$"
then
ynh_die --message="Port $port already open (and maybe used by another application)"
fi
if yunohost firewall list | grep -q "\- $stream_port$"
then
ynh_die --message="Port $stream_port already open (and maybe used by another application)"
fi
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $stream_port
#=================================================
@ -84,7 +92,7 @@ else
tvheadend_deb_url="$tvheadend_deb_x86"
fi
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url"
ynh_exec_quiet wget -q -O $tvheadend_deb_dst $tvheadend_deb_url
#=================================================
# INSTALL TVHEADEND DEB PACKAGE
@ -115,27 +123,28 @@ ynh_restore_file --origin_path="/etc/default/tvheadend"
ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE THE NGINX CONFIGURATION
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
ynh_script_progression --message="Restoring NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Prevent Tvheadend being upgraded throught APT..." --weight=1
apt-mark hold tvheadend
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $port $stream_port
yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $stream_port
#=================================================
# SETUP SSOWAT
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_permission_update --permission="main" --add="visitors"
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
@ -143,22 +152,8 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
ynh_script_progression --message="Prevent Tvheadend being upgraded throught APT..." --weight=1
apt-mark hold tvheadend
#=================================================
# START TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Starting Tvheadend service..." --weight=1
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of Tvheadend completed, HTTP port is $port and HTSP port is $stream_port" --last
ynh_script_progression --message="Restoration completed for $app, HTSP port is $stream_port" --last

View file

@ -5,6 +5,7 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -27,17 +28,20 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Tvheadend before upgrading (may take a while)..." --weight=4
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -48,14 +52,34 @@ ynh_abort_if_errors
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping Tvheadend service..." --weight=3
ynh_script_progression --message="Stopping a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# UPGRADE TVHEADEND DEB PACKAGE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
#=================================================
@ -85,7 +109,7 @@ then
tvheadend_deb_url="$tvheadend_deb_x86"
fi
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url"
ynh_exec_quiet wget -q -O $tvheadend_deb_dst $tvheadend_deb_url
#=================================================
# INSTALL TVHEADEND DEB PACKAGE
@ -116,36 +140,25 @@ then
fi
fi
#=================================================
# NGINX CONFIGURATION
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
if ! ynh_permission_exists --permission="main"; then
# Create the required permissions
ynh_permission_create --permission="main" --allowed="visitors"
fi
apt-mark hold tvheadend
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $port $stream_port
yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $stream_port
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# RELOAD NGINX
@ -154,19 +167,8 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
apt-mark hold tvheadend
#=================================================
# START TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Starting Tvheadend service..." --weight=1
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of Tvheadend completed, HTTP port is $port and HTSP port is $stream_port" --last
ynh_script_progression --message="Upgrade of $app completed, HTSP port is $stream_port" --last