#!/mod/bin/jimsh package require cgi puts "Content-Type: text/html" puts "" cgi_input #cgi_dump # Set variables if {[catch {set fd [open "/var/lib/humaxtv/hostname" r]}]} { set hostname "humax" } else { set hostname [string trim [read $fd]] close $fd } # Handle updates if {[dict exists $_cgi hostname]} { set nhostname [string trim [dict get $_cgi hostname]] if {$nhostname eq $hostname} { puts "Hostname is already '$hostname'." } elseif [string is alnum -strict $hostname] { set fd [open "/var/lib/humaxtv/hostname" w] puts $fd $nhostname close $fd exec hostname -F /var/lib/humaxtv/hostname puts "Hostname successfully updated, reboot recommended." } else { puts "Invalid hostname." } exit } source /mod/var/mongoose/html/lib/header.jim puts {} puts { } puts "