@@ -10,8 +10,43 @@ source "${SCRIPT_DIR}/lib-dialog.sh"
1010source " ${SCRIPT_DIR} /dialog-keyboard.sh"
1111
1212
13+ session_timeout () {
14+ local timeout_seconds=" $( jq_config ' .console_session_timeout // ""' ) "
15+ timeout_seconds=" ${timeout_seconds:- " 1800" } "
16+ export TIMEOUT_PID=" "
17+
18+ # Run the command in background so trap can be checked
19+ " $@ " &
20+ export CMD_PID=$!
21+
22+ # Start the timeout process
23+ (trap exit TERM; sleep " $timeout_seconds " & wait ; echo " Timeout reached" ; pkill -P " ${CMD_PID} " ; kill " ${CMD_PID} " ) &
24+ TIMEOUT_PID=$!
25+
26+ cleanup () {
27+ if [[ -n " ${TIMEOUT_PID} " ]]; then
28+ kill " ${TIMEOUT_PID} " 2> /dev/null
29+ if ! wait " ${TIMEOUT_PID} " ; then
30+ report_notice " cuos:console:logout" " Logout from console interface"
31+ else
32+ report_notice " cuos:console:logout_timeout" " Logout from console interface after timeout"
33+ fi
34+ TIMEOUT_PID=" "
35+ fi
36+ exit 0
37+ }
38+ trap cleanup SIGINT SIGTERM EXIT
39+
40+ wait $CMD_PID
41+ }
42+
1343maintenance_menu () {
14- maintenance_menu_check_login || return 1
44+ maintenance_menu_check_login || {
45+ report_err " cuos:console:login_failed" " Login to console interface failed"
46+ return 1
47+ }
48+
49+ report_notice " cuos:console:login" " Login to console interface"
1550
1651 while true ; do
1752 local ipaddress
@@ -28,7 +63,7 @@ maintenance_menu() {
2863 " act" " System Actions" \
2964 " diag" " Diagnostics" \
3065 - " " \
31- " exit" " \Z5Exit Menu\Z0" ) " || return 1
66+ " exit" " \Z5Exit Menu\Z0" ) " || break
3267 # "pass" "Change Admin Password"
3368 case " $choice " in
3469 host)
@@ -358,6 +393,6 @@ elif [[ -n "${1:-}" && "$(type -t "${1}")" == "function" ]]; then
358393 exit " $? "
359394else
360395 change_vt
361- maintenance_menu " $@ "
396+ session_timeout maintenance_menu " $@ "
362397fi
363398
0 commit comments