diff --git a/cbox-tree.d/usr/lib/cryptobox/cbox-manage.sh b/cbox-tree.d/usr/lib/cryptobox/cbox-manage.sh
index 3f97b6e..feb292e 100755
--- a/cbox-tree.d/usr/lib/cryptobox/cbox-manage.sh
+++ b/cbox-tree.d/usr/lib/cryptobox/cbox-manage.sh
@@ -44,9 +44,6 @@ function initial_checks()
{
local device="$1"
[ ! -b "$device" ] && log_msg "blockdevice $device does not exist" && return 1
- ## check if we have an existing configpartition
- ## TODO: why this config_mount_test?
- # config_mount_test "$device"
[ ! -x "$WIPE" ] && log_msg "$WIPE not found" && return 1
[ ! -x "$SFDISK" ] && log_msg "$SFDISK not found" && return 1
for a in $ALGO $HASH
@@ -368,6 +365,12 @@ case "$ACTION" in
/etc/init.d/samba stop
/etc/init.d/thttpd stop
;;
+ crypto-up )
+ mount_crypto
+ ;;
+ crypto-down )
+ umount_crypto
+ ;;
box-init )
# do complete initialization
"$0" box-init-fg
@@ -400,16 +403,17 @@ case "$ACTION" in
is_init_running )
is_init_running
;;
+ is_harddisk_available )
+ [ -z "$(find_harddisk)" ] && exit 1
+ exit 0
+ ;;
update_ip_address )
# reconfigure the network interface to a new IP address
# wait for 5 seconds to finish present http requests
echo -n "sleep 5; ifconfig $NET_IFACE `config_get_value ip`" | at now
;;
- crypto-mount )
- mount_crypto
- ;;
- crypto-umount )
- umount_crypto
+ get_current_ip )
+ get_current_ip
;;
set_config )
[ $# -ne 3 ] && error_msg 7 "'set_config' requires two parameters"
@@ -432,16 +436,30 @@ case "$ACTION" in
log_msg "Rebooting the CryptoBox ..."
echo "reboot" | at now
;;
- get_current_ip )
- get_current_ip
- ;;
- is_harddisk_available )
- [ -z "$(find_harddisk)" ] && exit 1
- exit 0
- ;;
* )
- # TODO: update this!
- echo "Syntax: `basename $0` { mount_config | umount_config | init }"
+ echo "Syntax: `basename $0` ACTION [PARAMS]"
+ echo " config-up - scan for configuration partition and mount it"
+ echo " config-down - unmount configuration partition"
+ echo " network-up - enable network interface"
+ echo " network-down - disable network interface"
+ echo " services-up - run some cryptobox specific daemons"
+ echo " services-down - stop some cryptobox specific daemons"
+ echo " crypto-up - mount crypto partition and start samba"
+ echo " crypto-down - unmount crypto partition and stop samba"
+ echo " box-init - initialize cryptobox (ALL data is LOST)"
+ echo " box-init-fg - the first part of initialization"
+ echo " box-init-bg - the last part of initialization (background)"
+ echo " is_crypto_mounted - check, if crypto partition is mounted"
+ echo " is_config_mounted - check, if configuration partition is mounted"
+ echo " is_init_running - check, if initialization is ongoing"
+ echo " is_harddisk_available - check, if there is a usable harddisk"
+ echo " get_current_ip - get the current IP of the network interface"
+ echo " update_ip_address - update the network interface after reconfiguration"
+ echo " set_config NAME VALUE - change a configuration setting"
+ echo " get_config NAME - retrieve a configuration setting"
+ echo " diskinfo - show the partition table of the harddisk"
+ echo " poweroff - shutdown the cryptobox"
+ echo " reboot - reboot the cryptobox"
echo
;;
esac
diff --git a/cbox-tree.d/usr/share/cryptobox/lang/de.hdf b/cbox-tree.d/usr/share/cryptobox/lang/de.hdf
index 879f6ec..b79b39c 100644
--- a/cbox-tree.d/usr/share/cryptobox/lang/de.hdf
+++ b/cbox-tree.d/usr/share/cryptobox/lang/de.hdf
@@ -105,6 +105,21 @@ Lang {
Text = Der ausgewählte Wert der Zeitabschaltung ist nicht gültig!
}
+ ConfigTimeOutFailed {
+ Title = Fehler beim Ändern der Zeitabschaltung
+ Text = Der Wert der Zeitabschaltung konnte nicht geändert werden!
+ }
+
+ ConfigLanguageFailed {
+ Title = Fehler beim Ändern der Spracheinstellung
+ Text = Die Sprach-Einstellung konnte nicht geändert werden!
+ }
+
+ ConfigIPFailed {
+ Title = Fehler beim Ändern der Netzwerkadresse
+ Text = Die Netzwerkadresse konnte nicht geändert werden!
+ }
+
IPAddressChanged {
Title = Änderung der Netzwerk-Adresse
Text = Die Netzwerk-Adresse der CryptoBox wurde verändert. In wenigen Sekunden werden sie zu der neuen Adresse umgeleitet.
diff --git a/cbox-tree.d/usr/share/cryptobox/templates/doc.cs b/cbox-tree.d/usr/share/cryptobox/templates/doc.cs
index 9b2be3f..eddc90d 100644
--- a/cbox-tree.d/usr/share/cryptobox/templates/doc.cs
+++ b/cbox-tree.d/usr/share/cryptobox/templates/doc.cs
@@ -1,5 +1,5 @@
-
+
diff --git a/cbox-tree.d/usr/share/cryptobox/templates/init_form.cs b/cbox-tree.d/usr/share/cryptobox/templates/init_form.cs
index 132956c..b37386d 100644
--- a/cbox-tree.d/usr/share/cryptobox/templates/init_form.cs
+++ b/cbox-tree.d/usr/share/cryptobox/templates/init_form.cs
@@ -19,8 +19,5 @@
diff --git a/cbox-tree.d/usr/share/cryptobox/templates/nav.cs b/cbox-tree.d/usr/share/cryptobox/templates/nav.cs
index 5dc6c5d..39eed5e 100644
--- a/cbox-tree.d/usr/share/cryptobox/templates/nav.cs
+++ b/cbox-tree.d/usr/share/cryptobox/templates/nav.cs
@@ -14,7 +14,6 @@
Initialisierung
Protokoll
-
-Hilfe
+Hilfe
Herunterfahren
diff --git a/cbox-tree.d/var/www/cgi-bin/cryptobox.pl b/cbox-tree.d/var/www/cgi-bin/cryptobox.pl
index df81c7e..b6e4eb6 100755
--- a/cbox-tree.d/var/www/cgi-bin/cryptobox.pl
+++ b/cbox-tree.d/var/www/cgi-bin/cryptobox.pl
@@ -90,8 +90,9 @@ sub get_available_languages()
sub log_msg()
{
my $text = shift;
- # TODO: improve or remove!
- system("echo $text >>$LOG_FILE");
+ open(LOGFILE,">> $LOG_FILE");
+ print LOGFILE "$text";
+ close(LOGFILE);
}
@@ -153,29 +154,22 @@ sub mount_vol
my $pw = shift;
if (&check_mounted) {
- $pagedata->setValue('Data.Warning', 'Das Dateisystem war bereits aktiv!');
- return 0;
+ $pagedata->setValue('Data.Warning', 'IsMounted');
+ } else {
+ open(PW_INPUT, "| $CB_SCRIPT crypto-up");
+ print PW_INPUT $pw;
+ close(PW_INPUT);
}
-
- # TODO: the output is always empty?
- my $output = open(PW_INPUT, "| $CB_SCRIPT crypto-mount");
- print PW_INPUT $pw;
- close(PW_INPUT);
-
- $pagedata->setValue('Data.ProgOutput',"$output") if ($output);
}
sub umount_vol
{
- unless (&check_mounted) {
- $pagedata->setValue('Data.Warning', 'Das Dateisystem war bereits inaktiv!');
- return 0;
+ if (&check_mounted) {
+ system("$CB_SCRIPT", "crypto-down");
+ } else {
+ $pagedata->setValue('Data.Warning', 'NotMounted');
}
-
- # TODO: check if "system" returns output
- my $output = `$CB_SCRIPT crypto-umount`;
- $pagedata->setValue('Data.ProgOutput',"$output") if ($output);
}
@@ -195,14 +189,14 @@ sub box_init
sub system_poweroff()
{
- &umount_vol();
+ &umount_vol() if (&check_mounted());
system("$CB_SCRIPT", "poweroff");
}
sub system_reboot()
{
- &umount_vol();
+ &umount_vol() if (&check_mounted());
system("$CB_SCRIPT", "reboot");
}
@@ -246,8 +240,6 @@ my $query = new CGI;
$pagedata = load_hdf();
-#TODO: check result of actions and set Data.Error for failures
-
######### temporary language setting? ############
# the default language can be overriden by the language links in the
# upper right of the page
@@ -292,9 +284,10 @@ if ( ! &check_ssl()) {
if (&check_mounted()) {
$pagedata->setValue('Data.Warning', 'UmountFailed');
$pagedata->setValue('Data.Action', 'umount_form');
- }
- $pagedata->setValue('Data.Success', 'UmountDone');
- $pagedata->setValue('Data.Action', 'mount_form');
+ } else {
+ $pagedata->setValue('Data.Success', 'UmountDone');
+ $pagedata->setValue('Data.Action', 'mount_form');
+ }
}
################ mount_do ########################
} elsif ($action eq 'mount_do') {
@@ -423,15 +416,31 @@ if ( ! &check_ssl()) {
$pagedata->setValue('Data.Warning', 'IPAddressChanged');
}
- # TODO: check for success by comparing with new config and report success
- $pagedata->setValue('Data.Success', 'ConfigSaved');
- # TODO: maybe the intro page does not fit here ...
+ # check for success
+ if (`$CB_SCRIPT get_config timeout` ne $query->param('timeout')) {
+ $pagedata->setValue('Data.Warning', 'ConfigTimeOutFailed');
+ } elsif (`$CB_SCRIPT get_config ip` ne $query->param('ip')) {
+ $pagedata->setValue('Data.Warning', 'ConfigIPFailed');
+ } elsif (`$CB_SCRIPT get_config language` ne $query->param('language')) {
+ $pagedata->setValue('Data.Warning', 'ConfigLanguageFailed');
+ } else {
+ $pagedata->setValue('Data.Success', 'ConfigSaved');
+ }
$pagedata->setValue('Data.Action', 'intro');
}
}
#################### show_log #######################
} elsif ($action eq 'show_log') {
$pagedata->setValue('Data.Action', 'show_log');
+ ##################### doc ############################
+ } elsif ($action eq 'doc') {
+ if ($query->param('page')) {
+ $pagedata->setValue('Data.Doc.Page', $query->param('page'));
+ $pagedata->setValue('Data.Action', 'doc');
+ } else {
+ $pagedata->setValue('Data.Doc.Page', 'CryptoBox');
+ $pagedata->setValue('Data.Action', 'doc');
+ }
##################### poweroff ######################
} elsif ($action eq 'shutdown_ask') {
$pagedata->setValue('Data.Action', 'shutdown_form');
@@ -461,7 +470,7 @@ $pagedata->setValue('Data.Status.Mounted', &check_mounted() ? 1 : 0);
my $output = &get_current_ip();
$pagedata->setValue('Data.Status.IP', "$output");
-$output = `$CB_SCRIPT diskinfo 2>&1 | sed 's/^/
/'`;
+($output = `$CB_SCRIPT diskinfo 2>&1`) =~ s#\Z#
#;
$pagedata->setValue('Data.PartitionInfo',"$output");
# preset config settings for clearsilver
@@ -469,8 +478,13 @@ $pagedata->setValue('Data.Config.IP', `$CB_SCRIPT get_config ip`);
$pagedata->setValue('Data.Config.TimeOut', `$CB_SCRIPT get_config timeout`);
$pagedata->setValue('Data.Config.Language', `$CB_SCRIPT get_config language`);
-# read log - TODO: use perl filtering
-$output = (-e "$LOG_FILE") ? `cat '$LOG_FILE' | sed 's/^/
/'` : '';
+# read log and add html linebreaks
+$output = '';
+if (-e "$LOG_FILE") {
+ open(LOGFILE, "< $LOG_FILE");
+ while () { $output .= "$_
" }
+ close(LOGFILE);
+}
$pagedata->setValue('Data.Log',"$output");
$pagedata->setValue('Data.Status.DevelopmentMode', 1) if ($IS_DEV);
diff --git a/cbox-tree.d/var/www/img/backg.gif b/cbox-tree.d/var/www/cryptobox-img/backg.gif
similarity index 100%
rename from cbox-tree.d/var/www/img/backg.gif
rename to cbox-tree.d/var/www/cryptobox-img/backg.gif
diff --git a/cbox-tree.d/var/www/img/evil_small.png b/cbox-tree.d/var/www/cryptobox-img/evil_small.png
similarity index 100%
rename from cbox-tree.d/var/www/img/evil_small.png
rename to cbox-tree.d/var/www/cryptobox-img/evil_small.png
diff --git a/cbox-tree.d/var/www/img/evil_test.png b/cbox-tree.d/var/www/cryptobox-img/evil_test.png
similarity index 100%
rename from cbox-tree.d/var/www/img/evil_test.png
rename to cbox-tree.d/var/www/cryptobox-img/evil_test.png
diff --git a/cbox-tree.d/var/www/img/list.gif b/cbox-tree.d/var/www/cryptobox-img/list.gif
similarity index 100%
rename from cbox-tree.d/var/www/img/list.gif
rename to cbox-tree.d/var/www/cryptobox-img/list.gif
diff --git a/cbox-tree.d/usr/share/doc/cryptobox/html/moin-inter.png b/cbox-tree.d/var/www/cryptobox-img/moin-inter.png
similarity index 100%
rename from cbox-tree.d/usr/share/doc/cryptobox/html/moin-inter.png
rename to cbox-tree.d/var/www/cryptobox-img/moin-inter.png
diff --git a/cbox-tree.d/usr/share/doc/cryptobox/html/moin-www.png b/cbox-tree.d/var/www/cryptobox-img/moin-www.png
similarity index 100%
rename from cbox-tree.d/usr/share/doc/cryptobox/html/moin-www.png
rename to cbox-tree.d/var/www/cryptobox-img/moin-www.png
diff --git a/cbox-tree.d/usr/share/doc/cryptobox/html/smile.png b/cbox-tree.d/var/www/cryptobox-img/smile.png
similarity index 100%
rename from cbox-tree.d/usr/share/doc/cryptobox/html/smile.png
rename to cbox-tree.d/var/www/cryptobox-img/smile.png
diff --git a/cbox-tree.d/usr/share/doc/cryptobox/html/smile4.png b/cbox-tree.d/var/www/cryptobox-img/smile4.png
similarity index 100%
rename from cbox-tree.d/usr/share/doc/cryptobox/html/smile4.png
rename to cbox-tree.d/var/www/cryptobox-img/smile4.png
diff --git a/cbox-tree.d/usr/share/doc/cryptobox/html/somerights20.gif b/cbox-tree.d/var/www/cryptobox-img/somerights20.gif
similarity index 100%
rename from cbox-tree.d/usr/share/doc/cryptobox/html/somerights20.gif
rename to cbox-tree.d/var/www/cryptobox-img/somerights20.gif
diff --git a/cbox-tree.d/var/www/cryptobox.css b/cbox-tree.d/var/www/cryptobox.css
index 9f556bc..e2b7f96 100644
--- a/cbox-tree.d/var/www/cryptobox.css
+++ b/cbox-tree.d/var/www/cryptobox.css
@@ -1,5 +1,5 @@
body {
- background-image: url(img/backg.gif);
+ background-image: url(/cryptobox-img/backg.gif);
background-position: top center;
background-attachment: fixed;
background-repeat: no-repeat;
@@ -40,7 +40,7 @@ body {
height: 120px;
margin: 0;
padding: 0;
- background-image: url(img/evil_small.png);
+ background-image: url(/cryptobox-img/evil_small.png);
background-position: top right;
background-attachment: scroll;
background-repeat: no-repeat;
@@ -123,7 +123,7 @@ body {
padding: 0 1em;
line-height: 1.7em;
list-style: none;
- background: url(img/list.gif) center left no-repeat;
+ background: url(/cryptobox-img/list.gif) center left no-repeat;
}
#footer {
@@ -155,7 +155,7 @@ body {
}
-/* --------------------=-=-=- Spezialkram -=-=-=------------------- */
+/* -------=-=-=- warnings, errors and success messages-=-=-=-------- */
#words div.warning,div.error,div.success {
margin-top: 20px;
@@ -193,7 +193,7 @@ body {
}
#words .warning,.error,.success a {
-// WHY line-height???
+// TODO: WHY line-height???
// line-height: 5em;
color: #5e5e5e;
text-decoration: none;
@@ -208,7 +208,7 @@ body {
}
/* ----------------------=-=-=- Forms -=-=-=--------------------- */
-/* nachfolgend die Sachen fuer schoene Formulare und Buttons */
+/* pretty forms and buttons */
input {
border: 1px solid #BFBFBF;
color: #949494;
@@ -284,3 +284,16 @@ button:hover {
#lang a:hover {
color: #707070;
}
+
+
+/* ------------=-=-=- documentation -=-=-=------------- */
+
+// #doc { }
+
+/* ------------=-=-=- special things -=-=-=------------- */
+
+#partition_info p {
+ margin-left:10%;
+ margin-right:10%;
+ font-family:monospace
+ }
diff --git a/etc-defaults.d/cbox-dev.conf b/etc-defaults.d/cbox-dev.conf
index e195379..cf65627 100644
--- a/etc-defaults.d/cbox-dev.conf
+++ b/etc-defaults.d/cbox-dev.conf
@@ -32,9 +32,6 @@ CDWRITER="2,0,0"
# directory of the test-cases
VALIDATE_TEST_CASES_DIR=$ROOT_DIR/validation/test-cases
-# TODO: take care, that this file exists! (it is created during "upload", "diff" or "merge")
-# who knows, what this should mean?
-
# override these settings if the CryptoBox is not directly available
# in this case they should point to a redirecting router
VALIDATE_HOST_IP=192.168.0.23
diff --git a/tools/userdocexport.sh b/tools/userdocexport.sh
index f2aceda..c4797e0 100755
--- a/tools/userdocexport.sh
+++ b/tools/userdocexport.sh
@@ -1,9 +1,6 @@
#!/bin/sh
set -u
-# TODO:
-# import of images
-
# root directory of the cryptobox development environment
ROOT_DIR="$(dirname $(dirname $0))"
@@ -18,7 +15,10 @@ WIKI_URL="/wikis/howto/"
HEADER_FILE="$ROOT_DIR/tools/doc_header.inc"
FOOTER_FILE="$ROOT_DIR/tools/doc_footer.inc"
+CBOX_CGI="/cryptobox?action=doc\&page="
+
DEST_DIR="$ROOT_DIR/cbox-tree.d/usr/share/doc/cryptobox/html"
+IMAGE_DIR="$ROOT_DIR/cbox-tree.d/var/www/cryptobox-img"
TMP_DIR=/tmp/$(basename $0)-$$.d
[ ! -e "$DEST_DIR" ] && echo "$DEST_DIR does not exist" && exit 1
@@ -40,11 +40,11 @@ for PAGE in $PAGES; do
# remove all lines before and after "body"
sed -i '1,/_END_OF_HEADER_/d; /_START_OF_FOOTER_/,$d' "$TMP_FILE"
- echo " adding header and footer ..."
- [ -e "${TMP_FILE}.0" ] && rm "${TMP_FILE}.0"
- mv "$TMP_FILE" "${TMP_FILE}.0"
- cat "$HEADER_FILE" "${TMP_FILE}.0" "$FOOTER_FILE" >"$TMP_FILE"
- rm "${TMP_FILE}.0"
+ #echo " adding header and footer ..."
+ #[ -e "${TMP_FILE}.0" ] && rm "${TMP_FILE}.0"
+ #mv "$TMP_FILE" "${TMP_FILE}.0"
+ #cat "$HEADER_FILE" "${TMP_FILE}.0" "$FOOTER_FILE" >"$TMP_FILE"
+ #rm "${TMP_FILE}.0"
echo " downloading requisites ..."
wget --quiet --ignore-tags=a --no-clobber --page-requisites --convert-links --no-parent --no-directories --base="$WIKI_HOST$WIKI_URL" --directory-prefix="$TMP_DIR" --html-extension --force-html --input-file="$TMP_FILE" || { echo "Downloading requisites for ($PAGE_SRC) failed!"; exit 1; }
@@ -52,17 +52,16 @@ for PAGE in $PAGES; do
echo " adjusting links for requisites ..."
find "$TMP_DIR" -type f | grep -v '\.html$' | while read a
do fname=$(basename "$a")
- sed -i "s#=\"[^\"]*/$fname\"#=\"$fname\"#g" "$TMP_FILE"
+ sed -i "s#=\"[^\"]*/$fname\"#=\"/cryptobox-img/$fname\"#g" "$TMP_FILE"
done
- # TODO: replace wiki-links by references to the cbox-cgi
- # check if wiki-links are absolute!
echo " adjusting wiki links ..."
- # add the ".html" suffix and remove absolute path
- sed -i "s#=\"$WIKI_URL\([^\.]*\)\"#=\"\1.html\"#g" "$TMP_FILE"
+ # redirect wiki links to cryptobox cgi
+ sed -i "s#=\"$WIKI_URL\([^\.]*\)\"#=\"$CBOX_CGI\1\"#g" "$TMP_FILE"
echo " finished!"
done
-cp "$TMP_DIR"/* "$DEST_DIR"
-rm -r "$TMP_DIR"
+mv "$TMP_DIR"/*.html "$DEST_DIR"
+mv "$TMP_DIR"/* "$IMAGE_DIR"
+rmdir "$TMP_DIR"