1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/guacamole_ynh.git synced 2024-09-03 19:16:03 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 13:15:38 +02:00 committed by GitHub
commit 19d61d26fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 113 additions and 200 deletions

1
.gitignore vendored
View file

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

View file

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

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
if [ "$YNH_DEBIAN_VERSION" == "bullseye" ] ; then if [ "$YNH_DEBIAN_VERSION" == "bullseye" ] ; then
@ -10,10 +10,6 @@ elif [ "$YNH_DEBIAN_VERSION" == "bookworm" ] ; then
tomcat_version="tomcat10" tomcat_version="tomcat10"
fi fi
#=================================================
# PERSONAL HELPERS
#=================================================
function setup_sources { function setup_sources {
ynh_setup_source --source_id="server" --dest_dir="$install_dir/.guacd-src" ynh_setup_source --source_id="server" --dest_dir="$install_dir/.guacd-src"
@ -53,13 +49,13 @@ function setup_sources {
ynh_setup_source --source_id="mariadb-java-client" --dest_dir="$install_dir/etc/guacamole/lib/" 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() { function _set_permissions() {
# Set permissions to app files # Set permissions to app files
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 | 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 | 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-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" setfacl -n -R -m "user:$app-tomcat:rx" -m "default:user:$app-tomcat:rx" "$install_dir"
@ -68,6 +64,6 @@ function _set_permissions() {
setfacl -n -R -m "user:$app-guacd:-" -m "default:user:$app-guacd:-" \ setfacl -n -R -m "user:$app-guacd:-" -m "default:user:$app-guacd:-" \
"$install_dir/var/lib/$tomcat_version/" "$install_dir/etc/guacamole/" "$install_dir/etc/$tomcat_version/" "$install_dir/var/lib/$tomcat_version/" "$install_dir/etc/guacamole/" "$install_dir/etc/$tomcat_version/"
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-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-tomcat:$app-tomcat" "/var/log/$app/tomcat/"
} }

View file

@ -1,55 +1,46 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$install_dir" ynh_backup "$install_dir"
#================================================= #=================================================
# BACKUP THE SYSTEM CONFIGURATION # 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 "/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.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 "/etc/systemd/system/$app-guacd.service"
ynh_backup --src_path="/etc/systemd/system/$app-tomcat.service" ynh_backup "/etc/systemd/system/$app-tomcat.service"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/var/log/$app" ynh_backup "/var/log/$app"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # 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 # 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 #!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # 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_systemctl --service="$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-tomcat" --action="stop" --log_path="/var/log/$app/tomcat.log"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # 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 # SPECIFIC MODIFICATIONS
@ -33,7 +25,7 @@ ynh_change_url_nginx_config
#================================================= #=================================================
if [ $change_path -eq 1 ]; then 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" old_path_tomcat="$old_path"
if [ "$old_path_tomcat" == "/" -o -z "$old_path_tomcat" ]; then 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/$tomcat_version/webapps/$old_path_tomcat" "$install_dir/var/lib/$tomcat_version/webapps/$new_path_tomcat" mv "$install_dir/var/lib/$tomcat_version/webapps/$old_path_tomcat" "$install_dir/var/lib/$tomcat_version/webapps/$new_path_tomcat"
fi fi
#=================================================
# GENERIC FINALISATION
#================================================= #=================================================
# START SYSTEMD SERVICES # 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_systemctl --service="$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-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
#================================================= #=================================================
# END OF SCRIPT # 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 #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Stopping system tomcat..." --weight=1 ynh_script_progression "Stopping system tomcat..."
# Guacamole depends on Apache Tomcat. # Guacamole depends on Apache Tomcat.
# But installing Tomcat from the Debian repos automatically enables and starts it. # But installing Tomcat from the Debian repos automatically enables and starts it.
@ -27,18 +21,16 @@ fi
#================================================= #=================================================
# CREATE DEDICATED USERS # 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" ynh_system_user_create --username="$app-guacd" --groups="$app"
ynh_system_user_create --username="$app-tomcat" --groups="$app" ynh_system_user_create --username="$app-tomcat" --groups="$app"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCES # 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 setup_sources
mkdir -p "/var/log/$app/tomcat/" "/var/log/$app/guacd/" "/var/log/$app/tomcat/" mkdir -p "/var/log/$app/tomcat/" "/var/log/$app/guacd/" "/var/log/$app/tomcat/"
@ -51,68 +43,63 @@ ln -s -f "/var/cache/$app-$tomcat_version" "$install_dir/var/lib/$tomcat_version
# ADD CONFIGURATIONS # 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/$tomcat_version/server.xml" ynh_replace --match="8080" --replace="$port" --file="$install_dir/etc/tomcat9/server.xml"
_set_permissions _set_permissions
#================================================= #=================================================
# COMPILE GUACD # COMPILE GUACD
#================================================= #=================================================
ynh_script_progression --message="Compiling guacd..." --weight=30 ynh_script_progression "Compiling guacd..."
pushd "$install_dir/.guacd-src" 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" 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_hide_warnings make -j $(nproc)
ynh_exec_warn_less make install ynh_hide_warnings make install
popd popd
#================================================= #=================================================
# FINISH SETTING UP DATABASE # 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 --match="guacadmin" --replace="$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 --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_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="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_db_shell < "$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_mysql_db_shell < "$install_dir/etc/guacamole/extensions/mysql-schema/002-create-admin-user.sql"
ynh_secure_remove --file="$install_dir/etc/guacamole/extensions/mysql-schema" ynh_safe_rm "$install_dir/etc/guacamole/extensions/mysql-schema"
#================================================= #=================================================
# SYSTEM CONFIGURATION # 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_config_add_nginx
ynh_add_nginx_config
# Create dedicated systemd configs ynh_config_add_systemd --service="$app-guacd" --template="guacd.service"
ynh_add_systemd_config --service="$app-guacd" --template="guacd.service"
yunohost service add "$app-guacd" --description="Guacamole server" --log="/var/log/$app/guacd.log" 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" yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/log/$app/tomcat.log"
# Use logrotate to manage application logfile(s) ynh_config_add_logrotate "/var/log/$app/tomcat/catalina.out"
ynh_use_logrotate --logfile="/var/log/$app/tomcat/catalina.out" --specific_user="$app-tomcat/$app-tomcat"
# Create a dedicated Fail2Ban config ynh_config_add_fail2ban --logpath="/var/log/syslog" --failregex='o.a.g.r.auth.AuthenticationService - Authentication attempt from <HOST> for user "[^"]*" failed\.$'
ynh_add_fail2ban_config --logpath="/var/log/syslog" --failregex='o.a.g.r.auth.AuthenticationService - Authentication attempt from <HOST> for user "[^"]*" failed\.$'
#================================================= #=================================================
# START SYSTEMD SERVICES # 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_systemctl --service="$app-guacd" --action="start" --log_path="/var/log/$app/guacd.log"
ynh_systemd_action --service_name="$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="$app-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -1,53 +1,34 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # 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" yunohost service remove "$app-guacd"
fi 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" yunohost service remove "$app-tomcat"
fi fi
# Remove the dedicated systemd config ynh_config_remove_systemd"$app-guacd"
ynh_remove_systemd_config --service="$app-guacd" ynh_config_remove_systemd"$app-tomcat"
ynh_remove_systemd_config --service="$app-tomcat"
# Remove the dedicated NGINX config ynh_config_remove_nginx
ynh_remove_nginx_config
# Remove the app-specific logrotate config ynh_config_remove_logrotate
ynh_remove_logrotate
# Remove the dedicated Fail2Ban config ynh_config_remove_fail2ban
ynh_remove_fail2ban_config
#=================================================
# REMOVE VARIOUS FILES
#=================================================
# Remove the log files
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USERS # 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" ynh_system_user_delete --username="$app-guacd"
ynh_system_user_delete --username="$app-tomcat" ynh_system_user_delete --username="$app-tomcat"
@ -55,4 +36,4 @@ ynh_system_user_delete --username="$app-tomcat"
# END OF SCRIPT # 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 #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,7 +7,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# STOP TOMCAT # STOP TOMCAT
#================================================= #=================================================
ynh_script_progression --message="Stopping system tomcat..." --weight=1 ynh_script_progression "Stopping system tomcat..."
if systemctl is-enabled $tomcat_version --quiet 2>/dev/null; then if systemctl is-enabled $tomcat_version --quiet 2>/dev/null; then
systemctl disable $tomcat_version --quiet systemctl disable $tomcat_version --quiet
@ -25,15 +19,14 @@ fi
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
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"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # 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) # Create the dedicated user (if not existing)
ynh_system_user_create --username="$app-guacd" ynh_system_user_create --username="$app-guacd"
@ -42,52 +35,52 @@ ynh_system_user_create --username="$app-tomcat"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # 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 # 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 _set_permissions
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # 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 "/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" ynh_restore "/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban 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 systemctl enable "$app-guacd.service" --quiet
yunohost service add "$app-guacd" --description="Guacamole server" --log="/var/log/$app/guacd.log" 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 systemctl enable "$app-tomcat.service" --quiet
yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/log/$app/tomcat.log" 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 # 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_systemctl --service="$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-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 # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -1,63 +1,41 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# STOP SYSTEMD SERVICES # 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_systemctl --service="$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-tomcat" --action="stop" --log_path="/var/log/$app/tomcat.log"
#================================================= #=================================================
# CREATE DEDICATED USERS # CREATE DEDICATED USERS
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create dedicated users (if not existing)
ynh_system_user_create --username="$app-guacd" ynh_system_user_create --username="$app-guacd"
ynh_system_user_create --username="$app-tomcat" ynh_system_user_create --username="$app-tomcat"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression "Upgrading source files..."
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
setup_sources setup_sources
fi
#================================================= #=================================================
# NGINX CONFIGURATION # 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_config_add_nginx
ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_script_progression "Upgrading dependencies..."
# Guacamole depends on Apache Tomcat. # Guacamole depends on Apache Tomcat.
# But installing Tomcat from the Debian repos automatically enables and starts it. # But installing Tomcat from the Debian repos automatically enables and starts it.
@ -69,17 +47,15 @@ if systemctl is-active $tomcat_version --quiet 2>/dev/null; then
systemctl stop $tomcat_version --quiet systemctl stop $tomcat_version --quiet
fi fi
#=================================================
# SPECIFIC UPGRADE
#================================================= #=================================================
# COMPILE GUACD # COMPILE GUACD
#================================================= #=================================================
ynh_script_progression --message="Compiling guacd..." --weight=30 ynh_script_progression "Compiling guacd..."
pushd "$install_dir/.guacd-src" 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" 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_hide_warnings env LDFLAGS="-lrt" make
ynh_exec_warn_less env LDFLAGS="-lrt" make install ynh_hide_warnings env LDFLAGS="-lrt" make install
popd popd
#================================================= #=================================================
@ -101,21 +77,18 @@ mkdir -p "/var/log/$app/tomcat/" "/var/log/$app/guacd/" "/var/log/$app/tomcat/"
# UPDATE CONFIG FILES # 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/$tomcat_version/server.xml" ynh_replace --match="8080" --replace="$port" --file="$install_dir/etc/tomcat9/server.xml"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_script_progression "Upgrading systemd configuration..."
# Create dedicated systemd configs ynh_config_add_systemd --service="$app-guacd" --template="guacd.service"
ynh_add_systemd_config --service="$app-guacd" --template="guacd.service" ynh_config_add_systemd --service="$app-tomcat" --template="tomcat.service"
ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
@ -125,15 +98,15 @@ _set_permissions
#================================================= #=================================================
# SETUP LOGROTATE # 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) # 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 # 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-guacd" --description="Guacamole server" --log="/var/log/$app/guacd.log"
yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/log/$app/tomcat.log" yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/log/$app/tomcat.log"
@ -141,21 +114,21 @@ yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/
#================================================= #=================================================
# START SYSTEMD SERVICES # 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_systemctl --service="$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-tomcat" --action="start" --log_path="/var/log/$app/tomcat.log"
#================================================= #=================================================
# UPGRADE FAIL2BAN # UPGRADE FAIL2BAN
#================================================= #=================================================
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1 ynh_script_progression "Reconfiguring Fail2Ban..."
# Create a dedicated Fail2Ban config # 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 # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"