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:
Éric Gaspar 2023-05-29 17:10:43 +02:00
parent 2cd01acd86
commit fef5b40db7
17 changed files with 308 additions and 261 deletions

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://downloads.apache.org/guacamole/1.5.1/binary/guacamole-auth-header-1.5.1.tar.gz
SOURCE_SUM=aea94a4d59370026edd0fb8d0bd8cd1090176eb2d10218dd27ede134a0647590
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=guacamole-auth-header.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://downloads.apache.org/guacamole/1.5.1/binary/guacamole-auth-jdbc-1.5.1.tar.gz
SOURCE_SUM=daf293856ddc2664b862a53b3f232ece82925832c081238161f27c49081b4305
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=guacamole-auth-jdbc.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://downloads.apache.org/guacamole/1.5.1/binary/guacamole-auth-ldap-1.5.1.tar.gz
SOURCE_SUM=4d32bb2aab09f9f99d02faa3db82c7c9ff3e5f84de9b042fba3a5f745f2704e8
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=guacamole-auth-ldap.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://downloads.apache.org/guacamole/1.5.1/binary/guacamole-1.5.1.war
SOURCE_SUM=b740f82ec05f40598e6f1c3b16d4d3798afe2872c051296e70785bf9292d0269
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=guacamole.war
SOURCE_EXTRACT=true

View file

@ -6,10 +6,10 @@ After=network.target
Type=simple Type=simple
User=__APP__-guacd User=__APP__-guacd
Group=__APP__-guacd Group=__APP__-guacd
ExecStart=__FINALPATH__/sbin/guacd -f -l __GUACD_PORT__ >> /var/log/__APP__/guacd.log 2>&1 ExecStart=__INSTALL_DIR__/sbin/guacd -f -l __GUACD_PORT__ >> /var/log/__APP__/guacd.log 2>&1
Restart=on-abnormal Restart=on-abnormal
Environment="LD_LIBRARY_PATH=__FINALPATH__/lib:__FINALPATH__/usr/lib" Environment="LD_LIBRARY_PATH=__INSTALL_DIR__/lib:__INSTALL_DIR__/usr/lib"
Environment="GUACAMOLE_HOME=__FINALPATH__/etc/guacamole" Environment="GUACAMOLE_HOME=__INSTALL_DIR__/etc/guacamole"
# Sandboxing options to harden security # Sandboxing options to harden security
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://downloads.mariadb.com/Connectors/java/connector-java-2.7.4/mariadb-java-client-2.7.4.jar
SOURCE_SUM=f06577b19e89b33028b96cd4f031248e761de7ebc712f4ef535e268df76edb2a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mariadb-java-client.jar
SOURCE_EXTRACT=false

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://downloads.apache.org/guacamole/1.5.1/source/guacamole-server-1.5.1.tar.gz
SOURCE_SUM=aabd707a68b99253f87234d0c3884678d6d6c1bceb39e7f9943c69d5329f4501
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=guacamole-server.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,16 +1,16 @@
[Unit] [Unit]
Description=Apache Tomcat 9 Web Application Server Description=Apache Tomcat 9 Web Application Server
After=network.target After=network.target
RequiresMountsFor=/var/log/__APP__/tomcat __FINALPATH__/var/lib/tomcat9 RequiresMountsFor=/var/log/__APP__/tomcat __INSTALL_DIR__/var/lib/tomcat9
[Service] [Service]
# Configuration # Configuration
Environment="CATALINA_HOME=/usr/share/tomcat9" Environment="CATALINA_HOME=/usr/share/tomcat9"
Environment="CATALINA_BASE=__FINALPATH__/var/lib/tomcat9" Environment="CATALINA_BASE=__INSTALL_DIR__/var/lib/tomcat9"
Environment="CATALINA_TMPDIR=/tmp" Environment="CATALINA_TMPDIR=/tmp"
Environment="JAVA_OPTS=-Djava.awt.headless=true" Environment="JAVA_OPTS=-Djava.awt.headless=true"
Environment="GUACAMOLE_HOME=__FINALPATH__/etc/guacamole" Environment="GUACAMOLE_HOME=__INSTALL_DIR__/etc/guacamole"
# Lifecycle # Lifecycle
@ -32,8 +32,8 @@ NoNewPrivileges=true
CacheDirectory=__APP__-tomcat9 CacheDirectory=__APP__-tomcat9
CacheDirectoryMode=750 CacheDirectoryMode=750
ProtectSystem=strict ProtectSystem=strict
ReadWritePaths=__FINALPATH__/etc/tomcat9/Catalina/ ReadWritePaths=__INSTALL_DIR__/etc/tomcat9/Catalina/
ReadWritePaths=__FINALPATH__/var/lib/tomcat9/webapps/ ReadWritePaths=__INSTALL_DIR__/var/lib/tomcat9/webapps/
ReadWritePaths=/var/log/__APP__/tomcat/ ReadWritePaths=/var/log/__APP__/tomcat/
[Install] [Install]

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://ftp.debian.org/debian/pool/main/t/tomcat9/tomcat9_9.0.70-1_all.deb
SOURCE_SUM=c062cd3ff27a566fdc6fed7dd2602c4e4ffe2216c8a19822bcaf03bd739e39b5
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=ar
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=tomcat9.deb
SOURCE_EXTRACT=false

94
manifest.toml Normal file
View file

@ -0,0 +1,94 @@
packaging_format = 2
id = "guacamole"
name = "Guacamole"
description.en = "Clientless remote desktop gateway. It supports standard protocols like VNC, RDP, and SSH"
description.fr = "Service de bureau à distance sans client. Fonctionne avec des protocoles standard comme VNC, RDP, et SSH"
version = "1.5.1~ynh1"
maintainers = ["Jules Bertholet"]
[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"
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
[integration]
yunohost = ">= 11.1.18"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
multi_instance = true
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
[install.path]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "path"
default = "/guacamole"
[install.admin]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "user"
[install.init_main_permission]
help.en = "Not recommended"
help.fr = "Pas reccomandé"
type = "group"
default = false
[resources]
[resources.sources]
[resources.sources.auth-header]
url = "https://downloads.apache.org/guacamole/1.5.1/binary/guacamole-auth-header-1.5.1.tar.gz"
sha256 = "aea94a4d59370026edd0fb8d0bd8cd1090176eb2d10218dd27ede134a0647590"
[resources.sources.mariadb-java-client]
url = "https://downloads.mariadb.com/Connectors/java/connector-java-2.7.4/mariadb-java-client-2.7.4.jar"
sha256 = "f06577b19e89b33028b96cd4f031248e761de7ebc712f4ef535e268df76edb2a"
[resources.sources.auth-ldap]
url = "https://downloads.apache.org/guacamole/1.5.1/binary/guacamole-auth-ldap-1.5.1.tar.gz"
sha256 = "4d32bb2aab09f9f99d02faa3db82c7c9ff3e5f84de9b042fba3a5f745f2704e8"
[resources.sources.client]
url = "https://downloads.apache.org/guacamole/1.5.1/binary/guacamole-1.5.1.war"
sha256 = "b740f82ec05f40598e6f1c3b16d4d3798afe2872c051296e70785bf9292d0269"
in_subdir = false
[resources.sources.server]
url = "https://downloads.apache.org/guacamole/1.5.1/source/guacamole-server-1.5.1.tar.gz"
sha256 = "aabd707a68b99253f87234d0c3884678d6d6c1bceb39e7f9943c69d5329f4501"
[resources.sources.tomcat9_deb]
url = "https://ftp.debian.org/debian/pool/main/t/tomcat9/tomcat9_9.0.70-1_all.deb"
sha256 = "c062cd3ff27a566fdc6fed7dd2602c4e4ffe2216c8a19822bcaf03bd739e39b5"
format = "ar"
rename = "tomcat9.deb"
[resources.sources.auth-jdbc]
url = "https://downloads.apache.org/guacamole/1.5.1/binary/guacamole-auth-jdbc-1.5.1.tar.gz"
sha256 = "daf293856ddc2664b862a53b3f232ece82925832c081238161f27c49081b4305"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
[resources.permissions]
main.url = "/"
[resources.database]
type = "mysql"

View file

@ -5,7 +5,7 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="acl build-essential libcairo2 libjpeg62-turbo-dev libpng-dev libtool-bin libossp-uuid-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libwebsockets-dev libpulse-dev libssl-dev libvorbis-dev libwebp-dev tomcat9" #REMOVEME? pkg_dependencies="acl build-essential libcairo2 libjpeg62-turbo-dev libpng-dev libtool-bin libossp-uuid-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libwebsockets-dev libpulse-dev libssl-dev libvorbis-dev libwebp-dev tomcat9"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
@ -14,43 +14,43 @@ pkg_dependencies="acl build-essential libcairo2 libjpeg62-turbo-dev libpng-dev l
function setup_sources { function setup_sources {
guacamole_verson="1.5.1" guacamole_verson="1.5.1"
ynh_setup_source --source_id="server" --dest_dir="$final_path/.guacd-src" ynh_setup_source --source_id="server" --dest_dir="$install_dir/.guacd-src"
tomcat_guac_dir="$path_url" tomcat_guac_dir="$path"
if [ "$path_url" == "/" -o -z "$path_url" ]; then if [ "$path" == "/" -o -z "$path" ]; then
tomcat_guac_dir="ROOT" tomcat_guac_dir="ROOT"
fi fi
ynh_setup_source --source_id="client" --dest_dir="$final_path/var/lib/tomcat9/webapps/$tomcat_guac_dir" ynh_setup_source --source_id="client" --dest_dir="$install_dir/var/lib/tomcat9/webapps/$tomcat_guac_dir"
ynh_setup_source --source_id="auth-ldap" --dest_dir="$final_path/etc/guacamole/extensions/ldap" ynh_setup_source --source_id="auth-ldap" --dest_dir="$install_dir/etc/guacamole/extensions/ldap"
mv "$final_path/etc/guacamole/extensions/ldap/guacamole-auth-ldap-$guacamole_verson.jar" "$final_path/etc/guacamole/extensions/guacamole-auth-ldap.jar" mv "$install_dir/etc/guacamole/extensions/ldap/guacamole-auth-ldap-$guacamole_verson.jar" "$install_dir/etc/guacamole/extensions/guacamole-auth-ldap.jar"
ynh_secure_remove --file="$final_path/etc/guacamole/extensions/ldap" #REMOVEME? ynh_secure_remove --file="$install_dir/etc/guacamole/extensions/ldap"
ynh_setup_source --source_id="auth-header" --dest_dir="$final_path/etc/guacamole/extensions/header" ynh_setup_source --source_id="auth-header" --dest_dir="$install_dir/etc/guacamole/extensions/header"
mv "$final_path/etc/guacamole/extensions/header/guacamole-auth-header-$guacamole_verson.jar" "$final_path/etc/guacamole/extensions/guacamole-auth-header.jar" mv "$install_dir/etc/guacamole/extensions/header/guacamole-auth-header-$guacamole_verson.jar" "$install_dir/etc/guacamole/extensions/guacamole-auth-header.jar"
ynh_secure_remove --file="$final_path/etc/guacamole/extensions/header" #REMOVEME? ynh_secure_remove --file="$install_dir/etc/guacamole/extensions/header"
ynh_setup_source --source_id="auth-jdbc" --dest_dir="$final_path/etc/guacamole/extensions/jdbc" ynh_setup_source --source_id="auth-jdbc" --dest_dir="$install_dir/etc/guacamole/extensions/jdbc"
mv "$final_path/etc/guacamole/extensions/jdbc/mysql/guacamole-auth-jdbc-mysql-$guacamole_verson.jar" "$final_path/etc/guacamole/extensions/guacamole-auth-jdbc-mysql.jar" mv "$install_dir/etc/guacamole/extensions/jdbc/mysql/guacamole-auth-jdbc-mysql-$guacamole_verson.jar" "$install_dir/etc/guacamole/extensions/guacamole-auth-jdbc-mysql.jar"
mv "$final_path/etc/guacamole/extensions/jdbc/mysql/schema" "$final_path/etc/guacamole/extensions/mysql-schema" mv "$install_dir/etc/guacamole/extensions/jdbc/mysql/schema" "$install_dir/etc/guacamole/extensions/mysql-schema"
ynh_secure_remove --file="$final_path/etc/guacamole/extensions/jdbc" #REMOVEME? ynh_secure_remove --file="$install_dir/etc/guacamole/extensions/jdbc"
ynh_setup_source --source_id="mariadb-java-client" --dest_dir="$final_path/etc/guacamole/lib/" ynh_setup_source --source_id="mariadb-java-client" --dest_dir="$install_dir/etc/guacamole/lib/"
ynh_setup_source --source_id="tomcat9_deb" --dest_dir="$final_path/" ynh_setup_source --source_id="tomcat9_deb" --dest_dir="$install_dir/"
pushd "$final_path" || ynh_die pushd "$install_dir" || ynh_die
ar x "$final_path/tomcat9.deb" "data.tar.xz" ar x "$install_dir/tomcat9.deb" "data.tar.xz"
popd || ynh_die popd || ynh_die
ynh_secure_remove --file="$final_path/tomcat9.deb" #REMOVEME? ynh_secure_remove --file="$install_dir/tomcat9.deb"
mkdir -p "$final_path/tomcat9-data" mkdir -p "$install_dir/tomcat9-data"
tar -C "$final_path/tomcat9-data" -xJf "$final_path/data.tar.xz" tar -C "$install_dir/tomcat9-data" -xJf "$install_dir/data.tar.xz"
cp -r "$final_path/tomcat9-data/usr/share/tomcat9/etc" -T "$final_path/etc/tomcat9/" cp -r "$install_dir/tomcat9-data/usr/share/tomcat9/etc" -T "$install_dir/etc/tomcat9/"
cp -r "$final_path/tomcat9-data/etc/tomcat9/" -T "$final_path/etc/tomcat9/" cp -r "$install_dir/tomcat9-data/etc/tomcat9/" -T "$install_dir/etc/tomcat9/"
ynh_secure_remove --file="$final_path/data.tar.xz" #REMOVEME? ynh_secure_remove --file="$install_dir/data.tar.xz"
ynh_secure_remove --file="$final_path/tomcat9-data" #REMOVEME? ynh_secure_remove --file="$install_dir/tomcat9-data"
} }
#================================================= #=================================================

View file

@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." #REMOVEME? ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -40,7 +40,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -13,54 +13,54 @@ source /usr/share/yunohost/helpers
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
old_domain=$YNH_APP_OLD_DOMAIN #REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH #REMOVEME? old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN #REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH #REMOVEME? new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" #REMOVEME? # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
# BACKUP BEFORE CHANGE URL 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 #REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" #REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED # CHECK WHICH PARTS SHOULD BE CHANGED
#================================================= #=================================================
change_domain=0 #REMOVEME? change_domain=0
if [ "$old_domain" != "$new_domain" ] #REMOVEME? if [ "$old_domain" != "$new_domain" ]
then then
change_domain=1 #REMOVEME? change_domain=1
fi fi
change_path=0 #REMOVEME? change_path=0
if [ "$old_path" != "$new_path" ] #REMOVEME? if [ "$old_path" != "$new_path" ]
then then
change_path=1 #REMOVEME? change_path=1
fi fi
#================================================= #=================================================
@ -78,28 +78,30 @@ ynh_systemd_action --service_name="$app-tomcat" --action="stop" --log_path="/var
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
#REMOVEME? 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 ] if [ $change_path -eq 1 ]
then 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" #REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper # Set global variables for NGINX helper
domain="$old_domain" #REMOVEME? domain="$old_domain"
path_url="$new_path" #REMOVEME? path="$new_path"
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config #REMOVEME? ynh_add_nginx_config
fi fi
# Change the domain for NGINX # Change the domain for NGINX
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then 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" #REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf #REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location # Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" #REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#================================================= #=================================================
@ -120,7 +122,7 @@ if [ $change_path -eq 1 ]; then
new_path_tomcat="ROOT" new_path_tomcat="ROOT"
fi fi
mv "$final_path/var/lib/tomcat9/webapps/$old_path_tomcat" "$final_path/var/lib/tomcat9/webapps/$new_path_tomcat" mv "$install_dir/var/lib/tomcat9/webapps/$old_path_tomcat" "$install_dir/var/lib/tomcat9/webapps/$new_path_tomcat"
fi fi
#================================================= #=================================================
@ -136,9 +138,9 @@ ynh_systemd_action --service_name="$app-tomcat" --action="start" --log_path="/va
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -13,42 +13,42 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN #REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH #REMOVEME? path=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN #REMOVEME? admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC #REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1 #REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app #REMOVEME? install_dir=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain #REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url #REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
ynh_app_setting_set --app=$app --key=admin --value=$admin #REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -58,15 +58,15 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_script_progression --message="Finding available ports..." --weight=1 ynh_script_progression --message="Finding available ports..." --weight=1
# Find available ports # Find available ports
guacd_port=$(ynh_find_port --port=4822) #REMOVEME? guacd_port=$(ynh_find_port --port=4822)
ynh_app_setting_set --app=$app --key=guacd_port --value=$guacd_port #REMOVEME? ynh_app_setting_set --app=$app --key=guacd_port --value=$guacd_port
port=$(ynh_find_port --port=8080) #REMOVEME? port=$(ynh_find_port --port=8080)
ynh_app_setting_set --app=$app --key=port --value=$port #REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1 #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
# 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.
@ -83,7 +83,7 @@ if [ "$(systemctl cat tomcat9 --quiet)" ]; then
fi fi
fi fi
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
if [ ! $tomcat_enabled ]; then if [ ! $tomcat_enabled ]; then
systemctl disable tomcat9 --quiet systemctl disable tomcat9 --quiet
@ -95,28 +95,28 @@ fi
#================================================= #=================================================
# CREATE DEDICATED USERS # CREATE DEDICATED USERS
#================================================= #=================================================
ynh_script_progression --message="Configuring system users..." --weight=1 #REMOVEME? ynh_script_progression --message="Configuring system users..." --weight=1
# Create system users # Create system users
ynh_system_user_create --username="$app-guacd" #REMOVEME? ynh_system_user_create --username="$app-guacd"
ynh_system_user_create --username="$app-tomcat" #REMOVEME? ynh_system_user_create --username="$app-tomcat"
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=1 #REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=1
db_name=$(ynh_sanitize_dbid --db_name=$app) #REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name #REMOVEME? db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name #REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCES # DOWNLOAD, CHECK AND UNPACK SOURCES
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=3 ynh_script_progression --message="Setting up source files..." --weight=3
ynh_app_setting_set --app=$app --key=final_path --value=$final_path #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
setup_sources setup_sources
@ -125,12 +125,12 @@ setup_sources
#================================================= #=================================================
ynh_script_progression --message="Setting up database files..." --weight=2 ynh_script_progression --message="Setting up database files..." --weight=2
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database="$db_name" < "$final_path/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/001-create-schema.sql"
ynh_replace_string --match_string="guacadmin" --replace_string="$admin" -f "$final_path/etc/guacamole/extensions/mysql-schema/002-create-admin-user.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 "$final_path/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 "$final_path/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" < "$final_path/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="$final_path/etc/guacamole/extensions/mysql-schema" #REMOVEME? ynh_secure_remove --file="$install_dir/etc/guacamole/extensions/mysql-schema"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -147,8 +147,8 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Compiling guacd..." --weight=30 ynh_script_progression --message="Compiling guacd..." --weight=30
pushd "$final_path/.guacd-src" || ynh_die pushd "$install_dir/.guacd-src" || ynh_die
./configure --enable-allow-freerdp-snapshots --prefix="$final_path" --datadir="$final_path" --with-freerdp-plugin-dir="$final_path/lib/x86_64-linux-gnu/freerdp2" ./configure --enable-allow-freerdp-snapshots --prefix="$install_dir" --data_dir="$install_dir" --with-freerdp-plugin-dir="$install_dir/lib/x86_64-linux-gnu/freerdp2"
ynh_exec_warn_less make ynh_exec_warn_less make
ynh_exec_warn_less make install ynh_exec_warn_less make install
popd || ynh_die popd || ynh_die
@ -157,10 +157,10 @@ popd || ynh_die
# SETUP TOMCAT # SETUP TOMCAT
#================================================= #=================================================
mkdir -p "$final_path/etc/" mkdir -p "$install_dir/etc/"
ln -s -f "$final_path/etc/tomcat9" "$final_path/var/lib/tomcat9/conf" ln -s -f "$install_dir/etc/tomcat9" "$install_dir/var/lib/tomcat9/conf"
ln -s -f "/var/log/$app/tomcat/" "$final_path/var/lib/tomcat9/logs" ln -s -f "/var/log/$app/tomcat/" "$install_dir/var/lib/tomcat9/logs"
ln -s -f "/var/cache/$app-tomcat9" "$final_path/var/lib/tomcat9/work" ln -s -f "/var/cache/$app-tomcat9" "$install_dir/var/lib/tomcat9/work"
#================================================= #=================================================
# CREATE LOG DIRS # CREATE LOG DIRS
@ -171,9 +171,9 @@ mkdir -p "/var/log/$app/tomcat/" "/var/log/$app/guacd/" "/var/log/$app/tomcat/"
# ADD CONFIGURATIONS # ADD CONFIGURATIONS
#================================================= #=================================================
ynh_add_config --template="guacamole.properties" --destination="$final_path/etc/guacamole/guacamole.properties" ynh_add_config --template="guacamole.properties" --destination="$install_dir/etc/guacamole/guacamole.properties"
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="$install_dir/etc/tomcat9/server.xml"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -191,15 +191,15 @@ ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
#================================================= #=================================================
# Set permissions to app files # Set permissions to app files
chown -R nobody $final_path chown -R nobody $install_dir
chmod -R o-rwx $final_path chmod -R o-rwx $install_dir
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 $install_dir
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 $install_dir
chown -R $app-guacd:$app-guacd "/var/log/$app/guacd/" chown -R $app-guacd:$app-guacd "/var/log/$app/guacd/"
chown -R $app-tomcat:$app-tomcat "/var/log/$app/tomcat/" chown -R $app-tomcat:$app-tomcat "/var/log/$app/tomcat/"
chown -R nobody:$app-tomcat "$final_path/etc/tomcat9/" "$final_path/etc/guacamole/" chown -R nobody:$app-tomcat "$install_dir/etc/tomcat9/" "$install_dir/etc/guacamole/"
chown -R "$app-tomcat":"$app-tomcat" "$final_path/var/lib/tomcat9/webapps" chown -R "$app-tomcat":"$app-tomcat" "$install_dir/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:- "$install_dir/var/lib/tomcat9/" "$install_dir/etc/guacamole/" "$install_dir/etc/tomcat9/"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -237,22 +237,22 @@ ynh_add_fail2ban_config --logpath="/var/log/syslog" --failregex='o.a.g.r.auth.Au
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1 #REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] #REMOVEME? if [ $is_public -eq 1 ]
then then
# Everyone can access the app. # Everyone can access the app.
# The "main" permission is automatically created before the install script. # The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" #REMOVEME? ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -50,26 +50,26 @@ ynh_remove_systemd_config --service="$app-tomcat"
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=1 #REMOVEME? ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1 #REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies #REMOVEME? ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1 #REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" #REMOVEME? ynh_secure_remove --file="$install_dir"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -109,11 +109,11 @@ ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# REMOVE DEDICATED USERS # REMOVE DEDICATED USERS
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system users..." --weight=1 #REMOVEME? ynh_script_progression --message="Removing the dedicated system users..." --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete --username="$app-guacd" #REMOVEME? ynh_system_user_delete --username="$app-guacd"
ynh_system_user_delete --username="$app-tomcat" #REMOVEME? ynh_system_user_delete --username="$app-tomcat"
#================================================= #=================================================

View file

@ -14,32 +14,32 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1 #REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \ #REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $install_dir "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -53,18 +53,18 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 #REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username="$app-guacd" #REMOVEME? ynh_system_user_create --username="$app-guacd"
ynh_system_user_create --username="$app-tomcat" #REMOVEME? ynh_system_user_create --username="$app-tomcat"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
#================================================= #=================================================
# RESTORE FAIL2BAN CONFIGURATION # RESTORE FAIL2BAN CONFIGURATION
@ -80,7 +80,7 @@ ynh_systemd_action --action=restart --service_name=fail2ban
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1 #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
tomcat_enabled="" tomcat_enabled=""
tomcat_active="" tomcat_active=""
@ -94,7 +94,7 @@ if [ "$(systemctl cat tomcat9 --quiet)" ]; then
fi fi
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
if [ ! $tomcat_enabled ]; then if [ ! $tomcat_enabled ]; then
systemctl disable tomcat9 --quiet systemctl disable tomcat9 --quiet
@ -108,21 +108,21 @@ fi
#================================================= #=================================================
# Restore permissions on app files # Restore permissions on app files
chown -R nobody $final_path chown -R nobody $install_dir
chmod -R o-rwx $final_path chmod -R o-rwx $install_dir
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 $install_dir
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 $install_dir
chown -R nobody:$app-tomcat "$final_path/etc/tomcat9/" "$final_path/etc/guacamole/" chown -R nobody:$app-tomcat "$install_dir/etc/tomcat9/" "$install_dir/etc/guacamole/"
chown -R "$app-tomcat":"$app-tomcat" "$final_path/var/lib/tomcat9/webapps" chown -R "$app-tomcat":"$app-tomcat" "$install_dir/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:- "$install_dir/var/lib/tomcat9/" "$install_dir/etc/guacamole/" "$install_dir/etc/tomcat9/"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1 #REMOVEME? ynh_script_progression --message="Restoring the MySQL database..." --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) #REMOVEME? 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 #REMOVEME? 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
#================================================= #=================================================

View file

@ -12,19 +12,19 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) #REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
guacd_port=$(ynh_app_setting_get --app=$app --key=guacd_port) #REMOVEME? guacd_port=$(ynh_app_setting_get --app=$app --key=guacd_port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -36,16 +36,16 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 #REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -60,11 +60,11 @@ ynh_systemd_action --service_name="$app-tomcat" --action="stop" --log_path="/var
#================================================= #=================================================
# CREATE DEDICATED USERS # CREATE DEDICATED USERS
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 #REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create dedicated users (if not existing) # Create dedicated users (if not existing)
ynh_system_user_create --username="$app-guacd" #REMOVEME? ynh_system_user_create --username="$app-guacd"
ynh_system_user_create --username="$app-tomcat" #REMOVEME? ynh_system_user_create --username="$app-tomcat"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -89,7 +89,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1 #REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
# 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.
@ -106,7 +106,7 @@ if [ "$(systemctl cat tomcat9 --quiet)" ]; then
fi fi
fi fi
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
if [ ! $tomcat_enabled ]; then if [ ! $tomcat_enabled ]; then
systemctl disable tomcat9 --quiet systemctl disable tomcat9 --quiet
@ -122,8 +122,8 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Compiling guacd..." --weight=30 ynh_script_progression --message="Compiling guacd..." --weight=30
pushd "$final_path/.guacd-src" || ynh_die pushd "$install_dir/.guacd-src" || ynh_die
./configure --enable-allow-freerdp-snapshots --prefix="$final_path" --datadir="$final_path" --with-freerdp-plugin-dir="$final_path/lib/x86_64-linux-gnu/freerdp2" ./configure --enable-allow-freerdp-snapshots --prefix="$install_dir" --data_dir="$install_dir" --with-freerdp-plugin-dir="$install_dir/lib/x86_64-linux-gnu/freerdp2"
ynh_exec_warn_less make ynh_exec_warn_less make
ynh_exec_warn_less make install ynh_exec_warn_less make install
popd || ynh_die popd || ynh_die
@ -132,10 +132,10 @@ popd || ynh_die
# SETUP TOMCAT # SETUP TOMCAT
#================================================= #=================================================
mkdir -p "$final_path/etc/" mkdir -p "$install_dir/etc/"
ln -s -f "$final_path/etc/tomcat9" "$final_path/var/lib/tomcat9/conf" ln -s -f "$install_dir/etc/tomcat9" "$install_dir/var/lib/tomcat9/conf"
ln -s -f "/var/log/$app/tomcat/" "$final_path/var/lib/tomcat9/logs" ln -s -f "/var/log/$app/tomcat/" "$install_dir/var/lib/tomcat9/logs"
ln -s -f "/var/cache/$app-tomcat9" "$final_path/var/lib/tomcat9/work" ln -s -f "/var/cache/$app-tomcat9" "$install_dir/var/lib/tomcat9/work"
#================================================= #=================================================
# CREATE LOG DIRS # CREATE LOG DIRS
@ -146,9 +146,9 @@ 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="$final_path/etc/guacamole/guacamole.properties" ynh_add_config --template="guacamole.properties" --destination="$install_dir/etc/guacamole/guacamole.properties"
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="$install_dir/etc/tomcat9/server.xml"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -166,15 +166,15 @@ ynh_add_systemd_config --service="$app-tomcat" --template="tomcat.service"
#================================================= #=================================================
# Set permissions on app files # Set permissions on app files
chown -R nobody $final_path chown -R nobody $install_dir
chmod -R o-rwx $final_path chmod -R o-rwx $install_dir
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 $install_dir
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 $install_dir
chown -R $app-guacd:$app-guacd "/var/log/$app/guacd/" chown -R $app-guacd:$app-guacd "/var/log/$app/guacd/"
chown -R $app-tomcat:$app-tomcat "/var/log/$app/tomcat/" chown -R $app-tomcat:$app-tomcat "/var/log/$app/tomcat/"
chown -R nobody:$app-tomcat "$final_path/etc/tomcat9/" "$final_path/etc/guacamole/" chown -R nobody:$app-tomcat "$install_dir/etc/tomcat9/" "$install_dir/etc/guacamole/"
chown -R "$app-tomcat":"$app-tomcat" "$final_path/var/lib/tomcat9/webapps" chown -R "$app-tomcat":"$app-tomcat" "$install_dir/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:- "$install_dir/var/lib/tomcat9/" "$install_dir/etc/guacamole/" "$install_dir/etc/tomcat9/"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -211,9 +211,9 @@ ynh_add_fail2ban_config --logpath="/var/log/syslog" --failregex='o.a.g.r.auth.Au
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT