
if {[cgi_get act] eq "xtelnet"} {
	set val [cgi_get val off]
	if {$val in {0 off}} {
		file delete /mod/boot/xtelnet
		puts "Telnet server expert mode will be disabled after next reboot."
	} else {
		exec /mod/bin/busybox/touch /mod/boot/xtelnet
		puts "Telnet server expert mode will be enabled after next reboot."
	}
	exit
}

if {[cgi_get act] eq "cryptokey"} {
	set val [cgi_get cryptokey ""]
	set nkey [system encryptionkey]
	if {$val eq "" || [string equal -nocase $val $nkey]} {
		if {[system customencryptionkey] ne ""} {
			system customencryptionkey $nkey
			system nugget cryptokey -init
			puts "Using native encryption key."
		} else {
			puts "Native key unchanged."
		}
		set cryptokey ""
	} elseif {[string length $val] != 32} {
		puts "Encryption key must be 32 hexadecimal digits."
	} else {
		if {[string equal -nocase $val [system customencryptionkey]]} {
			puts "Custom key unchanged."
		} elseif {[set customkey [system customencryptionkey $val]] ne ""} {
		        set cryptokey $customkey
			system nugget cryptokey -init
			puts "Installed new encryption key."
		} else {
			puts "Failed to install encryption key $val"
	}
	}
	puts "<br>"
	exit
}

set pkgdev [$settings pkgdev]
set rtschedule [$settings rtschedule]
set noautoremove [$settings noautoremove]
set logsize [$settings logsize]
set logkeep [$settings logkeep]
set logage [$settings logage]

set cryptokey [system customencryptionkey]

handle_int_update pkgdev $pkgdev "Development Package Display"
handle_int_update rtschedule $rtschedule "Real-time scheduling"
handle_int_update noautoremove $noautoremove "Package auto-remove"
handle_int_update logsize $logsize "Log rotation size"
handle_int_update logkeep $logkeep "Logs to keep"
handle_int_update logage $logage "Rotated log max age"

