⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatehosts.daily

📁 A* sudo sudo/* B* adduser script adduser C* rmuser script rmuser E* tout tout/*
💻 DAILY
字号:
#!/bin/csh#### updatehosts - remake and distribute hosts file as necessary.#### determines how old a file can be before it is considered unmodified..set maxthours = 1# ug+rwx modes for writing filesumask 002# get the date for figuring out whether to send diffs or the whole thingset date = `date`# munged version of date w/o colons on time...set now     = `date | sed 's/:/ /g'`# make sure we can execute fun thingsset path=(. ~ ~/bin /usr/ucb /usr/bin /usr/new /etc /bin /usr/local/bin \	/usr/local/etc /usr/hosts /usr/games /usr/local/adm/hosts/tools ) # get list of machines to distribute toset MACHINEINFO = /usr/local/etc/MACHINES# where the real hosts file lives..set HOSTFILE    = /etc/hosts# which mailer to run when bothering peopleset mail        = "/usr/ucb/mail" # list of people who like to know when host list changesset names = `cat /usr/local/adm/hosts/mailist`# someone who wants to be bothered w/errsset netadmin = coggs# list of machines to distribute to...set allhosts = \( boulder sigi tut orbit extaci euclid sol anchor piper kirk eprince \	pprince encore tigger )# find out who trusts us..#set trusted =  ( `grep -w TRUSTED ${MACHINEINFO} | awk '{print $1}' ` )# where the action is...set SRCDIR  = /usr/local/adm/hosts/hostsrccd $SRCDIR### check each section, determine if it has been changed since last time.set sections = \(`grep "DATASECTIONS =" makefile | sed 's/[A-Z]*[ 	]*=[ 		]*//'`)### max tolerable # of hours a file may be unmodified...@ maxtseconds = $maxthours * 60 * 60@ modified = 0echo ""							> /tmp/updatehostsforeach section ( $sections )	echo $section	set fileage = `cvdate -f $section`	if ($fileage < $maxtseconds) then		echo $section 				> touched-sections		@ modified++	endifendif ( $modified != 0 ) then	set sections = `cat touched-sections`	rm /tmp/updatehosts	cat << EOF					> /tmp/updatehosts.mesgThe following section(s) of the cu/boulder hosts file have been updated.$sectionsA complete copy of the file is available via anonymous ftp from boulder.colorado.eduYou may receive the complete updated hosts file by sending mail to\&'updatehosts@boulder' with a Subject: line consisting of the string\&'send'. You may receive further information on updatehosts by replacing the above 'send' with 'help'.For a complete rationalization, mail 'netadmin@boulder.colorado.edu'EOF  $mail -s "updatehosts@boulder: hosts file update: $sections" $names $netadmin \						< /tmp/updatehosts.mesg	rm /tmp/updatehosts.mesgendif### make the hosts file...#if ( $modified != 0 ) then	##	# make new hosts file	make hosts				>& /tmp/updatehosts.terr	if ($status != 0) then		goto reporterr	endif	cat /tmp/updatehosts.terr 		>> /tmp/updatehosts.err	##	# rcs it.	ci -l hosts < /dev/null 		>& /tmp/updatehosts.terr	if ($status != 0) then		goto reporterr	endif	cat /tmp/updatehosts.terr 		>> /tmp/updatehosts.err	##	# deposit copy in ~ftp/pub	cp hosts ~ftp/pub			>& /tmp/updatehosts.err	if ($status != 0) then		goto reporterr	endif	cat /tmp/updatehosts.terr 		>> /tmp/updatehosts.err	##	# stick new copy in host:/etc/hosts	cp hosts /etc/				>& /tmp/updatehosts.err	if ($status != 0) then		goto reporterr	endif	cat /tmp/updatehosts.terr 		>> /tmp/updatehosts.err	#	mkhosts /etc/hosts			>& /tmp/updatehosts.err		if ($status != 0) then	 	goto reporterr	endif	cat /tmp/updatehosts.terr 		>> /tmp/updatehosts.err		rm touched-sections	##	# distribute hosts file	#	distribhosts	endifexit(1)###reporterr:	cat /tmp/updatehosts.terr	>> /tmp/updatehosts.err	(echo "Errors:"; \	cat   /tmp/updatehosts.err ) | \	/usr/ucb/mail -s "updatehosts.daily: problems..." $netadmin	rm /tmp/updatehosts.err	exit(0)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -