From 62d78729a32dd136feddede21a5dc6e9c3dbe2d7 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sun, 27 Jul 2014 00:10:16 +0200 Subject: helpers/includes now should include an __init function and not just do stuff right away when being sourced --- openslx | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'openslx') diff --git a/openslx b/openslx index 6f683757..e4039dd3 100755 --- a/openslx +++ b/openslx @@ -28,21 +28,26 @@ qnd_exit() { } # source all helper unit files that are found under helper/*.inc -# these are general and used by "mltk" and "openslx" -for HELPER in "$ROOT_DIR"/helper/*.inc; do - . "$HELPER" && continue - unset_quiet - echo "Could not source $HELPER" - qnd_exit -done - -# source specific units only used by openslx -for HELPER in "$ROOT_DIR"/server/includes/*.inc; do - . "$HELPER" && continue +# or remote/includes/*.inc +# a helper unit may contain a function called "__init" which will be called +# after all helpers have been sourced. +for HELPER in "$ROOT_DIR"/helper/*.inc "$ROOT_DIR"/server/includes/*.inc; do + SHORT=${HELPER%.inc} + SHORT="_init_${SHORT##*/}" + . <(sed "s/^__init/$SHORT/" "$HELPER") && continue unset_quiet echo "Could not source $HELPER" qnd_exit done +# called below, after initial_checks +init_helpers () { + # in case the helers have init functions, call them now + for HELPER in "$ROOT_DIR"/helper/*.inc "$ROOT_DIR"/server/includes/*.inc; do + SHORT=${HELPER%.inc} + SHORT="_init_${SHORT##*/}" + type -t "$SHORT" | grep -q '^function$' && "$SHORT" + done +} banner () { @@ -134,7 +139,7 @@ check_devtools() { initial_checks() { if [ "x$(whoami)" != "xroot" ]; then - perror "ERROR: You need to have root rights to install packages." + perror "ERROR: You need to have root rights for proper rsync/mksquashfs." exit 1 else banner @@ -255,6 +260,7 @@ SERVER_CONFIG="0" initial_checks || perror "initial_checks failed." read_params $@ || perror "read_params failed." +init_helpers check_devtools || perror "check_devtools failed." -- cgit v1.2.3-55-g7522