42 lines
1.4 KiB
Bash
Executable File
42 lines
1.4 KiB
Bash
Executable File
#!/bin/zsh
|
|
##########################################################################
|
|
# Shellscript : Install Microsoft Products
|
|
# Autor : Andreas Vogel, NEXT Enterprise gmbh, 2021
|
|
##########################################################################
|
|
# set -x
|
|
##################### Testing ############################################
|
|
#linkID="2093504"
|
|
#url="https://go.microsoft.com/fwlink/?linkid=2093504"
|
|
|
|
##################### Variables ##########################################
|
|
linkID="2009112"
|
|
if [ "$4" != "" ] && [ "$linkID" = "" ]
|
|
then
|
|
linkID=$4
|
|
fi
|
|
url="https://go.microsoft.com/fwlink/?linkid=$linkID"
|
|
|
|
|
|
##################### create temporary working directory #################
|
|
echo "Creating working directory '$tempDirectory'"
|
|
workDirectory=$( /usr/bin/basename $0 )
|
|
tempDirectory=$( /usr/bin/mktemp -d "/private/tmp/$workDirectory.XXXXXX" )
|
|
echo "Changing directory to working directory '$tempDirectory'"
|
|
cd "$tempDirectory"
|
|
|
|
|
|
##################### Installation and cleanup ###########################
|
|
echo "Downloading package $linkID.pkg"
|
|
/usr/bin/curl --location --silent "$url" -o "$linkID.pkg"
|
|
if /usr/sbin/installer -pkg "$linkID.pkg" -target /
|
|
then
|
|
echo "Package was installed successfully"
|
|
exitCode=0
|
|
else
|
|
echo "Error"
|
|
exitCode=1
|
|
fi
|
|
|
|
/bin/rm -Rf "$tempDirectory"
|
|
echo "Deleting working directory '$tempDirectory' and its contents"
|
|
exit $exitCode |