Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- # Script downloads the currently-available hosts file from OurHouse, compares MD5 of the
- # downloaded file to the MD5 of the current file. If they do not match, it replaces the
- # currently installed file with the downloaded file.
- # Checks to see how many (if any) arguments were passed. If two arguments were passed,
- # it interprets the first as a username, and the second as a password. If only one was
- # passed, it uses the currently logged in user's username, and interprets the passed
- # argument as a password. If none are passed, it uses the currently logged in username,
- # and prompts for password.
- if [ "$1" != '' ] && [ "$2" != '' ]; then
- user_name=$1
- user_password=$2
- elif [ "$1" != '' ] && [ "$2" == '' ]; then
- user_name=$USER
- user_password=$1
- else
- user_name=$USER
- read -s -p "Password: " user_password
- fi
- echo -e "\n\n"
- # cURLs hosts file from OurHouse
- cd $TMPDIR
- echo
- echo -e `curl -O --ntlm -u 'example.com\'$user_name':'$user_password http://sharepoint.example.com/path/to/hosts/file/hosts.txt`
- dl_md5=`md5 -q hosts.txt`
- inst_md5=`md5 -q /etc/hosts`
- echo -e "\n\nFile on Server Checksum: "$dl_md5
- echo -e "File on Localhost Checksum: "$inst_md5 "\n"
- if [ "$dl_md5" == "$inst_md5" ]; then
- response="is current. No need to update."
- echo -e "/etc/hosts "$response " \n"
- growlnotify -n /etc/hosts -m " " $response
- else
- response="has been updated."
- sudo cp hosts.txt /etc/hosts
- echo -e "/etc/hosts "$response " \n"
- growlnotify -n /etc/hosts -m " " $response
- fi
- # Deletes the downloaded file
- rm hosts.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement