Friday 9 May 2014

Setting firefox preferences in macs for Oracle SSO to work.

#!/bin/bash
#Written by Tausif for FICO
#RESULT!
bloke=$(ls -l /dev/console | awk '{print $3}' )
place=$(sudo dscl . -read /Users/$bloke NFSHomeDirectory | awk '{print $2}')
logFile="/private/var/log/ff-mod.log"
log () {
echo $1
echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile
}

set(){



if grep 'network.negotiate-auth.trusted-uris' /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js;
then
sudo sed '/network.negotiate-auth.trusted-uris/d' /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js > /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js.e;
echo 'user_pref("network.negotiate-auth.trusted-uris", "http://,https://");' >> /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js.e;
mv /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js.e /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js
log "USER $bloke: network.negotiate-auth.trusted-uris is now set to http using SED";
else
echo 'user_pref("network.negotiate-auth.trusted-uris", "http://,https://");' >> /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js;
     log "USER $bloke: network.negotiate-auth.trusted-uris is now set to http";

fi
if grep 'network.negotiate-auth.gsslib' /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js;
then
sudo sed '/network.negotiate-auth.gsslib/d' /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js > /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js.e;
echo 'user_pref("network.negotiate-auth.gsslib", "1");' >> /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js.e;
mv /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js.e /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js
log "USER $bloke: network.negotiate-auth.gsslib is now set to 1 using SED";
else
echo 'user_pref("network.negotiate-auth.gsslib", "1");' >> /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js;
     log "USER $bloke: network.negotiate-auth.gsslib is now set to 1";

fi
if grep 'network.negotiate-auth.delegation-uris' /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js;
then
sudo sed '/network.negotiate-auth.delegation-uris/d' /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js > /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js.e;
echo 'user_pref("network.negotiate-auth.delegation-uris", "http://,https://");' >> /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js.e;
mv /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js.e /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js
log "USER $bloke: network.negotiate-auth.delegation-uris is now set to http using SED";
else
echo 'user_pref("network.negotiate-auth.delegation-uris", "http://,https://");' >> /Applications/Firefox.app/Contents/MacOS/defaults/pref/channel-prefs.js;
    log "USER $bloke: network.negotiate-auth.delegation-uris is now set to http";

fi
}


pset(){
bloke=$(ls -l /dev/console | awk '{print $3}' )
place=$(sudo dscl . -read /Users/$bloke NFSHomeDirectory | awk '{print $2}')
#Get an array of all users
declare -a userarray
userarray=$(sudo /usr/bin/dscl . list /Users UniqueID | awk '$2 >= 500 && $2 < 100000000000000000 { print $1; }')
#Iterate through the array of all users
for i in ${userarray[@]};
do
if [ -d $place/Library/Application\ Support/Firefox/Profiles ];
then
#Get an array of all profiles under this User for Firefox
declare -a parray
parray=( `ls $place/Library/Application\ Support/Firefox/Profiles | grep -v DS_Store` )
for p in ${parray[@]};
do
if grep 'network.negotiate-auth.trusted-uris' $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js;
then
sudo sed '/network.negotiate-auth.trusted-uris/d' $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js > $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js.e;
echo 'user_pref("network.negotiate-auth.trusted-uris", "http://,https://");' >> $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js.e;
mv $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js.e $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js;
log "USER $bloke: network.negotiate-auth.trusted-uris is now set to http using SED";
else
echo 'user_pref("network.negotiate-auth.trusted-uris", "http://,https://");' >> $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js;
log "USER $bloke: network.negotiate-auth.trusted-uris is now set to http";
fi
if grep 'network.negotiate-auth.gsslib' $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js;
then
sudo sed '/network.negotiate-auth.gsslib/d' $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js > $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js.e;
echo 'user_pref("network.negotiate-auth.gsslib", "1");' >> $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js.e;
mv $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js.e $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js;
log "USER $bloke: network.negotiate-auth.gsslib is now set to 1 using SED";
else
echo 'user_pref("network.negotiate-auth.gsslib", "1");' >> $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js;
log "USER $bloke: network.negotiate-auth.gsslib is now set to 1";
fi
if grep 'network.negotiate-auth.delegation-uris' $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js;
then
sudo sed '/network.negotiate-auth.delegation-uris/d' $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js > $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js.e;
echo 'user_pref("network.negotiate-auth.delegation-uris", "http://,https://");' >> $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js.e;
mv $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js.e $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js;
log "USER $bloke: network.negotiate-auth.delegation-uris is now set to http using SED";
else
echo 'user_pref("network.negotiate-auth.delegation-uris", "http://,https://");' >> $place/Library/Application\ Support/Firefox/Profiles/$p/prefs.js;
log "USER $bloke: network.negotiate-auth.delegation-uris is now set to http";
fi
done
fi
done

}

killFirefox(){

#LoginWindowPID=`pgrep firefox`; This command only works with 10.8 machines
ps -ax | grep -i "Firefox.app" | grep -v grep
if [ $? == 0 ];
then
firefoxPID=`ps -ax | grep -i firefox | head -1 | cut -d "?" -f1 | sed 's/^[ \t]*//;s/[ \t]*$//'`;
kill -9 $firefoxPID
log "Killing Firefox"
fi

}

killFirefox;
set;
pset;

exit 0;

No comments:

Post a Comment

Detect autopilot session

  Ensuring that some apps only install during autopilot is not easily accomplished, you can use the below powershell script as a requiremen...