mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-08 05:31:53 +00:00
changed fragments to .sh extension
This commit is contained in:
58
fragments/arguments.sh
Normal file
58
fragments/arguments.sh
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
# MARK: check minimal macOS requirement
|
||||
autoload is-at-least
|
||||
|
||||
if ! is-at-least 10.14 $(sw_vers -productVersion); then
|
||||
printlog "Installomator requires at least macOS 10.14 Mojave."
|
||||
exit 98
|
||||
fi
|
||||
|
||||
# MARK: argument parsing
|
||||
if [[ $# -eq 0 ]]; then
|
||||
if [[ -z $label ]]; then # check if label is set inside script
|
||||
printlog "no label provided, printing labels"
|
||||
grep -E '^[a-z0-9\_-]*(\)|\|\\)$' "$0" | tr -d ')|\' | grep -v -E '^(broken.*|longversion|version|valuesfromarguments)$' | sort
|
||||
#grep -E '^[a-z0-9\_-]*(\)|\|\\)$' "${labelFile}" | tr -d ')|\' | grep -v -E '^(broken.*|longversion|version|valuesfromarguments)$' | sort
|
||||
exit 0
|
||||
fi
|
||||
elif [[ $1 == "/" ]]; then
|
||||
# jamf uses sends '/' as the first argument
|
||||
printlog "shifting arguments for Jamf"
|
||||
shift 3
|
||||
fi
|
||||
|
||||
while [[ -n $1 ]]; do
|
||||
if [[ $1 =~ ".*\=.*" ]]; then
|
||||
# if an argument contains an = character, send it to eval
|
||||
printlog "setting variable from argument $1"
|
||||
eval $1
|
||||
else
|
||||
# assume it's a label
|
||||
label=$1
|
||||
fi
|
||||
# shift to next argument
|
||||
shift 1
|
||||
done
|
||||
|
||||
# lowercase the label
|
||||
label=${label:l}
|
||||
|
||||
printlog "################## Start Installomator v. $VERSION"
|
||||
printlog "################## $label"
|
||||
|
||||
# get current user
|
||||
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ { print $3 }')
|
||||
|
||||
|
||||
# MARK: labels in case statement
|
||||
case $label in
|
||||
version)
|
||||
# print the script VERSION
|
||||
printlog "$VERSION"
|
||||
exit 0
|
||||
;;
|
||||
longversion)
|
||||
# print the script version
|
||||
printlog "Installomater: version $VERSION ($VERSIONDATE)"
|
||||
exit 0
|
||||
;;
|
||||
Reference in New Issue
Block a user