Use binary to install zsh libraries
This commit is contained in:
committed by
T. R. Bernstein
parent
2e5dca950e
commit
ff374e3dcc
33
bin/azw
Executable file
33
bin/azw
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# vi: set ft=zsh tw=80 ts=2
|
||||||
|
autoload -w zshlib
|
||||||
|
|
||||||
|
function dispatchToExtern() {
|
||||||
|
local cmdName="$1"
|
||||||
|
whence azw-$cmdName &> /dev/null || {
|
||||||
|
lop -- -e "Unknown command $cmdName."
|
||||||
|
exit 10
|
||||||
|
}
|
||||||
|
azw-$cmdName "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function dispatchCommand() {
|
||||||
|
local cmdName="$1"
|
||||||
|
case $cmdName in
|
||||||
|
*)
|
||||||
|
dispatchToExtern $cmdName
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
local cmdName="$1"
|
||||||
|
[[ $# -gt 1 ]] && shift
|
||||||
|
|
||||||
|
dispatchCommand $cmdName
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel || "${ZSH_EVAL_CONTEXT}" == cmdarg ]]; then
|
||||||
|
_DIR="${0:A:h}"
|
||||||
|
main "$@"
|
||||||
|
fi
|
||||||
34
bin/azw-update-zsh-libraries
Executable file
34
bin/azw-update-zsh-libraries
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# vi: set ft=zsh tw=80 ts=2
|
||||||
|
|
||||||
|
function ensureLocalBinFolder() {
|
||||||
|
local folder="/usr/local/bin"
|
||||||
|
if [[ ! -d "${folder}" ]]; then
|
||||||
|
mkdir -p "${folder}" 2> /dev/null || return 10
|
||||||
|
chown root:admin "${folder}"
|
||||||
|
chmod ug=rwx,o=rx "${folder}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function installZshlib() {
|
||||||
|
/bin/zsh -c "$(curl -fsSL https://raw.githubusercontent.com/astzweig/zshlib/main/bootstrap.sh)"
|
||||||
|
[[ -f '/usr/local/share/zsh/site-functions/zshlib.zwc' ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
function installMacOSSystemLibrary() {
|
||||||
|
local destPath=/usr/local/bin/macos-system-lib.sh
|
||||||
|
curl --output $destPath -fsSL https://raw.githubusercontent.com/astzweig/macos-system/main/modules/lib.sh
|
||||||
|
chown root:admin $destPath
|
||||||
|
chmod ugo=r $destPath
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
installZshlib
|
||||||
|
ensureLocalBinFolder || return $?
|
||||||
|
installMacOSSystemLibrary
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel || "${ZSH_EVAL_CONTEXT}" == cmdarg ]]; then
|
||||||
|
_DIR="${0:A:h}"
|
||||||
|
main "$@"
|
||||||
|
fi
|
||||||
@@ -1,29 +1,55 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# vi: set ft=zsh tw=80 ts=2
|
# vi: set ft=zsh tw=80 ts=2
|
||||||
|
|
||||||
function installZshlib() {
|
function createLaunchDaemon() {
|
||||||
/bin/zsh -c "$(curl -fsSL https://raw.githubusercontent.com/astzweig/zshlib/main/bootstrap.sh)"
|
cat > ${launchDaemonPath} <<- LDAEMON
|
||||||
[[ -f '/usr/local/share/zsh/site-functions/zshlib.zwc' ]]
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>${serviceName}</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>azw</string>
|
||||||
|
<string>update-zsh-libraries</string>
|
||||||
|
</array>
|
||||||
|
<key>StartCalendarInterval</key>
|
||||||
|
<dict>
|
||||||
|
<key>Hour</key>
|
||||||
|
<integer>11</integer>
|
||||||
|
<key>Minute</key>
|
||||||
|
<integer>22</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
LDAEMON
|
||||||
|
chown root:wheel ${launchDaemonPath}
|
||||||
|
chmod ugo=rx ${launchDaemonPath}
|
||||||
}
|
}
|
||||||
|
|
||||||
function installMacOSSystemLibrary() {
|
function enableLaunchDaemon() {
|
||||||
ensureLocalBinFolder
|
launchctl enable system/${launchDaemonPath%.*}
|
||||||
local destPath=/usr/local/bin/macos-system-lib.sh
|
launchctl bootstrap system ${launchDaemonPath}
|
||||||
cp ${ASTZWEIG_MACOS_SYSTEM_LIB} $destPath
|
}
|
||||||
chown root:admin $destPath
|
|
||||||
chmod ugo=r $destPath
|
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() {
|
function configure_system() {
|
||||||
lop -y h1 -- -i 'Install ZSh Library'
|
lop -y h1 -- -i 'Install ZSh Library'
|
||||||
indicateActivity -- 'Install zshlib' installZshlib
|
indicateActivity -- 'Install zsh libraries' azw update-zsh-libraries
|
||||||
indicateActivity -- 'Install macos-system library' installMacOSSystemLibrary
|
createLaunchdService
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExecPrerequisites() {
|
function getExecPrerequisites() {
|
||||||
cmds=(
|
cmds=(
|
||||||
[zsh]=''
|
[azw]=''
|
||||||
[curl]=''
|
[azw-update-zsh-libraries]=''
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user