diff --git a/conf/tomcat.service b/conf/tomcat.service index 1f1e0c9..fd777fe 100644 --- a/conf/tomcat.service +++ b/conf/tomcat.service @@ -1,13 +1,13 @@ [Unit] Description=Apache Tomcat 9 Web Application Server After=network.target -RequiresMountsFor=/var/log/__APP__/tomcat __INSTALL_DIR__/var/lib/tomcat9 +RequiresMountsFor=/var/log/__APP__/tomcat __INSTALL_DIR__/var/lib/__TOMCAT_VERSION__ [Service] # Configuration -Environment="CATALINA_HOME=/usr/share/tomcat9" -Environment="CATALINA_BASE=__INSTALL_DIR__/var/lib/tomcat9" +Environment="CATALINA_HOME=/usr/share/__TOMCAT_VERSION__" +Environment="CATALINA_BASE=__INSTALL_DIR__/var/lib/__TOMCAT_VERSION__" Environment="CATALINA_TMPDIR=/tmp" Environment="JAVA_OPTS=-Djava.awt.headless=true" Environment="GUACAMOLE_HOME=__INSTALL_DIR__/etc/guacamole" @@ -15,13 +15,13 @@ Environment="GUACAMOLE_HOME=__INSTALL_DIR__/etc/guacamole" # Lifecycle Type=simple -ExecStartPre=+/usr/libexec/tomcat9/tomcat-update-policy.sh -ExecStart=/bin/sh /usr/libexec/tomcat9/tomcat-start.sh > /var/log/__APP__/tomcat/tomcat.log 2>&1 +ExecStartPre=+/usr/libexec/__TOMCAT_VERSION__/tomcat-update-policy.sh +ExecStart=/bin/sh /usr/libexec/__TOMCAT_VERSION__/tomcat-start.sh > /var/log/__APP__/tomcat/tomcat.log 2>&1 SuccessExitStatus=143 Restart=on-abort # Logging -SyslogIdentifier=__APP__-tomcat9 +SyslogIdentifier=__APP__-__TOMCAT_VERSION__ # Security User=__APP__-tomcat @@ -29,11 +29,11 @@ Group=__APP__-tomcat PrivateTmp=yes AmbientCapabilities=CAP_NET_BIND_SERVICE NoNewPrivileges=true -CacheDirectory=__APP__-tomcat9 +CacheDirectory=__APP__-__TOMCAT_VERSION__ CacheDirectoryMode=750 ProtectSystem=strict -ReadWritePaths=__INSTALL_DIR__/etc/tomcat9/Catalina/ -ReadWritePaths=__INSTALL_DIR__/var/lib/tomcat9/webapps/ +ReadWritePaths=__INSTALL_DIR__/etc/__TOMCAT_VERSION__/Catalina/ +ReadWritePaths=__INSTALL_DIR__/var/lib/__TOMCAT_VERSION__/webapps/ ReadWritePaths=/var/log/__APP__/tomcat/ [Install] diff --git a/manifest.toml b/manifest.toml index 3a84dbe..2772401 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ 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.4~ynh1" +version = "1.5.4~ynh2" maintainers = ["Jules Bertholet"] diff --git a/scripts/_common.sh b/scripts/_common.sh index 11a92d5..ce9d645 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,6 +6,12 @@ guacamole_version="1.5.4" +if [ "$debian_maj_version" -eq 11 ] ; then + tomcat_version="tomcat9" +elif [ "$debian_maj_version" -eq 12 ] ; then + tomcat_version="tomcat10" +fi + #================================================= # PERSONAL HELPERS #================================================= @@ -18,18 +24,18 @@ function setup_sources { tomcat_guac_dir="ROOT" fi - ynh_setup_source --source_id="tomcat9_deb" --dest_dir="$install_dir/downloads/tomcat9" - pushd "$install_dir/downloads/tomcat9" || ynh_die - ar x "tomcat9.deb" "data.tar.xz" + ynh_setup_source --source_id="$tomcat_version_deb" --dest_dir="$install_dir/downloads/$tomcat_version" + pushd "$install_dir/downloads/$tomcat_version" || ynh_die + ar x "$tomcat_version.deb" "data.tar.xz" tar xJf data.tar.xz popd || ynh_die mkdir -p "$install_dir/etc" - cp -r "$install_dir/downloads/tomcat9/usr/share/tomcat9/etc" -T "$install_dir/etc/tomcat9/" - cp -r "$install_dir/downloads/tomcat9/etc/tomcat9/" -T "$install_dir/etc/tomcat9/" + cp -r "$install_dir/downloads/$tomcat_version/usr/share/$tomcat_version/etc" -T "$install_dir/etc/$tomcat_version/" + cp -r "$install_dir/downloads/$tomcat_version/etc/$tomcat_version/" -T "$install_dir/etc/$tomcat_version/" ynh_setup_source --source_id="client" --dest_dir="$install_dir/downloads" - mkdir -p "$install_dir/var/lib/tomcat9/webapps" - mv "$install_dir/downloads/guacamole.war" "$install_dir/var/lib/tomcat9/webapps/$tomcat_guac_dir.war" + mkdir -p "$install_dir/var/lib/$tomcat_version/webapps" + mv "$install_dir/downloads/guacamole.war" "$install_dir/var/lib/$tomcat_version/webapps/$tomcat_guac_dir.war" mkdir -p "$install_dir/etc/guacamole/extensions" @@ -55,10 +61,10 @@ function _set_permissions() { setfacl -n -R -m "user:$app-guacd:rx" -m "default:user:$app-guacd:rx" "$install_dir" setfacl -n -R -m "user:$app-tomcat:rx" -m "default:user:$app-tomcat:rx" "$install_dir" - # chown -R nobody:$app-tomcat "$install_dir/etc/tomcat9/" "$install_dir/etc/guacamole/" - chown -R "$app-tomcat":"$app-tomcat" "$install_dir/var/lib/tomcat9/webapps" + # chown -R nobody:$app-tomcat "$install_dir/etc/$tomcat_version/" "$install_dir/etc/guacamole/" + chown -R "$app-tomcat":"$app-tomcat" "$install_dir/var/lib/$tomcat_version/webapps" 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/" + "$install_dir/var/lib/$tomcat_version/" "$install_dir/etc/guacamole/" "$install_dir/etc/$tomcat_version/" chown -R "$app-guacd:$app-guacd" "/var/log/$app/guacd/" chown -R "$app-tomcat:$app-tomcat" "/var/log/$app/tomcat/" diff --git a/scripts/change_url b/scripts/change_url index cb11768..b65c972 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -44,7 +44,7 @@ if [ $change_path -eq 1 ]; then new_path_tomcat="ROOT" fi - mv "$install_dir/var/lib/tomcat9/webapps/$old_path_tomcat" "$install_dir/var/lib/tomcat9/webapps/$new_path_tomcat" + mv "$install_dir/var/lib/$tomcat_version/webapps/$old_path_tomcat" "$install_dir/var/lib/$tomcat_version/webapps/$new_path_tomcat" fi #================================================= diff --git a/scripts/install b/scripts/install index bdc9698..7acb11e 100755 --- a/scripts/install +++ b/scripts/install @@ -20,20 +20,20 @@ ynh_script_progression --message="Stopping system tomcat..." --weight=1 tomcat_enabled="" tomcat_active="" -if [ "$(systemctl cat tomcat9 --quiet)" ]; then - if (systemctl is-enabled tomcat9 --quiet); then +if [ "$(systemctl cat $tomcat_version --quiet)" ]; then + if (systemctl is-enabled $tomcat_version --quiet); then tomcat_enabled=1 fi - if (systemctl is-active tomcat9 --quiet); then + if (systemctl is-active $tomcat_version --quiet); then tomcat_active=1 fi fi if [ $tomcat_enabled ]; then - systemctl disable tomcat9 --quiet + systemctl disable $tomcat_version --quiet fi if [ $tomcat_active ]; then - systemctl stop tomcat9 --quiet + systemctl stop $tomcat_version --quiet fi #================================================= @@ -55,9 +55,9 @@ setup_sources 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" +ln -s -f "$install_dir/etc/$tomcat_version" "$install_dir/var/lib/$tomcat_version/conf" +ln -s -f "/var/log/$app/tomcat/" "$install_dir/var/lib/$tomcat_version/logs" +ln -s -f "/var/cache/$app-$tomcat_version" "$install_dir/var/lib/$tomcat_version/work" #================================================= # ADD CONFIGURATIONS @@ -65,7 +65,7 @@ ln -s -f "/var/cache/$app-tomcat9" "$install_dir/var/lib/tomcat9/work" ynh_add_config --template="guacamole.properties" --destination="$install_dir/etc/guacamole/guacamole.properties" -ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$install_dir/etc/tomcat9/server.xml" +ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$install_dir/etc/$tomcat_version/server.xml" _set_permissions diff --git a/scripts/restore b/scripts/restore index 7dcd68e..476bea3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -17,20 +17,20 @@ ynh_script_progression --message="Stopping system tomcat..." --weight=1 tomcat_enabled="" tomcat_active="" -if [ "$(systemctl cat tomcat9 --quiet)" ]; then - if (systemctl is-enabled tomcat9 --quiet); then +if [ "$(systemctl cat $tomcat_version --quiet)" ]; then + if (systemctl is-enabled $tomcat_version --quiet); then tomcat_enabled=1 fi - if (systemctl is-active tomcat9 --quiet); then + if (systemctl is-active $tomcat_version --quiet); then tomcat_active=1 fi fi if [ ! $tomcat_enabled ]; then - systemctl disable tomcat9 --quiet + systemctl disable $tomcat_version --quiet fi if [ ! $tomcat_active ]; then - systemctl stop tomcat9 --quiet + systemctl stop $tomcat_version --quiet fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 63ed75e..7ccc7e9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -65,20 +65,20 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1 tomcat_enabled="" tomcat_active="" -if [ "$(systemctl cat tomcat9 --quiet)" ]; then - if (systemctl is-enabled tomcat9 --quiet); then +if [ "$(systemctl cat $tomcat_version --quiet)" ]; then + if (systemctl is-enabled $tomcat_version --quiet); then tomcat_enabled=1 fi - if (systemctl is-active tomcat9 --quiet); then + if (systemctl is-active $tomcat_version --quiet); then tomcat_active=1 fi fi if [ ! $tomcat_enabled ]; then - systemctl disable tomcat9 --quiet + systemctl disable $tomcat_version --quiet fi if [ ! $tomcat_active ]; then - systemctl stop tomcat9 --quiet + systemctl stop $tomcat_version --quiet fi #================================================= @@ -99,9 +99,9 @@ popd #================================================= 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" +ln -s -f "$install_dir/etc/$tomcat_version" "$install_dir/var/lib/$tomcat_version/conf" +ln -s -f "/var/log/$app/tomcat/" "$install_dir/var/lib/$tomcat_version/logs" +ln -s -f "/var/cache/$app-$tomcat_version" "$install_dir/var/lib/$tomcat_version/work" #================================================= # CREATE LOG DIRS @@ -115,7 +115,7 @@ mkdir -p "/var/log/$app/tomcat/" "/var/log/$app/guacd/" "/var/log/$app/tomcat/" ynh_add_config --template="guacamole.properties" --destination="$install_dir/etc/guacamole/guacamole.properties" -ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$install_dir/etc/tomcat9/server.xml" +ynh_replace_string --match_string="8080" --replace_string="$port" --target_file="$install_dir/etc/$tomcat_version/server.xml" #================================================= # SETUP SYSTEMD