diff --git a/bin/cryptobox.conf b/bin/cryptobox.conf index ea99730..0b10ac8 100644 --- a/bin/cryptobox.conf +++ b/bin/cryptobox.conf @@ -85,5 +85,14 @@ umount = /bin/umount nice = /usr/bin/nice super = /usr/bin/super # this is the "program" name as defined in /etc/super.tab -CryptoBoxRootActions = CryptoBoxRootActions +CryptoBoxRootActions = CryptoBoxRootActionsLocal + + +[PluginSettings] +# plugin specific settings +# the section names _must_ be the same as the names of the plugins + +## change the default network interface for the plugin "network" +#[[network]] +#interface = eth0 diff --git a/bin/run_webserver.sh b/bin/run_webserver.sh index 587e069..d4ff73c 100755 --- a/bin/run_webserver.sh +++ b/bin/run_webserver.sh @@ -2,16 +2,28 @@ # # example start script to run a local cryptobox webserver # -# we set some parameters to make it possible to run it without an existing cryptobox installation +# we set some parameters to make it possible to run it without an +# existing cryptobox installation +# +# change your local settings in "cryptobox-local.conf" - if this file +# does not exist, then "cryptobox.conf" is used # -BIN_DIR=$(cd "$(dirname $0)"; pwd) +BIN_DIR=$(dirname "$0") +BIN_DIR=$(cd "$BIN_DIR"; pwd) ## add the local python directory to the search path export PYTHONPATH="$BIN_DIR/../src" ## disable ssl detection #export HTTPS=1 +PREFERRED_CONF_FILE=$BIN_DIR/cryptobox-local.conf +FALLBACK_CONF_FILE=$BIN_DIR/cryptobox.conf + +## determine the configuration file +CONFIG_FILE=$FALLBACK_CONF_FILE +test -e "$PREFERRED_FILE" && CONFIG_FILE=$PREFERRED_CONF_FILE + ## create necessary directories mkdir -p "$BIN_DIR/../ttt/mnt" mkdir -p "$BIN_DIR/../ttt/settings" @@ -19,5 +31,5 @@ mkdir -p "$BIN_DIR/../ttt/settings" cd "$BIN_DIR" ## run the webserver -"$BIN_DIR/CryptoBoxWebserver" --config="$BIN_DIR/cryptobox.conf" --pidfile=/tmp/cryptoboxwebserver.pid --logfile=/tmp/cryptoboxwebser.log --port=8080 --datadir="$BIN_DIR/../www-data" "$@" +"$BIN_DIR/CryptoBoxWebserver" --config="$CONFIG_FILE" --pidfile=/tmp/cryptoboxwebserver.pid --logfile=/tmp/cryptoboxwebser.log --port=8080 --datadir="$BIN_DIR/../www-data" "$@" diff --git a/conf-examples/cryptobox.conf b/conf-examples/cryptobox.conf index 9024751..c72b5a5 100644 --- a/conf-examples/cryptobox.conf +++ b/conf-examples/cryptobox.conf @@ -85,3 +85,12 @@ super = /usr/bin/super # this is the "program" name as defined in /etc/super.tab CryptoBoxRootActions = CryptoBoxRootActions + +[PluginSettings] +# plugin specific settings +# the section names _must_ be the same as the names of the plugins + +## change the default network interface for the plugin "network" +#[[network]] +#interface = eth0 + diff --git a/plugins/plugin-interface.txt b/plugins/plugin-interface.txt index eda7fc2..2bbabf9 100644 --- a/plugins/plugin-interface.txt +++ b/plugins/plugin-interface.txt @@ -30,6 +30,8 @@ Python code interface: or "volume_mount" (for volume plugins)) - access the plugin's state as self.prefs - store user supplied values in the dictionary self.prefs with indices starting with "_" (e.g.: self.prefs["_automount_uuids"]) + - system wide readonly plugin settings can be specified in the main cryptobox.conf - + these settings are available as self.defaults[...] - method "get_status": - returns a string, that describes a state connected to this plugin (e.g. the current date and time (for the "date" plugin)) diff --git a/src/cryptobox/core/settings.py b/src/cryptobox/core/settings.py index 335b8d5..b534605 100644 --- a/src/cryptobox/core/settings.py +++ b/src/cryptobox/core/settings.py @@ -271,6 +271,9 @@ class CryptoBoxSettings: else: self.log.warn("configuration setting should be a section " + "name instead of a value: %s" % element_path) + elif element_path.startswith("PluginSettings->"): + ## ignore plugin settings + pass else: self.log.warn("unknown configuration setting: %s" % element_path) @@ -491,6 +494,9 @@ umount = fileExecutable(default="/bin/umount") super = fileExecutable(default="/usr/bin/super") # this is the "program" name as defined in /etc/super.tab CryptoBoxRootActions = string(min=1) + +[PluginSettings] +[[__many__]] """ pluginValidationSpec = """ diff --git a/src/cryptobox/plugins/base.py b/src/cryptobox/plugins/base.py index a323114..ec68ccf 100644 --- a/src/cryptobox/plugins/base.py +++ b/src/cryptobox/plugins/base.py @@ -64,7 +64,14 @@ class CryptoBoxPlugin: ## initialize plugin configuration self.cbox.prefs.plugin_conf[self.get_name()] = {} self.prefs = self.cbox.prefs.plugin_conf[self.get_name()] - + self.cbox.log.debug("Plugin '%s': settings " % self.get_name() + \ + "loaded from plugin configuration file: %s" % str(self.prefs)) + if self.get_name() in self.cbox.prefs["PluginSettings"]: + self.defaults = self.cbox.prefs["PluginSettings"] + else: + self.defaults = {} + self.cbox.log.debug("Plugin '%s': configuration " % self.get_name() + \ + "settings imported from global config file: %s" % str(self.defaults)) def do_action(self, **args):