1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/guacamole_ynh.git synced 2024-09-03 19:16:03 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-30 23:30:15 +02:00 committed by Alexandre Aubin
parent 8b3bb95e29
commit a15616cf7f
9 changed files with 116 additions and 183 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~
*.sw[op]
.DS_Store

View file

@ -18,7 +18,8 @@ admindoc = "https://guacamole.apache.org/doc/gug/"
code = "https://github.com/apache/guacamole-server"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true

View file

@ -1,15 +1,11 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
guacamole_version="1.5.4"
#=================================================
# PERSONAL HELPERS
#=================================================
function setup_sources {
ynh_setup_source --source_id="server" --dest_dir="$install_dir/.guacd-src"
@ -45,13 +41,13 @@ function setup_sources {
ynh_setup_source --source_id="mariadb-java-client" --dest_dir="$install_dir/etc/guacamole/lib/"
ynh_secure_remove --file="$install_dir/downloads/"
ynh_safe_rm "$install_dir/downloads/"
}
function _set_permissions() {
# Set permissions to app files
chown -R "$app:$app" "$install_dir"
chmod -R g+rwX,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:$app" "$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 g+rwX,o-rwx "$install_dir"
setfacl -n -R -m "user:$app-guacd:rx" -m "default:user:$app-guacd:rx" "$install_dir"
setfacl -n -R -m "user:$app-tomcat:rx" -m "default:user:$app-tomcat:rx" "$install_dir"
@ -60,14 +56,6 @@ function _set_permissions() {
setfacl -n -R -m "user:$app-guacd:-" -m "default:user:$app-guacd:-" \
"$install_dir/var/lib/tomcat9/" "$install_dir/etc/guacamole/" "$install_dir/etc/tomcat9/"
chown -R "$app-guacd:$app-guacd" "/var/log/$app/guacd/"
chown -R "$app-tomcat:$app-tomcat" "/var/log/$app/tomcat/"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app-guacd:$app-guacd" "/var/log/$app/guacd/"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app-tomcat:$app-tomcat" "/var/log/$app/tomcat/"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,55 +1,46 @@
#!/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 SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app-guacd.service"
ynh_backup --src_path="/etc/systemd/system/$app-tomcat.service"
ynh_backup "/etc/systemd/system/$app-guacd.service"
ynh_backup "/etc/systemd/system/$app-tomcat.service"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/var/log/$app"
ynh_backup "/var/log/$app"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
ynh_mysql_dump_db > db.sql
#=================================================
# 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)."

View file

@ -1,30 +1,22 @@
#!/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 systemd services..." --weight=1
ynh_script_progression "Stopping systemd services..."
ynh_systemd_action --service_name="$app-guacd" --action="stop" --log_path="/var/log/$app/guacd.log"
ynh_systemd_action --service_name="$app-tomcat" --action="stop" --log_path="/var/log/$app/tomcat.log"
ynh_systemctl --service="$app-guacd" --action="stop" --log_path="/var/log/$app/guacd.log"
ynh_systemctl --service="$app-tomcat" --action="stop" --log_path="/var/log/$app/tomcat.log"
#=================================================
# 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
@ -33,7 +25,7 @@ ynh_change_url_nginx_config
#=================================================
if [ $change_path -eq 1 ]; then
ynh_script_progression --message="Moving Tomcat webbapp folder..." --weight=1
ynh_script_progression "Moving Tomcat webbapp folder..."
old_path_tomcat="$old_path"
if [ "$old_path_tomcat" == "/" -o -z "$old_path_tomcat" ]; then
@ -47,18 +39,16 @@ if [ $change_path -eq 1 ]; then
mv "$install_dir/var/lib/tomcat9/webapps/$old_path_tomcat" "$install_dir/var/lib/tomcat9/webapps/$new_path_tomcat"
fi
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICES
#=================================================
ynh_script_progression --message="Starting systemd services..." --weight=1
ynh_script_progression "Starting systemd services..."
ynh_systemd_action --service_name="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log"
ynh_systemd_action --service_name="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
ynh_systemctl --service="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log"
ynh_systemctl --service="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,18 +1,12 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Stopping system tomcat..." --weight=1
ynh_script_progression "Stopping system tomcat..."
# Guacamole depends on Apache Tomcat.
# But installing Tomcat from the Debian repos automatically enables and starts it.
@ -39,7 +33,7 @@ fi
#=================================================
# CREATE DEDICATED USERS
#=================================================
ynh_script_progression --message="Configuring system users..." --weight=1
ynh_script_progression "Configuring system users..."
# Create system users
ynh_system_user_create --username="$app-guacd" --groups="$app"
@ -48,7 +42,7 @@ ynh_system_user_create --username="$app-tomcat" --groups="$app"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCES
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=3
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
setup_sources
@ -63,68 +57,68 @@ ln -s -f "/var/cache/$app-tomcat9" "$install_dir/var/lib/tomcat9/work"
# ADD CONFIGURATIONS
#=================================================
ynh_add_config --template="guacamole.properties" --destination="$install_dir/etc/guacamole/guacamole.properties"
ynh_config_add --template="guacamole.properties" --destination="$install_dir/etc/guacamole/guacamole.properties"
ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$install_dir/etc/tomcat9/server.xml"
ynh_replace --match="8080" --replace="$port" --file="$install_dir/etc/tomcat9/server.xml"
_set_permissions
#=================================================
# COMPILE GUACD
#=================================================
ynh_script_progression --message="Compiling guacd..." --weight=30
ynh_script_progression "Compiling guacd..."
pushd "$install_dir/.guacd-src"
LDFLAGS="-lrt" ./configure --enable-allow-freerdp-snapshots --prefix="$install_dir" --datadir="$install_dir" --with-freerdp-plugin-dir="$install_dir/lib/x86_64-linux-gnu/freerdp2"
ynh_exec_warn_less make -j $(nproc)
ynh_exec_warn_less make install
ynh_hide_warnings make -j $(nproc)
ynh_hide_warnings make install
popd
#=================================================
# FINISH SETTING UP DATABASE
#=================================================
ynh_script_progression --message="Setting up database files..." --weight=2
ynh_script_progression "Setting up database files..."
ynh_replace_string --match_string="guacadmin" --replace_string="$admin" -f "$install_dir/etc/guacamole/extensions/mysql-schema/002-create-admin-user.sql"
ynh_replace_string --match_string="CA458A7D494E3BE824F5E1E175A1556C0F8EEF2C2D7DF3633BEC4A29C4411960" --replace_string="$(hexdump -n 32 -e '4/4 "%08X"' /dev/urandom)" -f "$install_dir/etc/guacamole/extensions/mysql-schema/002-create-admin-user.sql"
ynh_replace_string --match_string="FE24ADC5E11E2B25288D1704ABE67A79E342ECC26064CE69C5B3177795A82264" --replace_string="$(hexdump -n 32 -e '4/4 "%08X"' /dev/urandom)" -f "$install_dir/etc/guacamole/extensions/mysql-schema/002-create-admin-user.sql"
ynh_replace --match="guacadmin" --replace="$admin" -f "$install_dir/etc/guacamole/extensions/mysql-schema/002-create-admin-user.sql"
ynh_replace --match="CA458A7D494E3BE824F5E1E175A1556C0F8EEF2C2D7DF3633BEC4A29C4411960" --replace="$(hexdump -n 32 -e '4/4 "%08X"' /dev/urandom)" -f "$install_dir/etc/guacamole/extensions/mysql-schema/002-create-admin-user.sql"
ynh_replace --match="FE24ADC5E11E2B25288D1704ABE67A79E342ECC26064CE69C5B3177795A82264" --replace="$(hexdump -n 32 -e '4/4 "%08X"' /dev/urandom)" -f "$install_dir/etc/guacamole/extensions/mysql-schema/002-create-admin-user.sql"
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/etc/guacamole/extensions/mysql-schema/001-create-schema.sql"
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/etc/guacamole/extensions/mysql-schema/002-create-admin-user.sql"
ynh_secure_remove --file="$install_dir/etc/guacamole/extensions/mysql-schema"
ynh_mysql_db_shell < "$install_dir/etc/guacamole/extensions/mysql-schema/001-create-schema.sql"
ynh_mysql_db_shell < "$install_dir/etc/guacamole/extensions/mysql-schema/002-create-admin-user.sql"
ynh_safe_rm "$install_dir/etc/guacamole/extensions/mysql-schema"
#=================================================
# 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
# Create dedicated systemd configs
ynh_add_systemd_config --service="$app-guacd" --template="guacd.service"
ynh_config_add_systemd --service="$app-guacd" --template="guacd.service"
yunohost service add "$app-guacd" --description="Guacamole server" --log="/var/log/$app/guacd.log"
ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
ynh_config_add_systemd --service="$app-tomcat" --template="tomcat.service"
yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/log/$app/tomcat.log"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/tomcat/catalina.out" --specific_user="$app-tomcat/$app-tomcat"
ynh_config_add_logrotate "/var/log/$app/tomcat/catalina.out"
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/syslog" --failregex='o.a.g.r.auth.AuthenticationService - Authentication attempt from <HOST> for user "[^"]*" failed\.$'
ynh_config_add_fail2ban --logpath="/var/log/syslog" --failregex='o.a.g.r.auth.AuthenticationService - Authentication attempt from <HOST> for user "[^"]*" failed\.$'
#=================================================
# START SYSTEMD SERVICES
#=================================================
ynh_script_progression --message="Starting $app's systemd services..." --weight=1
ynh_script_progression "Starting $app's systemd services..."
# Start systemd services
ynh_systemd_action --service_name="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log"
ynh_systemd_action --service_name="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
ynh_systemctl --service="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log"
ynh_systemctl --service="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,52 +1,44 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
ynh_script_progression "Removing system configurations related to $app..."
if ynh_exec_warn_less yunohost service status $app-guacd >/dev/null; then
if ynh_hide_warnings yunohost service status $app-guacd >/dev/null; then
yunohost service remove "$app-guacd"
fi
if ynh_exec_warn_less yunohost service status $app-tomcat >/dev/null; then
if ynh_hide_warnings yunohost service status $app-tomcat >/dev/null; then
yunohost service remove "$app-tomcat"
fi
# Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-guacd"
ynh_remove_systemd_config --service="$app-tomcat"
ynh_config_remove_systemd"$app-guacd"
ynh_config_remove_systemd"$app-tomcat"
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
# Remove the app-specific logrotate config
ynh_remove_logrotate
ynh_config_remove_logrotate
# Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config
ynh_config_remove_fail2ban
#=================================================
# REMOVE VARIOUS FILES
#=================================================
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USERS
#=================================================
ynh_script_progression --message="Removing the dedicated system users..." --weight=1
ynh_script_progression "Removing the dedicated system users..."
# Delete a system user
ynh_system_user_delete --username="$app-guacd"
@ -56,4 +48,4 @@ ynh_system_user_delete --username="$app-tomcat"
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/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
@ -13,7 +7,7 @@ source /usr/share/yunohost/helpers
#=================================================
# STOP TOMCAT
#=================================================
ynh_script_progression --message="Stopping system tomcat..." --weight=1
ynh_script_progression "Stopping system tomcat..."
tomcat_enabled=""
tomcat_active=""
@ -36,15 +30,14 @@ fi
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$install_dir"
chown -R "$app:www-data" "$install_dir"
ynh_script_progression "Restoring the app main directory..."
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"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
ynh_script_progression "Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username="$app-guacd"
@ -53,52 +46,52 @@ ynh_system_user_create --username="$app-tomcat"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
ynh_script_progression "Restoring the MySQL database..."
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
ynh_mysql_db_shell < ./db.sql
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_script_progression "Restoring various files..."
ynh_restore_file --origin_path="/var/log/$app"
ynh_restore "/var/log/$app"
_set_permissions
#=================================================
# 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"
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
ynh_restore "/etc/fail2ban/jail.d/$app.conf"
ynh_restore "/etc/fail2ban/filter.d/$app.conf"
ynh_systemctl --action=restart --service=fail2ban
ynh_restore_file --origin_path="/etc/systemd/system/$app-guacd.service"
ynh_restore "/etc/systemd/system/$app-guacd.service"
systemctl enable "$app-guacd.service" --quiet
yunohost service add "$app-guacd" --description="Guacamole server" --log="/var/log/$app/guacd.log"
ynh_restore_file --origin_path="/etc/systemd/system/$app-tomcat.service"
ynh_restore "/etc/systemd/system/$app-tomcat.service"
systemctl enable "$app-tomcat.service" --quiet
yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/log/$app/tomcat.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"
#=================================================
# START SYSTEMD SERVICES
#=================================================
ynh_script_progression --message="Starting NGINX and $app's systemd services..." --weight=1
ynh_script_progression "Starting NGINX and $app's systemd services..."
ynh_systemd_action --service_name="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log"
ynh_systemd_action --service_name="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
ynh_systemctl --service="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log"
ynh_systemctl --service="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
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" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -1,34 +1,20 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICES
#=================================================
ynh_script_progression --message="Stopping systemd services..." --weight=1
ynh_script_progression "Stopping systemd services..."
ynh_systemd_action --service_name="$app-guacd" --action="stop" --log_path="/var/log/$app/guacd.log"
ynh_systemd_action --service_name="$app-tomcat" --action="stop" --log_path="/var/log/$app/tomcat.log"
ynh_systemctl --service="$app-guacd" --action="stop" --log_path="/var/log/$app/guacd.log"
ynh_systemctl --service="$app-tomcat" --action="stop" --log_path="/var/log/$app/tomcat.log"
#=================================================
# CREATE DEDICATED USERS
#=================================================
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
#REMOVEME? ynh_script_progression "Making sure dedicated system user exists..."
# Create dedicated users (if not existing)
ynh_system_user_create --username="$app-guacd"
@ -38,9 +24,10 @@ ynh_system_user_create --username="$app-tomcat"
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then
ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
setup_sources
@ -49,15 +36,15 @@ fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
ynh_script_progression "Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_script_progression "Upgrading dependencies..."
# Guacamole depends on Apache Tomcat.
# But installing Tomcat from the Debian repos automatically enables and starts it.
@ -81,17 +68,15 @@ if [ ! $tomcat_active ]; then
systemctl stop tomcat9 --quiet
fi
#=================================================
# SPECIFIC UPGRADE
#=================================================
# COMPILE GUACD
#=================================================
ynh_script_progression --message="Compiling guacd..." --weight=30
ynh_script_progression "Compiling guacd..."
pushd "$install_dir/.guacd-src"
LDFLAGS="-lrt" ./configure --enable-allow-freerdp-snapshots --prefix="$install_dir" --datadir="$install_dir" --with-freerdp-plugin-dir="$install_dir/lib/x86_64-linux-gnu/freerdp2"
ynh_exec_warn_less env LDFLAGS="-lrt" make
ynh_exec_warn_less env LDFLAGS="-lrt" make install
ynh_hide_warnings env LDFLAGS="-lrt" make
ynh_hide_warnings env LDFLAGS="-lrt" make install
popd
#=================================================
@ -113,21 +98,19 @@ mkdir -p "/var/log/$app/tomcat/" "/var/log/$app/guacd/" "/var/log/$app/tomcat/"
# UPDATE CONFIG FILES
#=================================================
ynh_add_config --template="guacamole.properties" --destination="$install_dir/etc/guacamole/guacamole.properties"
ynh_config_add --template="guacamole.properties" --destination="$install_dir/etc/guacamole/guacamole.properties"
ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$install_dir/etc/tomcat9/server.xml"
ynh_replace --match="8080" --replace="$port" --file="$install_dir/etc/tomcat9/server.xml"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_script_progression "Upgrading systemd configuration..."
# Create dedicated systemd configs
ynh_add_systemd_config --service="$app-guacd" --template="guacd.service"
ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
ynh_config_add_systemd --service="$app-guacd" --template="guacd.service"
ynh_config_add_systemd --service="$app-tomcat" --template="tomcat.service"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
@ -137,15 +120,15 @@ _set_permissions
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
ynh_script_progression "Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/tomcat/catalina.out" --non-append --specific_user="$app-tomcat/$app-tomcat"
ynh_config_add_logrotate "/var/log/$app/tomcat/catalina.out"
#=================================================
# INTEGRATE SERVICES IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating services in YunoHost..." --weight=1
ynh_script_progression "Integrating services in YunoHost..."
yunohost service add "$app-guacd" --description="Guacamole server" --log="/var/log/$app/guacd.log"
yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/log/$app/tomcat.log"
@ -153,21 +136,21 @@ yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/
#=================================================
# START SYSTEMD SERVICES
#=================================================
ynh_script_progression --message="Starting systemd services..." --weight=1
ynh_script_progression "Starting systemd services..."
ynh_systemd_action --service_name="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log"
ynh_systemd_action --service_name="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
ynh_systemctl --service="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log"
ynh_systemctl --service="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
#=================================================
# UPGRADE FAIL2BAN
#=================================================
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
ynh_script_progression "Reconfiguring Fail2Ban..."
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/syslog" --failregex='o.a.g.r.auth.AuthenticationService - Authentication attempt from <HOST> for user "[^"]*" failed\.$'
ynh_config_add_fail2ban --logpath="/var/log/syslog" --failregex='o.a.g.r.auth.AuthenticationService - Authentication attempt from <HOST> for user "[^"]*" failed\.$'
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"