#!/usr/bin/env zsh
# vi: set ft=zsh tw=80 ts=2
function createLaunchDaemon() {
cat > ${launchDaemonPath} <<- LDAEMON
Label
${serviceName}
ProgramArguments
/usr/local/bin/azw
update-zsh-libraries
StartCalendarInterval
Hour
11
Minute
22
LDAEMON
chown root:wheel ${launchDaemonPath}
chmod ugo=rx ${launchDaemonPath}
}
function enableLaunchDaemon() {
launchctl enable system/${launchDaemonPath%.*}
launchctl bootstrap system ${launchDaemonPath}
}
function createLaunchdService() {
local serviceName="de.astzweig.macos.launchdaemons.zsh-library-updater"
local launchDaemonPath="/Library/LaunchDaemons/${serviceName}.plist"
[[ -f ${launchDaemonPath} ]] || indicateActivity -- 'Create Launch Daemon' createLaunchDaemon
indicateActivity -- 'Enable Launch Daemon' enableLaunchDaemon
}
function configure_system() {
lop -y h1 -- -i 'Install ZSh Library'
indicateActivity -- 'Install zsh libraries' azw update-zsh-libraries
createLaunchdService
}
function getExecPrerequisites() {
cmds=(
[azw]=''
[azw-update-zsh-libraries]=''
)
}
function getUsage() {
read -r -d '' text <<- USAGE
Usage:
$cmdName show-questions [ ]...
$cmdName [-v] [-d FILE]
Install convenient zsh libraries system-wide for use in zsh scripts.
Options:
-d FILE, --logfile FILE Print log message to logfile instead of stdout.
-v, --verbose Be more verbose.
----
$cmdName 0.1.0
Copyright (C) 2022 Rezart Qelibari, Astzweig GmbH & Co. KG
License EUPL-1.2. There is NO WARRANTY, to the extent permitted by law.
USAGE
print -- ${text}
}
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
_DIR="${0:A:h}"
test -f "${ASTZWEIG_MACOS_SYSTEM_LIB}" || { echo 'This module requires macos-system library. Please run again with macos-system library provieded as a path in ASTZWEIG_MACOS_SYSTEM_LIB env variable.'; return 10 }
source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
module_main $0 "$@"
fi