#!/bin/sh # /usr/local/sbin/sync-hosts # # update either the local or remote (Windows) hosts file located on a Windows NT partition source /etc/functions-multiboot # initialize some variables # do not include a path separator at the end of the file path # edit the file paths as neccesary for your system REMOTEPATH="/mnt/nt_e/Hosts" LOCALPATH="/etc" SCRATCHPATH="/mnt/nt_o/Scratch" CheckHostsFile () { if [ "$1" = "" ] || [ "$2" = "" ] ; then echo -e "${BOLDRED}Incorrect parameters passed to the CheckHostsFile function.${COLOR_RESET}" echo -e "${BOLDWHITE}Parameter 1: ${BOLDGREEN}$1${COLOR_RESET}" echo -e "${BOLDWHITE}Parameter 2: ${BOLDGREEN}$2${COLOR_RESET}" exit 1 fi # Tell the viewers what's going to happen. MSG="Checking the $1 file." if [ "$RUNMODE" = "statusfile" ] ; then echo "update_hosts: $MSG" >> $STATUSFILE else echo -e "${BOLDWHITE}$MSG${COLOR_RESET}" fi Check_File_Exists $1 if [ "$2" = "local" ] ; then Win_To_Local else # must be remote Local_To_Win fi # enable the following for troubleshooting # Check_File_Exists $1 } # Tell the viewers what's going to happen. echo -e "${BOLDWHITE}Attempting to synchronize the hosts file.${COLOR_RESET}" if [ "$1" != "local" ] && [ "$1" != "remote" ] ; then echo -e "${BOLDRED}Error!${COLOR_RESET} The first parameter to this script must be either ${BOLDGREEN}local${COLOR_RESET} or ${BOLDGREEN}remote${COLOR_RESET}. Exiting." exit 1 fi if [ "$2" = "statusfile" ] ; then RUNMODE="$2" fi if [ `whoami` != "root" ] && [ -n "$HOME" ] ; then echo -e "You need ${BOLDGREEN}root${COLOR_RESET} privileges to run this script. Exiting." exit 1 fi Check_Mount_Path $REMOTEPATH Check_Mount_Path $SCRATCHPATH CheckHostsFile hosts $1 CheckHostsFile hosts-adservers $1 CheckHostsFile hosts-adservers-squid $1