summaryrefslogtreecommitdiffstats
path: root/openslx
diff options
context:
space:
mode:
authorSimon Rettberg2014-07-27 00:10:16 +0200
committerSimon Rettberg2014-07-27 00:10:16 +0200
commit62d78729a32dd136feddede21a5dc6e9c3dbe2d7 (patch)
treedccd7c833bb33825c45922397dd84d629d25f05f /openslx
parent[rfs-s31] fix busybox copying v2 (diff)
downloadtm-scripts-62d78729a32dd136feddede21a5dc6e9c3dbe2d7.tar.gz
tm-scripts-62d78729a32dd136feddede21a5dc6e9c3dbe2d7.tar.xz
tm-scripts-62d78729a32dd136feddede21a5dc6e9c3dbe2d7.zip
helpers/includes now should include an __init function and not just do stuff right away when being sourced
Diffstat (limited to 'openslx')
-rwxr-xr-xopenslx30
1 files changed, 18 insertions, 12 deletions
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."