Hi,
I have about 50 macs and i wish to control it with puppet software. I need a script that will install puppet on macs in one click (if not installed before).
I never used applescript before so I googled a bit and wrote a following code:
When i'm trying to run i'm getting the error
Any suggestions?
I have about 50 macs and i wish to control it with puppet software. I need a script that will install puppet on macs in one click (if not installed before).
I never used applescript before so I googled a bit and wrote a following code:
Code:
#!/bin/bash
FULLSTRING=""
# Mounting share
mkdir /Volumes/MacInstall
if ! (mount | grep 'MacInstall.*afpfs' > /dev/null); then
if ! (mount_afp afp://192.168.1.2/MacInstall /Volumes/MacInstall/); then
osascript -e 'tell application "SystemUIServer" to display alert "ERROR!" message "Some error ocuured. Call admin"'
exit 33
fi
fi
# Checking installed soft (dmg)
for dmgname in `ls /Volumes/MacInstall/ |grep .dmg$`; do
searchname="com.puppetlabs.`echo "$dmgname" | cut -d - -f 1`"
pkgname=`echo $dmgname | cut -d - -f 1`
if ! (pkgutil --pkgs |grep $searchname > /dev/null); then
FULLSTRING="${FULLSTRING}$pkgname "
fi
done
sleep 1
if [ -n "$FULLSTRING" ]; then
#Checking user password
osascript $FULLSTRING <<EOF
set the current_user to (get the long user name of (system info)) as string
repeat
tell application "SystemUIServer"
set answer to text returned of (display dialog "Enter your password" with icon caution default answer "" with hidden answer)
end tell
try
tell application "SystemUIServer" to do shell script "true" user name the current_user password answer with administrator privileges
exit repeat
on error --incorrect password
tell application "SystemUIServer" to display dialog "Sorry. You entered the wrong password." buttons{"Try Again","Cancel"}
end try
end repeat
#Installing software
on run argv
repeat with var from 1 to (count of argv)
do shell script "hdiutil mount /Volumes/MacInstall/" & item var of argv & ".dmg -mountpoint /Volumes/TempAppInstall"
do shell script "installer -package /Volumes/TempAppInstall/" & item var of argv & ".pkg" user name the current_user password answer with administrator privileges
end repeat
end run
EOF
fi
umount /Volumes/MacInstall
Code:
syntax error: The run handler is specified more than once, or there were top-level commands in addition to the run handler. (-2752)
Last edited: