diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/funcs.sh | 17 | ||||
-rw-r--r-- | lib/hooks.sh | 18 |
2 files changed, 24 insertions, 11 deletions
diff --git a/lib/funcs.sh b/lib/funcs.sh index 2126e9a..0122c60 100644 --- a/lib/funcs.sh +++ b/lib/funcs.sh @@ -100,17 +100,12 @@ choose_target() { fi } -housekeeping() { - git submodule init - git submodule update - - #.files is used to tell scripts where to look for the dotfiles - [ -f "$HOME/.files" ] && source "$HOME/.files" - if [ "$DOTFILEBASE" != "$(pwd)" ] && yes_no "'.files' out of date. Regenerate?"; then - echo "DOTFILEBASE=\"$(pwd)\"" > $HOME/.files +debug() { + if [ "$DEBUG" = "yes" ]; then + echo "[DEBUG] $@" fi +} - if [ ! -f "$HOME/.files.config" ] && yes_no ".files.config does not exist. Populate with defaults?"; then - cp "config.default" "$HOME/.files.config" - fi +warning() { + echo "[WARNING] $@" } diff --git a/lib/hooks.sh b/lib/hooks.sh new file mode 100644 index 0000000..8d5fc1d --- /dev/null +++ b/lib/hooks.sh @@ -0,0 +1,18 @@ +# Functions for hooks + +# 1: Name of hook +call_hook() { + if [ ! -x "hooks/$1.hook" ]; then + debug "$1.hook was not found. Skipping." + return + fi + + debug "Running hook $1" + + hooks/$1.hook 2>&1 | (while read line; do echo [hook: $1] $line; done) + RET=${PIPESTATUS[0]} + + if [ $RET -ne 0 ]; then + warning "Hook $1 exitet with code $RET" + fi +} |