add "PluginSettings" section to the main configuration file
these settings are available for plugins as self.defaults[...] run_webserver now uses "cryptobox-local.conf" ("cryptobox.conf" is the fallback)
This commit is contained in:
parent
b33263b11c
commit
ab6e34ddf9
|
@ -85,5 +85,14 @@ umount = /bin/umount
|
||||||
nice = /usr/bin/nice
|
nice = /usr/bin/nice
|
||||||
super = /usr/bin/super
|
super = /usr/bin/super
|
||||||
# this is the "program" name as defined in /etc/super.tab
|
# 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
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,28 @@
|
||||||
#
|
#
|
||||||
# example start script to run a local cryptobox webserver
|
# 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
|
## add the local python directory to the search path
|
||||||
export PYTHONPATH="$BIN_DIR/../src"
|
export PYTHONPATH="$BIN_DIR/../src"
|
||||||
## disable ssl detection
|
## disable ssl detection
|
||||||
#export HTTPS=1
|
#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
|
## create necessary directories
|
||||||
mkdir -p "$BIN_DIR/../ttt/mnt"
|
mkdir -p "$BIN_DIR/../ttt/mnt"
|
||||||
mkdir -p "$BIN_DIR/../ttt/settings"
|
mkdir -p "$BIN_DIR/../ttt/settings"
|
||||||
|
@ -19,5 +31,5 @@ mkdir -p "$BIN_DIR/../ttt/settings"
|
||||||
cd "$BIN_DIR"
|
cd "$BIN_DIR"
|
||||||
|
|
||||||
## run the webserver
|
## 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" "$@"
|
||||||
|
|
||||||
|
|
|
@ -85,3 +85,12 @@ super = /usr/bin/super
|
||||||
# this is the "program" name as defined in /etc/super.tab
|
# this is the "program" name as defined in /etc/super.tab
|
||||||
CryptoBoxRootActions = CryptoBoxRootActions
|
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
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ Python code interface:
|
||||||
or "volume_mount" (for volume plugins))
|
or "volume_mount" (for volume plugins))
|
||||||
- access the plugin's state as self.prefs
|
- 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"])
|
- 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":
|
- method "get_status":
|
||||||
- returns a string, that describes a state connected to this plugin (e.g. the current date and
|
- returns a string, that describes a state connected to this plugin (e.g. the current date and
|
||||||
time (for the "date" plugin))
|
time (for the "date" plugin))
|
||||||
|
|
|
@ -271,6 +271,9 @@ class CryptoBoxSettings:
|
||||||
else:
|
else:
|
||||||
self.log.warn("configuration setting should be a section "
|
self.log.warn("configuration setting should be a section "
|
||||||
+ "name instead of a value: %s" % element_path)
|
+ "name instead of a value: %s" % element_path)
|
||||||
|
elif element_path.startswith("PluginSettings->"):
|
||||||
|
## ignore plugin settings
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
self.log.warn("unknown configuration setting: %s" % element_path)
|
self.log.warn("unknown configuration setting: %s" % element_path)
|
||||||
|
|
||||||
|
@ -491,6 +494,9 @@ umount = fileExecutable(default="/bin/umount")
|
||||||
super = fileExecutable(default="/usr/bin/super")
|
super = fileExecutable(default="/usr/bin/super")
|
||||||
# this is the "program" name as defined in /etc/super.tab
|
# this is the "program" name as defined in /etc/super.tab
|
||||||
CryptoBoxRootActions = string(min=1)
|
CryptoBoxRootActions = string(min=1)
|
||||||
|
|
||||||
|
[PluginSettings]
|
||||||
|
[[__many__]]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pluginValidationSpec = """
|
pluginValidationSpec = """
|
||||||
|
|
|
@ -64,7 +64,14 @@ class CryptoBoxPlugin:
|
||||||
## initialize plugin configuration
|
## initialize plugin configuration
|
||||||
self.cbox.prefs.plugin_conf[self.get_name()] = {}
|
self.cbox.prefs.plugin_conf[self.get_name()] = {}
|
||||||
self.prefs = 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):
|
def do_action(self, **args):
|
||||||
|
|
Loading…
Reference in a new issue