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 #76

Open
wants to merge 2 commits 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
2 changes: 1 addition & 1 deletion ALL_README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# All available README files by language

- [Read the README in English](README.md)
- [Lee el README en español](README_es.md)
- [Lea el README en español](README_es.md)
- [Irakurri README euskaraz](README_eu.md)
- [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md)
Expand Down
3 changes: 2 additions & 1 deletion manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ admindoc = "https://airsonic.github.io/docs/"
code = "https://github.com/airsonic-advanced/airsonic-advanced"

[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true
ldap = true
Expand Down
14 changes: 1 addition & 13 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
#!/bin/bash

#=================================================
# COMMON VARIABLES
#=================================================

#=================================================
# PERSONAL HELPERS
#=================================================

#=================================================
# EXPERIMENTAL HELPERS
#=================================================

#=================================================
# FUTURE OFFICIAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
25 changes: 8 additions & 17 deletions scripts/backup
Original file line number Diff line number Diff line change
@@ -1,60 +1,51 @@
#!/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
#=================================================

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"

#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================

ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"

#=================================================
# BACKUP SYSTEMD
#=================================================

ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"

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

ynh_backup --src_path="/etc/default/$app"
ynh_backup "/etc/default/$app"

#=================================================
# 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,54 +1,44 @@
#!/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
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=3
ynh_script_progression "Configuring $app's systemd service..."

# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd

ynh_add_config --template="../conf/systemd-sysconfig" --destination="/etc/default/$app"
ynh_config_add --template="systemd-sysconfig" --destination="/etc/default/$app"

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

# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path="$install_dir/airsonic.log" --line_match="Started Application in"
ynh_systemctl --service=$app --action=start --log_path="$install_dir/airsonic.log" --wait_until="Started Application in"

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

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

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

if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
if ynh_in_ci_tests; then
sleep 60
fi

Expand All @@ -16,26 +10,25 @@ source /usr/share/yunohost/helpers
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=82
ynh_script_progression "Setting up source files..."

# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"

chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$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 | chmod -R o-rwx "$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"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
ynh_script_progression "Configuring NGINX web server..."

# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx

#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=3
ynh_script_progression "Adding multimedia directories..."

ynh_multimedia_build_main_dir
ynh_multimedia_addfolder --source_dir="/home/yunohost.app/$app/Podcasts" --dest_dir="share/Podcasts"
Expand All @@ -47,7 +40,7 @@ ynh_multimedia_addaccess $app
#=================================================
# ENABLE "TRANSCODE"
#=================================================
ynh_script_progression --message="Enabling transcode..." --weight=1
ynh_script_progression "Enabling transcode..."

### For details, see https://airsonic.github.io/docs/transcode/

Expand All @@ -68,36 +61,36 @@ chown $app $install_dir/transcode
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_script_progression "Adding $app's configuration..."

ynh_add_config --template="../conf/systemd-sysconfig" --destination="/etc/default/$app"
ynh_config_add --template="systemd-sysconfig" --destination="/etc/default/$app"

chmod 600 "/etc/default/$app"
chown $app:$app "/etc/default/$app"

# Copy configuration file of airsonic
ynh_add_config --template="../conf/airsonic.properties" --destination="$install_dir/airsonic.properties"
ynh_config_add --template="airsonic.properties" --destination="$install_dir/airsonic.properties"

chmod 600 "$install_dir/airsonic.properties"
chown $app:$app "$install_dir/airsonic.properties"

#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=3
ynh_script_progression "Configuring $app's systemd service..."

# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd

#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
ynh_script_progression --message="Setuping application with CURL..." --weight=1
ynh_script_progression "Setuping application with CURL..."

ynh_systemd_action --service_name=$app --action="start" --log_path="$install_dir/$app.log" --line_match="Started Application in"
ynh_systemctl --service=$app --action="start" --log_path="$install_dir/$app.log" --wait_until="Started Application in"

# Reload Nginx
ynh_systemd_action --service_name=nginx --action="reload"
ynh_systemctl --service=nginx --action="reload"

mailadmin=$(ynh_user_get_info --username=$admin --key=mail)

Expand All @@ -107,7 +100,7 @@ salt=$(ynh_string_random --length=8)
token=$(echo -n $passwordAdmin$salt | md5sum | awk '{print $1}')

# Installation with curl
ynh_script_progression --message="Finalizing installation..." --weight=6
ynh_script_progression "Finalizing installation..."

# This version number can be found here:
# https://airsonic.github.io/docs/api/
Expand All @@ -130,45 +123,43 @@ ynh_local_curl "/rest/createUser.view" "u=admin" "t=$token" "s=$salt" "username=
#=================================================
# USE MULTIMEDIA
#=================================================
ynh_script_progression --message="Using multimedia..." --weight=1
ynh_script_progression "Using multimedia..."

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

# Use multimedia folder
ynh_replace_string --match_string="INSERT INTO MUSIC_FOLDER VALUES(0,'/var/music','Music'" --replace_string="INSERT INTO MUSIC_FOLDER VALUES(0,'/home/yunohost.multimedia/share/Music','YunoHost Music'" --target_file="$install_dir/db/airsonic.script"
ynh_replace --match="INSERT INTO MUSIC_FOLDER VALUES(0,'/var/music','Music'" --replace="INSERT INTO MUSIC_FOLDER VALUES(0,'/home/yunohost.multimedia/share/Music','YunoHost Music'" --file="$install_dir/db/airsonic.script"

ynh_script_progression --message="Restarting a systemd service..." --weight=12
ynh_script_progression "Restarting a systemd service..."

# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="$install_dir/airsonic.log" --line_match="Started Application in"
ynh_systemctl --service=$app --action="start" --log_path="$install_dir/airsonic.log" --wait_until="Started Application in"

#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
ynh_script_progression "Configuring log rotation..."

# Use logrotate to manage application logfile(s)
ynh_use_logrotate $install_dir/$app.log
ynh_config_add_logrotate $install_dir/$app.log

#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
ynh_script_progression "Integrating service in YunoHost..."

yunohost service add $app --description="Airsonic daemon" --log="$install_dir/$app.log"

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

# Start a systemd service
ynh_systemd_action --service_name=$app --action="restart" --log_path="$install_dir/$app.log" --line_match="Started Application in"
ynh_systemctl --service=$app --action="restart" --log_path="$install_dir/$app.log" --wait_until="Started Application in"

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

ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"
20 changes: 7 additions & 13 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,25 +10,25 @@ 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
if ynh_hide_warnings yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
ynh_script_progression "Removing $app service integration..."
yunohost service remove $app
fi

# Remove the dedicated systemd config
ynh_remove_systemd_config
ynh_config_remove_systemd

# Remove the app-specific logrotate config
ynh_remove_logrotate
ynh_config_remove_logrotate

# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx

ynh_secure_remove --file="/etc/default/$app"
ynh_safe_rm "/etc/default/$app"

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

ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"
Loading