diff --git a/src/bin/zmlicensectl b/src/bin/zmlicensectl index 1b197aad..44698e70 100755 --- a/src/bin/zmlicensectl +++ b/src/bin/zmlicensectl @@ -64,10 +64,15 @@ startLicenseDaemonService() if [ "x$zimbra_license_daemon_offline_mode" = "x" ]; then zimbra_license_daemon_offline_mode=false fi + if [ "x$zimbra_license_proxy_timeout" = "x" ]; then + zimbra_license_proxy_timeout=60 + fi + # Converting the value to milliseconds by appending 3 zeros + zimbra_license_proxy_timeout="${zimbra_license_proxy_timeout}000" if [ -f ${LD_LIBRARY_PATH}/libShafer-prod-linux64.so ]; then - export LD_LIBRARY_PATH; nohup ${ZMJAVA} -Dlicense-daemon.log.level=${zimbra_license_daemon_log_level} -Dlicense-daemon.offline.mode=${zimbra_license_daemon_offline_mode} -jar $LICENSE_DAEMON_SERVICE --spring.profiles.active=prod --server.port=$LICENSE_DAEMON_SERVICE_PORT > /dev/null 2>&1 & + export LD_LIBRARY_PATH; nohup ${ZMJAVA} -Dlicense-daemon.log.level=${zimbra_license_daemon_log_level} -Dlicense-daemon.offline.mode=${zimbra_license_daemon_offline_mode} -Dlicense.proxy.api.http.timeout=${zimbra_license_proxy_timeout} -Dlicense.proxy.api.http.socketTimeout=${zimbra_license_proxy_timeout} -Dlicense.proxy.api.http.readTimeout=${zimbra_license_proxy_timeout} -jar $LICENSE_DAEMON_SERVICE --spring.profiles.active=prod --server.port=$LICENSE_DAEMON_SERVICE_PORT > /dev/null 2>&1 & else - export LD_LIBRARY_PATH; nohup ${ZMJAVA} -Dlicense-daemon.log.level=${zimbra_license_daemon_log_level} -Dlicense-daemon.offline.mode=${zimbra_license_daemon_offline_mode} -jar $LICENSE_DAEMON_SERVICE --spring.profiles.active=dev --server.port=$LICENSE_DAEMON_SERVICE_PORT > /dev/null 2>&1 & + export LD_LIBRARY_PATH; nohup ${ZMJAVA} -Dlicense-daemon.log.level=${zimbra_license_daemon_log_level} -Dlicense-daemon.offline.mode=${zimbra_license_daemon_offline_mode} -Dlicense.proxy.api.http.timeout=${zimbra_license_proxy_timeout} -Dlicense.proxy.api.http.socketTimeout=${zimbra_license_proxy_timeout} -Dlicense.proxy.api.http.readTimeout=${zimbra_license_proxy_timeout} -jar $LICENSE_DAEMON_SERVICE --spring.profiles.active=dev --server.port=$LICENSE_DAEMON_SERVICE_PORT > /dev/null 2>&1 & fi sleep 5 checkLicenseDaemonServiceRunning @@ -306,8 +311,10 @@ displayHelp() echo " --service start|restart|stop|status" echo " --service setLogLevel=INFO|DEBUG|ERROR|WARN" echo " --service setOfflineMode=true|false" + echo " --service setProxyTimeout=70 (any numeric value greater than 60 is acceptable)" echo " --service getLogLevel" echo " --service getOfflineMode" + echo " --service getProxyTimeout" echo " --nalpeiron start|restart|stop|status" echo " --exportOfflineLicenseData | -exportOfflineLicenseData --exportStartTime YYYY/MM/DD --exportEndTime YYYY/MM/DD (offline only feature)" echo " --clearLicenseWorkDir" @@ -383,6 +390,19 @@ case "$1" in exit 0 ;; + "getProxyTimeout") + # Ensure exact match for "getOfflineMode" + if [ "$#" -ne 2 ]; then + displayHelp + exit 1 + fi + # Read the current log level from CONFIG_FILE + proxyTimeout=$(grep "zimbra_license_proxy_timeout" "$CONFIG_FILE" | cut -d '=' -f 2) + # Output the current log level + echo "Current proxy timeout: $proxyTimeout seconds" + exit 0 + ;; + "setLogLevel=INFO"|"setLogLevel=DEBUG"|"setLogLevel=ERROR"|"setLogLevel=WARN") loglevel=`echo $2|cut -d = -f 2` sed -i "/zimbra_license_daemon_log_level*/c\zimbra_license_daemon_log_level="$loglevel"" $CONFIG_FILE @@ -401,6 +421,33 @@ case "$1" in exit 0 ;; + "setProxyTimeout="*) + # Extract the timeout value from the second argument + proxyTimeout=`echo $2|cut -d = -f 2` + # Validate that the value is not empty + if [[ -z "$proxyTimeout" ]]; then + echo "Error: Proxy timeout value is missing." + exit 1 + fi + # Validate if the value is numeric + if ! [[ "$proxyTimeout" =~ ^[0-9]+$ ]]; then + echo "Error: Proxy timeout must be a numeric value." + exit 1 + fi + # Ensure the proxyTimeout value is greater than 60 + if (( proxyTimeout <= 60 )); then + echo "Error: Proxy timeout must be greater than 60." + exit 1 + fi + # Update the configuration file + sed -i "/zimbra_license_proxy_timeout*/c\zimbra_license_proxy_timeout="$proxyTimeout"" $CONFIG_FILE + # Check if the sed command succeeded + if [ $? != 0 ]; then + exit 1 + fi + exit 0 + ;; + *) displayHelp exit 1 @@ -424,6 +471,13 @@ case "$1" in else if ! sudo systemctl stop nalpdaemon &>/dev/null; then echo "failed." + + + + + + + exit 1 else echo "done."