Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[autopatch] Automatic patch attempt for helpers 2.1 #20

Open
wants to merge 1 commit into
base: testing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ userdoc = "https://tvheadend.org/projects/tvheadend/wiki"
code = "https://github.com/tvheadend/tvheadend"

[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64", "arm64", "armhf"]
multi_instance = false
ldap = "not_relevant"
Expand Down
4 changes: 2 additions & 2 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ _install_tvheadend_package() {
echo tvheadend tvheadend/last_notes note | debconf-set-selections

# Install the package
ynh_package_install \
_ynh_apt_install \
"$install_dir/tvheadend.deb"

chown -R "hts:video" "$data_dir"
Expand All @@ -27,7 +27,7 @@ _install_tvheadend_package() {
_uninstall_tvheadend_package() {
apt-mark unhold tvheadend

ynh_package_autopurge tvheadend
_ynh_apt autoremove --purge tvheadend

# Delete the system user created by the package
deluser hts --remove-home
Expand Down
21 changes: 6 additions & 15 deletions scripts/backup
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# 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

#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."

#=================================================
# BACKUP THE APP MAIN DIR
#=================================================

ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"

#=================================================
# BACKUP THE DATA DIR
#=================================================

### Only relevant if there is a "data_dir" resource for this app
ynh_backup --src_path="$data_dir" --is_big
ynh_backup "$data_dir"

#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================

ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"

#=================================================
# BACKUP VARIOUS FILES
#=================================================

ynh_backup --src_path="/etc/default/tvheadend"
ynh_backup "/etc/default/tvheadend"

#=================================================
# END OF SCRIPT
#=================================================

ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
30 changes: 10 additions & 20 deletions scripts/change_url
Original file line number Diff line number Diff line change
@@ -1,56 +1,46 @@
#!/bin/bash

#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."

ynh_systemd_action --service_name=$app --action="stop"
ynh_systemctl --service=$app --action="stop"

#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
ynh_script_progression "Updating NGINX web server configuration..."

ynh_change_url_nginx_config
ynh_config_change_url_nginx

#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# Update Tvheadend configuration file
if [ "$change_path" -eq 1 ]; then
# Update Tvheadend configuration file
ynh_script_progression --message="Updating Tvheadend configuration..." --weight=1
ynh_script_progression "Updating Tvheadend configuration..."
if [ "$path" = "/" ]; then
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
ynh_config_add --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
else
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
ynh_config_add --template="tvheadend" --destination="/etc/default/tvheadend"
fi
fi

#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."

# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start"
ynh_systemctl --service="$app" --action="start"

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"
31 changes: 12 additions & 19 deletions scripts/install
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

Expand All @@ -14,54 +8,53 @@ source /usr/share/yunohost/helpers
#=================================================

# Passwords are not saved by default.
ynh_app_setting_set --app="$app" --key=password --value="$password"
ynh_app_setting_set --key=password --value="$password"

#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Installing $app package..." --weight=1

chown -R "$app:www-data" "$install_dir"
ynh_script_progression "Installing $app package..."

#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
_install_tvheadend_package
# The deb install automatically create the hts system user

# Tvheadend automatically start after install
# we stop it before the configuration
ynh_systemd_action --service_name="$app" --action="stop"
ynh_systemctl --service="$app" --action="stop"

#=================================================
# MODIFY TVHEADEND CONFIG FILES
#=================================================
ynh_script_progression --message="Update configuration files..." --weight=1
ynh_script_progression "Update configuration files..."

# Copy and modify /etc/default/tvheadend
if [ "$path" = "/" ]; then
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
ynh_config_add --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
else
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
ynh_config_add --template="tvheadend" --destination="/etc/default/tvheadend"
fi

#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_script_progression "Adding system configurations related to $app..."

# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx

yunohost service add "$app" --description="TV streaming server and recorder" --needs_exposed_ports="$port_stream"

#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."

# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start"
ynh_systemctl --service="$app" --action="start"

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression --message="Installation of $app completed, HTSP port is $port_stream" --last
ynh_script_progression "Installation of $app completed, HTSP port is $port_stream"
28 changes: 11 additions & 17 deletions scripts/remove
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

Expand All @@ -16,39 +10,39 @@ source /usr/share/yunohost/helpers
#=================================================

# 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
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
ynh_script_progression "Removing "$app" service integration..."
yunohost service remove "$app"
fi

#=================================================
# STOP AND DISABLE TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Stopping Tvheadend service..." --weight=2
ynh_script_progression "Stopping Tvheadend service..."

ynh_systemd_action --service_name="$app" --action=stop
ynh_exec_quiet systemctl disable "$app" --quiet
ynh_exec_quiet systemctl daemon-reload
ynh_systemctl --service="$app" --action=stop
systemctl disable "$app" --quiet
systemctl daemon-reload

#=================================================
# UNHOLD TVHEADEND FROM APT
#=================================================
ynh_script_progression --message="Removing the $app apt package..." --weight=2
ynh_script_progression "Removing the $app apt package..."

_uninstall_tvheadend_package

#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
ynh_script_progression "Removing system configurations related to $app..."

# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx

ynh_secure_remove --file="/etc/default/tvheadend"
ynh_safe_rm "/etc/default/tvheadend"

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"
37 changes: 15 additions & 22 deletions scripts/restore
Original file line number Diff line number Diff line change
@@ -1,72 +1,65 @@
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# 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

#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1

ynh_restore_file --origin_path="$install_dir"
ynh_script_progression "Restoring the app main directory..."

chown -R "$app:www-data" "$install_dir"
ynh_restore "$install_dir"

#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Reinstalling $app package..." --weight=1
ynh_script_progression "Reinstalling $app package..."

_install_tvheadend_package
# The deb install automatically create the hts system user

# Tvheadend automatically start after install
# we stop it before the configuration
ynh_systemd_action --service_name="$app" --action="stop"
ynh_systemctl --service="$app" --action="stop"

#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_script_progression "Restoring the data directory..."

ynh_restore_file --origin_path="$data_dir" --not_mandatory
ynh_restore "$data_dir"

chown -R "hts:video" "$data_dir"

#=================================================
# RESTORE TVHEADEND CONFIG FILES
#=================================================
ynh_script_progression --message="Restoring Tvheadend main directory and config files..." --weight=1
ynh_script_progression "Restoring Tvheadend main directory and config files..."

ynh_restore_file --origin_path="/etc/default/tvheadend"
ynh_restore "/etc/default/tvheadend"

#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_script_progression "Restoring system configurations related to $app..."

ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"

yunohost service add "$app" --description="TV streaming server and recorder" --needs_exposed_ports="$port_stream"

#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."

ynh_systemd_action --service_name="$app" --action="start"
ynh_systemctl --service="$app" --action="start"

ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression --message="Restoration completed for $app, HTSP port is $port_stream" --last
ynh_script_progression "Restoration completed for $app, HTSP port is $port_stream"
Loading