From 98dc7f564eb67918025569caf16fc69d457bb1bf Mon Sep 17 00:00:00 2001 From: lars Date: Sat, 23 Jul 2005 23:57:11 +0000 Subject: [PATCH] shutdown/reboot added to web interface --- .../usr/lib/cryptobox/configure-cryptobox.sh | 2 +- .../usr/share/cryptobox/lang/de.hdf | 13 +++++++ .../usr/share/cryptobox/templates/nav.cs | 1 + .../cryptobox/templates/shutdown_form.cs | 16 ++++++++ cryptobox.conf.d/var/www/cgi-bin/cryptobox.pl | 37 ++++++++++++++----- 5 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 cryptobox.conf.d/usr/share/cryptobox/templates/shutdown_form.cs diff --git a/cryptobox.conf.d/usr/lib/cryptobox/configure-cryptobox.sh b/cryptobox.conf.d/usr/lib/cryptobox/configure-cryptobox.sh index e76af01..8710921 100755 --- a/cryptobox.conf.d/usr/lib/cryptobox/configure-cryptobox.sh +++ b/cryptobox.conf.d/usr/lib/cryptobox/configure-cryptobox.sh @@ -60,7 +60,7 @@ function configure_secure() sed -i '/getty/d' /etc/inittab # remove unnecessary packages - dpkg --force-all -P $SECURITY_REMOVE_PACKAGES + dpkg --force-all -P $SECURITY_REMOVE_PACKAGES 2>&1 | grep -v "which isn't installed." # remove development files rm -f "$DEV_FEATURES_SCRIPT" diff --git a/cryptobox.conf.d/usr/share/cryptobox/lang/de.hdf b/cryptobox.conf.d/usr/share/cryptobox/lang/de.hdf index 322bd12..ec53c8a 100644 --- a/cryptobox.conf.d/usr/share/cryptobox/lang/de.hdf +++ b/cryptobox.conf.d/usr/share/cryptobox/lang/de.hdf @@ -8,6 +8,7 @@ Lang { Umount = Deaktivierung der Cryptodaten Config = Konfiguration der CryptoBox Log = Protokoll der CryptoBox + ShutDown = System } @@ -33,6 +34,8 @@ Lang { Update = Aktualisieren Mount = CryptoDaten aktivieren Umount = CryptoDaten deaktivieren + PowerOff = ausschalten + ReBoot = neu starten } @@ -109,6 +112,16 @@ Lang { Title = Crypto-Daten deaktiviert Text = Das verschlüsselte Dateisystem ist nun vor jedem Zugriff geschützt. } + + PowerOff { + Title = Abschaltung + Text = Die CryptoBox wird gerade heruntergefahren. Spätestens in ein paar Minuten kannst du sie ausschalten. + } + + ReBoot { + Title = Neustart + Text = Die CryptoBox wird gerade neu gestartet. Spätestens in ein paar Minuten ist sie wieder verfügbar. + } } diff --git a/cryptobox.conf.d/usr/share/cryptobox/templates/nav.cs b/cryptobox.conf.d/usr/share/cryptobox/templates/nav.cs index 63bf9d1..a1589ae 100644 --- a/cryptobox.conf.d/usr/share/cryptobox/templates/nav.cs +++ b/cryptobox.conf.d/usr/share/cryptobox/templates/nav.cs @@ -15,6 +15,7 @@ Initialisierung Protokoll Hilfe +Herunterfahren Test-Sequenzen diff --git a/cryptobox.conf.d/usr/share/cryptobox/templates/shutdown_form.cs b/cryptobox.conf.d/usr/share/cryptobox/templates/shutdown_form.cs new file mode 100644 index 0000000..f4aea72 --- /dev/null +++ b/cryptobox.conf.d/usr/share/cryptobox/templates/shutdown_form.cs @@ -0,0 +1,16 @@ +

+ +
+
+ + + + + + + +
+
diff --git a/cryptobox.conf.d/var/www/cgi-bin/cryptobox.pl b/cryptobox.conf.d/var/www/cgi-bin/cryptobox.pl index ea09416..eb0a283 100755 --- a/cryptobox.conf.d/var/www/cgi-bin/cryptobox.pl +++ b/cryptobox.conf.d/var/www/cgi-bin/cryptobox.pl @@ -1,14 +1,6 @@ #!/usr/bin/perl # -# Vorbereitung: -# - die Variable "MNTIMAGE" (siehe unten) setzen - es muss der Name der cryptoloop-image-Datei sein -# - in die /etc/fstab einen passenden Eintrag einfuegen, z.B.: -# /data/cryptoimage.loop /mnt/crypto auto noauto,user,loop,encryption=aes,keybits=256 -# - ein Image erstellen (als root): -# dd if=/dev/zero of=cryptoimage.loop bs=1M count=10 -# losetup -k 256 -e aes /dev/loop1 cryptoimage.loop -# mkfs.ext3 /dev/loop1 -# losetup -d /dev/loop1 +# web interface of the CryptoBox # @@ -189,6 +181,20 @@ sub box_init } +sub system_poweroff() +{ + &umount_vol(); + system("{sleep 5; /sbin/poweroff; } /dev/null &"); +} + + +sub system_reboot() +{ + &umount_vol(); + system("{sleep 5; /sbin/reboot; } /dev/null &"); +} + + ################### main ######################### my $query = new CGI; @@ -363,6 +369,19 @@ if ( ! &check_ssl()) { $pagedata->setValue('Data.Doc.Page', 'CryptoBox.html'); $pagedata->setValue('Data.Action', 'doc'); } + ##################### pweroff ####################### + } elsif ($action eq 'shutdown_ask') { + $pagedata->setValue('Data.Action', 'shutdown_form'); + ##################### reboot ###################### + } elsif ($action eq 'shutdown_do') { + if ($type eq 'reboot') { + &system_reboot(); + $pagedata->setValue('Data.Success', 'ReBoot'); + } else { + &system_poweroff(); + $pagedata->setValue('Data.Success', 'PowerOff'); + } + $pagedata->setValue('Data.Action', 'intro'); ################### unknown ######################### } else { $pagedata->setValue('Data.Error', 'UnknownAction');