mirror of
https://github.com/YunoHost-Apps/guacamole_ynh.git
synced 2024-09-03 19:16:03 +02:00
Apply template
This commit is contained in:
parent
3f6c64498d
commit
7d631f26a9
4 changed files with 75 additions and 176 deletions
|
@ -22,30 +22,16 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
# BACKUP THE SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app-guacd.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app-tomcat.service"
|
||||
|
||||
|
|
105
scripts/install
105
scripts/install
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||
ynh_script_progression --message="Stopping system tomcat..." --weight=1
|
||||
|
||||
# Guacamole depends on Apache Tomcat.
|
||||
# But installing Tomcat from the Debian repos automatically enables and starts it.
|
||||
|
@ -53,55 +53,12 @@ ynh_script_progression --message="Setting up source files..." --weight=3
|
|||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
setup_sources
|
||||
|
||||
#=================================================
|
||||
# FINISH SETTING UP DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up database files..." --weight=2
|
||||
|
||||
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_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_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"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# COMPILE GUACD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Compiling guacd..." --weight=30
|
||||
|
||||
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
|
||||
popd
|
||||
|
||||
|
||||
#=================================================
|
||||
# SETUP TOMCAT
|
||||
#=================================================
|
||||
|
||||
mkdir -p "/var/log/$app/tomcat/" "/var/log/$app/guacd/" "/var/log/$app/tomcat/"
|
||||
mkdir -p "$install_dir/etc/"
|
||||
ln -s -f "$install_dir/etc/tomcat9" "$install_dir/var/lib/tomcat9/conf"
|
||||
ln -s -f "/var/log/$app/tomcat/" "$install_dir/var/lib/tomcat9/logs"
|
||||
ln -s -f "/var/cache/$app-tomcat9" "$install_dir/var/lib/tomcat9/work"
|
||||
|
||||
#=================================================
|
||||
# CREATE LOG DIRS
|
||||
#=================================================
|
||||
|
||||
mkdir -p "/var/log/$app/tomcat/" "/var/log/$app/guacd/" "/var/log/$app/tomcat/"
|
||||
|
||||
#=================================================
|
||||
# ADD CONFIGURATIONS
|
||||
#=================================================
|
||||
|
@ -113,47 +70,59 @@ ynh_replace_string --match_string="8080" --replace_string="$port" --target_file=
|
|||
_set_permissions
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
# COMPILE GUACD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring systemd services..." --weight=1
|
||||
ynh_script_progression --message="Compiling guacd..." --weight=30
|
||||
|
||||
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
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# FINISH SETTING UP DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up database files..." --weight=2
|
||||
|
||||
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_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"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Create dedicated systemd configs
|
||||
ynh_add_systemd_config --service="$app-guacd" --template="guacd.service"
|
||||
ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
|
||||
yunohost service add "$app-guacd" --description="Guacamole server" --log="/var/log/$app/guacd.log"
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||
ynh_add_systemd_config --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"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICES IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating services in YunoHost..." --weight=1
|
||||
|
||||
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"
|
||||
# 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\.$'
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
||||
ynh_script_progression --message="Starting $app's systemd services..." --weight=1
|
||||
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# SETUP FAIL2BAN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
|
||||
|
||||
# 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\.$'
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -10,13 +10,9 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
if ynh_exec_warn_less yunohost service status $app-guacd >/dev/null; then
|
||||
yunohost service remove "$app-guacd"
|
||||
|
@ -25,41 +21,19 @@ if ynh_exec_warn_less yunohost service status $app-tomcat >/dev/null; then
|
|||
yunohost service remove "$app-tomcat"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config --service="$app-guacd"
|
||||
ynh_remove_systemd_config --service="$app-tomcat"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated Fail2Ban config
|
||||
ynh_remove_fail2ban_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
|
|
100
scripts/restore
100
scripts/restore
|
@ -11,45 +11,9 @@ source ../settings/scripts/_common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
# STOP TOMCAT
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username="$app-guacd"
|
||||
ynh_system_user_create --username="$app-tomcat"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
|
||||
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||
ynh_script_progression --message="Stopping system tomcat..." --weight=1
|
||||
|
||||
tomcat_enabled=""
|
||||
tomcat_active=""
|
||||
|
@ -72,6 +36,23 @@ if [ ! $tomcat_active ]; then
|
|||
systemctl stop tomcat9 --quiet
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username="$app-guacd"
|
||||
ynh_system_user_create --username="$app-tomcat"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
@ -89,44 +70,33 @@ ynh_restore_file --origin_path="/var/log/$app"
|
|||
_set_permissions
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/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_file --origin_path="/etc/systemd/system/$app-guacd.service"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-tomcat.service"
|
||||
systemctl enable "$app-guacd.service" --quiet
|
||||
systemctl enable "$app-tomcat.service" --quiet
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICES IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating services in YunoHost..." --weight=1
|
||||
|
||||
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"
|
||||
systemctl enable "$app-tomcat.service" --quiet
|
||||
yunohost service add "$app-tomcat" --description="Guacamole client" --log="/var/log/$app/tomcat.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
||||
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
# START SYSTEMD SERVICES
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
ynh_script_progression --message="Starting NGINX and $app's systemd services..." --weight=1
|
||||
|
||||
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_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue