diff --git a/modules/05-install-remap-keys.sh b/modules/05-install-remap-keys.sh index d075dee..951b9ae 100755 --- a/modules/05-install-remap-keys.sh +++ b/modules/05-install-remap-keys.sh @@ -96,10 +96,7 @@ function configure_system() { local xpcConsumerPath="${dstDir}/astzweig-xpc-consumer" local remapKeysPath="${dstDir}/remap-keys" local launchDaemonPath="/Library/LaunchDaemons/${serviceName}.plist" - [[ -d ${dstDir} ]] || { - lop -- -e "Could not install remap-keys. Directory ${dstDir} does not exist." - return 10 - } + ensurePathOrLogError ${dstDir} 'Could not install remap-keys.' || return 10 [[ -x ${remapKeysPath} ]] || indicateActivity createRemapKeysBinary 'Create remap-keys executable' [[ -x ${xpcConsumerPath} ]] || createXPCConsumer 'Create XPC event consuer' [[ -f ${launchDaemonPath} ]] || createLaunchDaemon 'Create Launch Daemon' diff --git a/modules/07-install-binaries.sh b/modules/07-install-binaries.sh index 326ebed..85fbbd0 100755 --- a/modules/07-install-binaries.sh +++ b/modules/07-install-binaries.sh @@ -9,10 +9,7 @@ function ensureRightAccess() { function configure_system() { local dstDir='/usr/local/bin' - [[ -d ${dstDir} ]] || { - lop -- -e "Could not install binaries. Directory ${dstDir} does not exist." - return 10 - } + ensurePathOrLogError ${dstDir} 'Could not install binaries.' || return 10 pushd -q ${_DIR}/../bin for file in *; do indicateActivity cp,${file},${dstDir} "Copying ${file}" @@ -24,6 +21,7 @@ function configure_system() { function getExecPrerequisites() { cmds=( [cp]='' + [install]='' ) } diff --git a/modules/lib.sh b/modules/lib.sh index 102cc8b..308fcb4 100644 --- a/modules/lib.sh +++ b/modules/lib.sh @@ -27,6 +27,14 @@ function getModuleAnswerByKeyRegEx() { return 1 } +function ensurePathOrLogError() { + local dir=$1 msg=$2 + [[ -d ${dir} ]] || install -m $(umask -S) -d $(getMissingPaths ${dir}) || { + lop -- -e "$msg" -e "Directory ${dir} does not exist and could not be created." + return 10 + } +} + function checkCommands() { local cmd for cmd in ${(k)cmds}; do diff --git a/zshlib b/zshlib index dabb512..a20db50 160000 --- a/zshlib +++ b/zshlib @@ -1 +1 @@ -Subproject commit dabb5124615eb3751b067997b7b5586765b6bd76 +Subproject commit a20db501bde1c640c1faf0d51a366f004564814a