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

Apply last example_ynh (#11)

* Apply last example_ynh

* Fix restore
This commit is contained in:
yalh76 2021-08-06 13:44:33 +02:00 committed by GitHub
parent 5db2e629e9
commit 8b73a43154
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 92 additions and 87 deletions

View file

@ -1,14 +1,9 @@
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/path" (PATH) path="/path"
admin="john" (USER) admin="john"
is_public=0 (PUBLIC|public=1|private=0) is_public=0
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -17,7 +12,6 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
upgrade=0 from_commit=CommitHash
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0 port_already_use=0
@ -29,4 +23,3 @@ Notification=none
; commit=CommitHash ; commit=CommitHash
name=Name and date of the commit. name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1& manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&

0
doc/.gitkeep Normal file
View file

3
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,3 @@
## Configuration
The user that is configured as admin during install will have access to admin settings in the settings menu of the app (under the user menu). Configuration files are in `/opt/yunohost/guacamole/etc/guacamole` (for the first install).

3
doc/DISCLAIMER_fr.md Normal file
View file

@ -0,0 +1,3 @@
## Configuration
L'utilisateur choisi comme admin durant le processus d'installation aura accès au paramétres d'administration dans le menu de configuration de l'application (sous le menu utilisateur). Le fichiers de configuration sont dans `/opt/yunohost/guacamole/etc/guacamole` (pour la première installation).

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View file

@ -6,8 +6,14 @@
"en": "Clientless remote desktop gateway. It supports standard protocols like VNC, RDP, and SSH.", "en": "Clientless remote desktop gateway. It supports standard protocols like VNC, RDP, and SSH.",
"fr": "Service de bureau à distance sans client. Fonctionne avec des protocoles standard comme VNC, RDP, et SSH." "fr": "Service de bureau à distance sans client. Fonctionne avec des protocoles standard comme VNC, RDP, et SSH."
}, },
"version": "1.3.0~ynh4", "version": "1.3.0~ynh5",
"url": "https://guacamole.apache.org/", "url": "https://guacamole.apache.org/",
"upstream": {
"license": "Apache-2.0",
"website": "https://guacamole.apache.org/",
"admindoc": "https://guacamole.apache.org/doc/gug/",
"code": "https://github.com/search?utf8=%E2%9C%93&q=repo%3Aapache%2Fguacamole-server+repo%3Aapache%2Fguacamole-client+repo%3Aapache%2Fguacamole-website&type=Repositories&ref=searchresults"
},
"license": "Apache-2.0", "license": "Apache-2.0",
"maintainer": { "maintainer": {
"name": "Jules Bertholet", "name": "Jules Bertholet",
@ -31,10 +37,6 @@
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"ask": {
"en": "Choose a path for Guacamole",
"fr": "Choisissez un chemin pour Guacamole"
},
"example": "/guacamole", "example": "/guacamole",
"default": "/guacamole" "default": "/guacamole"
}, },

View file

@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
@ -52,12 +52,14 @@ ynh_abort_if_errors
#================================================= #=================================================
change_domain=0 change_domain=0
if [ "$old_domain" != "$new_domain" ]; then if [ "$old_domain" != "$new_domain" ]
then
change_domain=1 change_domain=1
fi fi
change_path=0 change_path=0
if [ "$old_path" != "$new_path" ]; then if [ "$old_path" != "$new_path" ]
then
change_path=1 change_path=1
fi fi
@ -79,7 +81,8 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file # Change the path in the NGINX config file
if [ $change_path -eq 1 ]; then if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified # Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path" ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper # Set global variables for NGINX helper
@ -90,7 +93,8 @@ if [ $change_path -eq 1 ]; then
fi fi
# Change the domain for NGINX # Change the domain for NGINX
if [ $change_domain -eq 1 ]; then if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path" ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf

View file

@ -92,6 +92,15 @@ if [ ! $tomcat_active ]; then
systemctl stop tomcat9 --quiet systemctl stop tomcat9 --quiet
fi fi
#=================================================
# CREATE DEDICATED USERS
#=================================================
ynh_script_progression --message="Configuring system users..." --weight=1
# Create system users
ynh_system_user_create --username="$app-guacd"
ynh_system_user_create --username="$app-tomcat"
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
@ -166,15 +175,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USERS
#=================================================
ynh_script_progression --message="Configuring system users..." --weight=1
# Create system users
ynh_system_user_create --username="$app-guacd"
ynh_system_user_create --username="$app-tomcat"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
@ -202,15 +202,6 @@ ln -s -f "/var/cache/$app-tomcat9" "$final_path/var/lib/tomcat9/work"
#================================================= #=================================================
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/"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring systemd services..." --weight=1
# Create dedicated systemd configs
ynh_add_systemd_config --service="$app-guacd" --template="guacd.service" -v guacd_port
ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
#================================================= #=================================================
# ADD CONFIGURATIONS # ADD CONFIGURATIONS
#================================================= #=================================================
@ -219,6 +210,15 @@ ynh_add_config --template="guacamole.properties" --destination="$final_path/etc/
ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$final_path/etc/tomcat9/server.xml" ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$final_path/etc/tomcat9/server.xml"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring systemd services..." --weight=1
# Create dedicated systemd configs
ynh_add_systemd_config --service="$app-guacd" --template="guacd.service"
ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -90,7 +90,7 @@ ynh_remove_logrotate
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing Fail2ban configuration..." --weight=1 ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
# Remove the dedicated Fail2Ban config # Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
@ -102,7 +102,7 @@ ynh_remove_fail2ban_config
#================================================= #=================================================
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app/" ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -48,16 +48,10 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # 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" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
@ -68,11 +62,23 @@ ynh_system_user_create --username="$app-guacd"
ynh_system_user_create --username="$app-tomcat" ynh_system_user_create --username="$app-tomcat"
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="/var/log/$app" ynh_restore_file --origin_path="$final_path"
#=================================================
# 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 # REINSTALL DEPENDENCIES
#================================================= #=================================================
@ -108,23 +114,10 @@ chown -R root:root $final_path
chmod -R o-rwx $final_path chmod -R o-rwx $final_path
setfacl -n -R -m user:$app-guacd:rx -m default:user:$app-guacd:rx $final_path setfacl -n -R -m user:$app-guacd:rx -m default:user:$app-guacd:rx $final_path
setfacl -n -R -m user:$app-tomcat:rx -m default:user:$app-tomcat:rx $final_path setfacl -n -R -m user:$app-tomcat:rx -m default:user:$app-tomcat:rx $final_path
chown -R $app-guacd:$app-guacd "/var/log/$app/guacd/"
chown -R $app-tomcat:$app-tomcat "/var/log/$app/tomcat/"
chown -R root:$app-tomcat "$final_path/etc/tomcat9/" "$final_path/etc/guacamole/" chown -R root:$app-tomcat "$final_path/etc/tomcat9/" "$final_path/etc/guacamole/"
chown -R "$app-tomcat":"$app-tomcat" "$final_path/var/lib/tomcat9/webapps" chown -R "$app-tomcat":"$app-tomcat" "$final_path/var/lib/tomcat9/webapps"
setfacl -n -R -m user:$app-guacd:- -m default:user:$app-guacd:- "$final_path/var/lib/tomcat9/" "$final_path/etc/guacamole/" "$final_path/etc/tomcat9/" setfacl -n -R -m user:$app-guacd:- -m default:user:$app-guacd:- "$final_path/var/lib/tomcat9/" "$final_path/etc/guacamole/" "$final_path/etc/tomcat9/"
#=================================================
# 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
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
@ -134,6 +127,15 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/var/log/$app"
chown -R $app-guacd:$app-guacd "/var/log/$app/guacd/"
chown -R $app-tomcat:$app-tomcat "/var/log/$app/tomcat/"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
@ -163,6 +165,7 @@ ynh_systemd_action --service_name="$app-tomcat" --action="start" --log_path="/va
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"

View file

@ -26,10 +26,10 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
@ -57,11 +57,21 @@ ynh_script_progression --message="Stopping systemd services..." --weight=1
ynh_systemd_action --service_name="$app-guacd" --action="stop" --log_path="/var/log/$app/guacd.log" 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_systemd_action --service_name="$app-tomcat" --action="stop" --log_path="/var/log/$app/tomcat.log"
#=================================================
# CREATE DEDICATED USERS
#=================================================
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-tomcat"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]; then if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
@ -140,15 +150,6 @@ if [ ! $tomcat_active ]; then
systemctl stop tomcat9 --quiet systemctl stop tomcat9 --quiet
fi fi
#=================================================
# CREATE DEDICATED USERS
#=================================================
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-tomcat"
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
@ -176,15 +177,6 @@ ln -s -f "/var/cache/$app-tomcat9" "$final_path/var/lib/tomcat9/work"
#================================================= #=================================================
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/"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create dedicated systemd configs
ynh_add_systemd_config --service="$app-guacd" --template="guacd.service" -v guacd_port
ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
#================================================= #=================================================
# UPDATE CONFIG FILES # UPDATE CONFIG FILES
#================================================= #=================================================
@ -193,6 +185,15 @@ ynh_add_config --template="guacamole.properties" --destination="$final_path/etc/
ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$final_path/etc/tomcat9/server.xml" ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$final_path/etc/tomcat9/server.xml"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create dedicated systemd configs
ynh_add_systemd_config --service="$app-guacd" --template="guacd.service"
ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

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

View file

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