(*
This script will set optimize your lookup order for a LAN internet connection or dial-up
*)
set runresult to ""
tell me to activate
display dialog "Please choose your connection method to optimize your internet connection" buttons {"LAN", "Dial-up"} default button 2
set userchoice to button returned of result
if userchoice = "LAN" then
set myReply to (display dialog "Please enter your Administrator password" default answer "" giving up after 60)
set myPassword to (text returned of myReply)
if myPassword is not "" then
try
--LAN optimized
do shell script "sudo /usr/bin/niutil -create / /locations/lookupd/hosts" password myPassword with administrator privileges
do shell script "sudo /usr/bin/niutil -createprop / /locations/lookupd/hosts LookupOrder CacheAgent NIAgent DNSAgent" password myPassword with administrator privileges
do shell script "sudo /bin/kill -USR1 `/bin/cat /var/run/lookupd.pid`" password myPassword with administrator privileges
set runresult to "Network settings optimized for LAN connection" & return
on error errormsj
display dialog errormsj as string
set runresult to runresult & "Settings change failed: " & errormsj & return
--return adds ASCII13 to the output
end try
end if
tell me to activate
display dialog (runresult as string) buttons {"Ok"}
else if userchoice = "Dial-up" then
set myReply to (display dialog "Please enter your Administrator password" default answer "" giving up after 60)
set myPassword to (text returned of myReply)
if myPassword is not "" then
try
--Dial-up optimized
do shell script "/usr/bin/niutil -create / /locations/lookupd/hosts" password myPassword with administrator privileges
do shell script "/usr/bin/niutil -createprop / /locations/lookupd/hosts LookupOrder CacheAgent DNSAgent NIAgent" password myPassword with administrator privileges
do shell script "/bin/kill -USR1 `/bin/cat /var/run/lookupd.pid`" password myPassword with administrator privileges
--display progress
set runresult to "Settings optimized for dial-up connection"
on error errormsj
display dialog errormsj as string
set runresult to errormsj
end try
end if
tell me to activate
display dialog ("Network Configuration:" & return & runresult) as string buttons {"Ok"}
end if