Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1011269
  • 博文数量: 584
  • 博客积分: 2293
  • 博客等级: 大尉
  • 技术积分: 3045
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-28 11:15
文章分类

全部博文(584)

文章存档

2012年(532)

2011年(47)

2009年(5)

我的朋友

分类:

2012-02-19 01:23:48

虽然在操作系统的安装过程中可以初步指定一些配置,但很多配置需要在安装后再进行手动配置,操作多了就麻烦,而且容易手误,这个是本人多年来安装配置RHEL时使用的脚本,从RHEL4开始,到RHEL5,因为RHEL6目前手头的项目还未开始,因此,本脚本只适用于RHEL4~RHEL5.
 
本脚本可实现自动配置主机名,ip地址,掩码,网关,bond0,vsftpd,xdmcp,telnet,及ntp客户端时钟同步。如果对使用过程中的选项不太明白,可直接回车,即按默认选项操作,操作完会有关键信息反馈说明。脚本很简单,对选项不太明白的也可直接查看源码就能懂。
 
代码一共三个文件
autochg.sh
change_modprobe.conf.sh
change_vsftpd.conf.sh
 
使用方法:放在同一个目录下,执行./autochg.sh即可
 
注:建议在刚安装完操作系统后使用本脚本,若在已在线运行或已做过初始化配置的系统上执行本脚本,不保证能100%无错运行,脚本在做配置修改时会自动备份原来的配置文件。
 
界面概览
Author:$author  Host:$host      Version:$softversion    Revision:$revision
------------------------------------------------------------------------------------
This shell script can do these:
        0.modify IP-ADDRESS/BROADCAST/NETMASK
        1.modify /etc/hosts
        2.modify GATEWAY
        ---------------------------------------------
        3.configure vsftpd (/etc/vsftpd/)
        4.configure bond0 for eth0 & eth1
        5.configure telnet service
        6.configure xdmcp for xmanager(udp port 177)
        ---------------------------------------------
        7.configure ntp client
        8.auto active vsftpd,telnet,bond,xdmcp service
 
plz enter u choice [0,1,2,3,4,5,6,7,8,9,b(back),q(quit),a(all)]:"
 
脚本代码
 
1.autochg.sh
  1. #!/bin/bash
  2. LANG=C;export LANG
  3. menu()
  4. {
  5. clear
  6. author="huangyu"
  7. host=`hostname`
  8. softversion=1.6.3
  9. revision=20090305
  10. date=`date +%F.%T`
  11. # less echo,faster speed
  12. cat <
  13. ####################################################################################
  14. Author:$author Host:$host Version:$softversion Revision:$revision
  15. ------------------------------------------------------------------------------------
  16. This shell script can do these:
  17. 0.modify IP-ADDRESS/BROADCAST/NETMASK
  18. 1.modify /etc/hosts
  19. 2.modify GATEWAY
  20. ---------------------------------------------
  21. 3.configure vsftpd (/etc/vsftpd/)
  22. 4.configure bond0 for eth0 & eth1
  23. 5.configure telnet service
  24. 6.configure xdmcp for xmanager(udp port 177)
  25. ---------------------------------------------
  26. 7.configure ntp client
  27. 8.auto active vsftpd,telnet,bond,xdmcp service
  28. ####################################################################################
  29. MENULIST
  30. echo -n "plz enter u choice [0,1,2,3,4,5,6,7,8,9,b(back),q(quit),a(all)]:"
  31. read choice
  32. }
  33. ####################################################################################
  34. get_ipaddr()
  35. {
  36. ipaddra=`ifconfig -a | grep inet | grep -v inet6 | grep -v 127.0.0.1 | awk '{print $2}'`
  37. echo "IPADDR=${ipaddra#*:}" >/etc/sysconfig/network-scripts/ifcfg-tmpip
  38. for i in tmpip bond0 eth0 eth1
  39. do
  40. ipaddrb=`grep ^IPADDR /etc/sysconfig/network-scripts/ifcfg-$i 2>/dev/null`
  41. if [ ! "${ipaddrb#*=}" = "" ]
  42. then
  43. ipaddr=${ipaddrb#*=}
  44. break
  45. fi
  46. done
  47. rm -f /etc/sysconfig/network-scripts/ifcfg-tmpip 2>/dev/null
  48. if [ "$ipaddr" = "" ]
  49. then
  50. echo "this hosts has not a valid ip address"
  51. while [ "$ipaddr" = "" ]
  52. do
  53. echo -n "plz input the address:"
  54. read ipaddr
  55. done
  56. else
  57. echo -n "plz input the address[$ipaddr]:"
  58. read ipaddr1
  59. if [ ! "$ipaddr1" = "" ]
  60. then
  61. ipaddr=$ipaddr1
  62. fi
  63. fi
  64. }
  65. get_brcast()
  66. {
  67. brcasta=`ifconfig -a | grep inet | grep -v inet6 | grep -v 127.0.0.1 | awk '{print $3}'`
  68. echo "BROADCAST=${brcasta#*:}" >/etc/sysconfig/network-scripts/ifcfg-tmpip
  69. for i in tmpip bond0 eth0 eth1
  70. do
  71. brcastb=`grep ^BROADCAST /etc/sysconfig/network-scripts/ifcfg-$i 2>/dev/null`
  72. if [ ! "${brcastb#*=}" = "" ]
  73. then
  74. brcast=${brcastb#*=}
  75. break
  76. fi
  77. done
  78. rm -f /etc/sysconfig/network-scripts/ifcfg-tmpip 2>/dev/null
  79. if [ "$brcast" = "" ]
  80. then
  81. echo "this hosts has not a valid broadcast"
  82. while [ "$brcast" = "" ]
  83. do
  84. echo -n "plz input the brdcast:"
  85. read brcast
  86. done
  87. else
  88. echo -n "plz input the brdcast[$brcast]:"
  89. read brcast1
  90. if [ ! "$brcast1" = "" ]
  91. then
  92. brcast=$brcast1
  93. fi
  94. fi
  95. }
  96. get_ntmask()
  97. {
  98. ntmaska=`ifconfig -a | grep inet | grep -v inet6 | grep -v 127.0.0.1 | awk '{print $4}'`
  99. echo "NETMASK=${netmaska#*:}" >/etc/sysconfig/network-scripts/ifcfg-tmpip
  100. for i in tmpip bond0 eth0 eth1
  101. do
  102. ntmaskb=`grep ^NETMASK /etc/sysconfig/network-scripts/ifcfg-$i 2>/dev/null`
  103. if [ ! "${ntmaskb#*=}" = "" ]
  104. then
  105. ntmask=${ntmaskb#*=}
  106. break
  107. fi
  108. done
  109. rm -f /etc/sysconfig/network-scripts/ifcfg-tmpip 2>/dev/null
  110. if [ "$ntmask" = "" ]
  111. then
  112. echo "this hosts has not a valid netmask"
  113. while [ "$ntmask" = "" ]
  114. do
  115. echo -n "plz input the netmask:"
  116. read ntmask
  117. done
  118. else
  119. echo -n "plz input the netmask[$ntmask]:"
  120. read ntmask1
  121. if [ ! "$ntmask1" = "" ]
  122. then
  123. ntmask=$ntmask1
  124. fi
  125. fi
  126. }
  127. c_netinfo()
  128. {
  129. ####################################################################################
  130. echo
  131. echo -n "Do u want to configure ETH0's IP-ADDRESS?[y|n]"
  132. read myselect
  133. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  134. then
  135. unset myselect
  136. clear
  137. if [ -f /etc/sysconfig/network-scripts/ifcfg-bond0 ]
  138. then
  139. orifile=/etc/sysconfig/network-scripts/ifcfg-bond0
  140. newfile=/root/ifcfg-bond0
  141. device=bond0
  142. else
  143. orifile=/etc/sysconfig/network-scripts/ifcfg-eth0
  144. newfile=/root/ifcfg-eth0
  145. device=eth0
  146. fi
  147. get_ipaddr
  148. get_brcast
  149. get_ntmask
  150. if [ -f $orifile ]
  151. then
  152. mv $orifile ${newfile}.`date +%F-%T`
  153. fi
  154. echo "DEVICE=$device" >>$orifile
  155. echo "BOOTPROTO=none" >>$orifile
  156. echo "ONBOOT=yes" >>$orifile
  157. echo "IPADDR=$ipaddr" >>$orifile
  158. echo "BROADCAST=$brcast" >>$orifile
  159. echo "NETMASK=$ntmask" >>$orifile
  160. echo
  161. echo "the old $orifile has been backup to ${newfile}.`date +%F`"
  162. echo "the new $orifile's content is:"
  163. echo
  164. cat $orifile
  165. echo
  166. #echo -n "plz enter u choice[0,1,2,3,4,5,6,7,8,9,b(back),q(quit)]:"
  167. #read choice
  168. fi
  169. echo
  170. }
  171. c_gateway()
  172. {
  173. ####################################################################################
  174. echo -n "Do you want to configure GATEWAY?[y|n]"
  175. read myselect
  176. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  177. then
  178. unset myselect
  179. clear
  180. orifile=/etc/sysconfig/network
  181. newfile=/root/network
  182. if ! grep GATEWAY $orifile >/dev/null
  183. then
  184. while [ "$gw" = "" ]
  185. do
  186. echo -n "plz enter GATEWAY:"
  187. read gw
  188. done
  189. else
  190. echo -n "`grep GATEWAY $orifile`,plz enter new GW:"
  191. read gw
  192. fi
  193. if [ ! "$gw" = "" ]
  194. then
  195. #sed "/GATEWAY/d" $orifile | sed "$ a\GATEWAY=$gw" >$newfile
  196. #the bellow line is better,more fast
  197. (sed "/GATEWAY/d" $orifile;echo GATEWAY=$gw) >$newfile
  198. cp $newfile $orifile
  199. fi
  200. echo
  201. echo "the new $orifile file's content:"
  202. echo
  203. cat $orifile
  204. echo
  205. fi
  206. echo
  207. }
  208. c_hosts()
  209. {
  210. ####################################################################################
  211. echo -n "Do you want to configure /etc/hosts file?[y|n]"
  212. read myselect
  213. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  214. then
  215. unset myselect
  216. clear
  217. get_ipaddr
  218. cp /etc/hosts /root/hosts.`date +%F-%T`
  219. sed "/127.0.0.1/s/$HOSTNAME//" /etc/hosts | sed "/$ipaddr/d" \
  220. | sed "$ a\\$ipaddr $HOSTNAME" >/root/hosts
  221. cp /root/hosts /etc/hosts
  222. echo "the new /etc/hosts file's content:"
  223. echo
  224. cat /etc/hosts
  225. echo
  226. fi
  227. echo
  228. }
  229. c_vsftpd()
  230. {
  231. #################################################################################
  232. echo "Do you want to configure vsftpd?[y|n]"
  233. echo " 1.disable anonymous user access"
  234. echo " 2.lock user in his home directory"
  235. echo " 3.change vsftp's running type to be standalone or a xinetd service"
  236. echo " and first time u don't need to assign it."
  237. echo
  238. echo -n "Do you want to configure vsftpd?[y|n]"
  239. read myselect
  240. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  241. then
  242. unset myselect
  243. clear
  244. echo "========== begin to modify /etc/vsftpd/vsftpd.conf ==========="
  245. echo
  246. filename=/etc/vsftpd/vsftpd.conf
  247. newfile=/root/vsftpd.conf
  248. cmdfile=${0%%/*}/change_vsftpd.conf.sh
  249. if [ -d /etc/vsftpd ]
  250. then
  251. echo -n "do u want vsftpd to be a xinetd service? default is ignore. [y|n|i]:"
  252. read se_type
  253. $cmdfile $filename >$newfile
  254. cp $filename $filename.`date +%F-%T`
  255. if [ "$se_type" = "y" ];then
  256. service vsftpd stop
  257. sed "s/^listen=YES/listen=NO/" $newfile >$filename
  258. sed "/disable/c\ disable = no" /usr/share/doc/vsftpd*/vsftpd.xinetd >/etc/xinetd.d/vsftpd
  259. elif [ "$se_type" = "n" ];then
  260. service vsftpd stop
  261. sed "s/^listen=NO/listen=YES/" $newfile >$filename
  262. rm /etc/xinetd.d/vsftpd
  263. else
  264. cp $newfile $filename
  265. fi
  266. awk -F':' '($3>=500&&$3<600){print $1}' /etc/passwd > /etc/vsftpd/chroot_list
  267. #use sed can do also. but up-line is good.
  268. #sed -n "`sed -n '/500:500/=' /etc/passwd`,$ p" /etc/passwd \
  269. # | awk -F : '{print $1}' > /etc/vsftpd/chroot_list
  270. echo "the original file is bakup to $filename.`date +%F`..."
  271. echo
  272. echo "the key point:"
  273. echo
  274. echo "`grep anonymous_enable $filename`"
  275. echo "`grep chroot $filename`"
  276. if [ "$se_type" = "y" ];then echo "`grep ^listen $filename`";fi
  277. echo
  278. echo "the /etc/vsftpd/chroot_list file's contenti:"
  279. cat /etc/vsftpd/chroot_list
  280. else
  281. echo "you have not insatlled vsftpd service."
  282. echo "waiting 3 seconds..."
  283. sleep 3
  284. continue
  285. fi
  286. echo
  287. echo -n 'do u want to permit "root" user using vsftp? default is ignore. {y|n} [n]: '
  288. read ftp_type
  289. if [ "$ftp_type" = "y" ];then
  290. #-------for RHEL 4---------------------
  291. if [ -f /etc/vsftpd.ftpusers ]; then sed -i "/root/ c\#root" /etc/vsftpd.ftpusers; fi
  292. if [ -f /etc/vsftpd.user_list ]; then sed -i "/root/ c\#root" /etc/vsftpd.user_list; fi
  293. #-------for RHEL 5---------------------
  294. if [ -f /etc/vsftpd/ftpusers ]; then sed -i "/root/ c\#root" /etc/vsftpd/ftpusers; fi
  295. if [ -f /etc/vsftpd/user_list ]; then sed -i "/root/ c\#root" /etc/vsftpd/user_list; fi
  296. else
  297. #-------for RHEL 4---------------------
  298. if [ -f /etc/vsftpd.ftpusers ]; then sed -i "/#root/ c\root" /etc/vsftpd.ftpusers; fi
  299. if [ -f /etc/vsftpd.user_list ]; then sed -i "/#root/ c\root" /etc/vsftpd.user_list; fi
  300. #-------for RHEL 5---------------------
  301. if [ -f /etc/vsftpd/ftpusers ]; then sed -i "/#root/ c\root" /etc/vsftpd/ftpusers; fi
  302. if [ -f /etc/vsftpd/user_list ]; then sed -i "/#root/ c\root" /etc/vsftpd/user_list; fi
  303. fi
  304. echo "The configuration of vsftp about root user has been changed successful."
  305. fi
  306. echo
  307. }
  308. c_bond()
  309. {
  310. ###########################################################################
  311. echo -n "Do you want to configure modprobe.conf for bonding?[y|n]"
  312. read myselect
  313. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  314. then
  315. unset myselect
  316. clear
  317. echo "========== begin to modify /etc/modprobe.conf ==========="
  318. echo
  319. #sleep 1
  320. filename=/etc/modprobe.conf
  321. newfile=/root/modprobe.conf
  322. cmdfile=${0%%/*}/change_modprobe.conf.sh
  323. grep bond0 /etc/modprobe.conf >/dev/null
  324. if [ $? = 1 ]
  325. then
  326. echo -n "Plz input the bonding mode,default is 1.[1|0]"
  327. read bmode
  328. if [ "$bmode" = "" ];then bmode=1;fi
  329. $cmdfile $filename >$newfile
  330. mv $filename $filename.`date +%F-%T`
  331. sed "s/mode=0/mode=$bmode/" $newfile >$filename
  332. echo "$filename has been modified."
  333. echo "the original file is bakup to $filename.`date +%F`..."
  334. else
  335. echo "this hosts has been using bonding mode,nothing to changed."
  336. echo "the $filename file's content:"
  337. cat /etc/modprobe.conf
  338. fi
  339. echo
  340. echo
  341. orieth0=/etc/sysconfig/network-scripts/ifcfg-eth0
  342. orieth1=/etc/sysconfig/network-scripts/ifcfg-eth1
  343. oribond=/etc/sysconfig/network-scripts/ifcfg-bond0
  344. neweth0=/root/ifcfg-eth0
  345. neweth1=/root/ifcfg-eth1
  346. newbond=/root/ifcfg-bond0
  347. if [ -f $oribond ]
  348. then
  349. cp $oribond $newbond.`date +%F-%T`
  350. fi
  351. if [[ ! ( ! "$ipaddr" = "" && ! "$brcast" = "" && ! "$netmask" = "" ) ]]
  352. then
  353. get_ipaddr
  354. get_brcast
  355. get_ntmask
  356. fi
  357. echo "DEVICE=bond0" >$oribond
  358. echo "BOOTPROTO=none" >>$oribond
  359. echo "ONBOOT=yes" >>$oribond
  360. echo "IPADDR=$ipaddr" >>$oribond
  361. echo "BROADCAST=$brcast" >>$oribond
  362. echo "NETMASK=$ntmask" >>$oribond
  363. if [ -f $orieth0 ]
  364. then
  365. mv $orieth0 $neweth0.`date +%F-%T`
  366. fi
  367. if [ -f $orieth1 ]
  368. then
  369. mv $orieth1 $neweth1.`date +%F-%T`
  370. fi
  371. echo "DEVICE=eth0" >>$orieth0
  372. echo "BOOTPROTO=none" >>$orieth0
  373. echo "ONBOOT=yes" >>$orieth0
  374. echo "MASTER=bond0" >>$orieth0
  375. echo "SLAVE=yes" >>$orieth0
  376. echo "DEVICE=eth1" >>$orieth1
  377. echo "BOOTPROTO=none" >>$orieth1
  378. echo "ONBOOT=yes" >>$orieth1
  379. echo "MASTER=bond0" >>$orieth1
  380. echo "SLAVE=yes" >>$orieth1
  381. echo
  382. echo "cat $oribond"
  383. cat $oribond
  384. echo
  385. echo "cat $orieth0"
  386. cat $orieth0
  387. echo
  388. echo "cat $orieth1"
  389. cat $orieth1
  390. echo
  391. fi
  392. echo
  393. }
  394. c_telnet()
  395. {
  396. ############################################################################
  397. echo -n "Do you want to configure telnet service?[y|n]"
  398. read myselect
  399. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  400. then
  401. unset myselect
  402. clear
  403. orifile=/etc/xinetd.d/telnet
  404. newfile=/root/telnet
  405. echo "========== begin to modify $orifile ==========="
  406. echo
  407. if [ -f $orifile ]
  408. then
  409. cp $orifile $newfile.`date +%F-%T`
  410. sed "/disable/c\ disable = no" $orifile >$newfile
  411. cp $newfile $orifile
  412. echo "the new telnet file content:"
  413. echo
  414. cat $orifile
  415. else
  416. echo "you have not install telnet service"
  417. fi
  418. echo
  419. fi
  420. echo
  421. echo -n "Do you want to permit root using telnet to login the system? {y|n} [n] "
  422. read myselect
  423. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  424. then
  425. unset myselect
  426. clear
  427. pts_counts=$(grep pts /etc/securetty |wc -l)
  428. if [ $pts_counts -eq 0 ]
  429. then
  430. echo pts/1 >>/etc/securetty
  431. echo pts/2 >>/etc/securetty
  432. echo pts/3 >>/etc/securetty
  433. echo pts/4 >>/etc/securetty
  434. echo pts/5 >>/etc/securetty
  435. echo "the /etc/securetty file has been changed now."
  436. echo "Permit total 5 root accounts direct using telnet to login to system concurrent."
  437. else
  438. echo "the current configuration has permit root direct login to the system."
  439. echo "and the max concurrent number is $pts_counts."
  440. echo "nothing has changed."
  441. fi
  442. echo
  443. fi
  444. echo
  445. }
  446. c_xdmcp()
  447. {
  448. ############################################################################
  449. echo -n "Do you want to configure remote x-windows service?[y|n]"
  450. read myselect
  451. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  452. then
  453. unset myselect
  454. clear
  455. version=`sed -n "/release 4/p" /etc/redhat-release | wc -l`
  456. if [ $version = 1 ]
  457. then
  458. oritab=/etc/inittab
  459. newtab=/root/inittab
  460. origdm=/etc/X11/gdm/gdm.conf
  461. newgdm=/root/gdm.conf
  462. echo "========== begin to modify $oritab & $origdm ==========="
  463. echo
  464. if grep ^x:5:respawn:/usr/bin/gdm $oritab >/dev/null
  465. then
  466. echo "the $oritab has been configured.no need configure more"
  467. else
  468. cp $oritab $newtab.`date +%F-%T`
  469. sed "/x:5:respawn/c\x:5:respawn:\/usr\/bin\/gdm" $oritab >$newtab
  470. cp $newtab $oritab
  471. echo "the new $oritab 's content changed:"
  472. echo " x:5:respawn:/usr/bin/gdm"
  473. echo
  474. fi
  475. if [ -f $origdm ]
  476. then
  477. cp $origdm $newgdm.`date +%F-%T`
  478. #enum=(`sed -n "/^Enable=/ =" $origdm`)
  479. #xnum=(`sed -n "/^\[xdmcp\]/ =" $origdm`)
  480. #sed "${enum[0]} c\Enable=true" $origdm >$newgdm
  481. sed "`sed -n '/^Enable=/=' $origdm | sed -n '1p'` c\Enable=true" $origdm >$newgdm
  482. cp $newgdm $origdm
  483. echo "the new ${origdm} 's content:"
  484. echo " the line ${enum[0]} has been change to 'Enable=true'"
  485. else
  486. echo "you have not install X11 service"
  487. fi
  488. else
  489. #oritab=/etc/inittab
  490. #newtab=/root/inittab
  491. origdm=/etc/gdm/custom.conf
  492. newgdm=/root/custom.conf
  493. echo "========== begin to modify $oritab & $origdm ==========="
  494. echo
  495. if [ -f $origdm ]
  496. then
  497. cp $origdm $newgdm.`date +%F-%T`
  498. sed -i '/^\Enable=/d' $origdm
  499. sed -i '/^\[xdmcp\]/ a\Enable=true' $origdm
  500. sed -i '/^\AllowRemoteRoot/d' $origdm
  501. sed -i '/^\[security\]/ a\AllowRemoteRoot=true' $origdm
  502. gdmgreeter=$(grep 'RemoteGreeter=/usr/libexec/gdmgreeter' /etc/gdm/custom.conf|wc -l)
  503. if [ $gdmgreeter = 0 ]
  504. then
  505. sed -i '/^\[daemon\]/ a\RemoteGreeter=/usr/libexec/gdmgreeter' $origdm
  506. fi
  507. echo "the new ${origdm} has been changed by follow:"
  508. echo " Enable=true"
  509. echo " AllowRemoteRoot=true"
  510. else
  511. echo "you have not install X11 service"
  512. fi
  513. echo
  514. echo "NOTE:"
  515. echo "your redhat linux system version is 5."
  516. echo "if this configuration can not work after system reboot,"
  517. echo "you can restore the original file from /root/ directory"
  518. echo "then login to the GUI, run gdmsetup"
  519. echo "or"
  520. echo "click 'system->management-->login screen'"
  521. echo "then,click 'remote' and 'secure' tab to configure xdmcp"
  522. fi
  523. echo
  524. fi
  525. echo
  526. }
  527. c_ntp()
  528. {
  529. ############################################################################
  530. echo -n "Do you want to configure ntp client?[y|n]"
  531. read myselect
  532. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  533. then
  534. unset myselect
  535. clear
  536. orifile=/var/spool/cron/root
  537. newfile=/root/root
  538. if [ -f $orifile ]
  539. then
  540. sed "/ntpdate/d" $orifile > $newfile
  541. else
  542. touch $orifile
  543. fi
  544. if grep ntpdate $orifile > /dev/null
  545. then
  546. for i in `sed -n '/ntpdate/p' $orifile | awk '{print $7}'`
  547. do
  548. ((num++))
  549. echo -n "enter the new ntp server ip-addr. server $num's ip [$i]:"
  550. #read ntpip[$num]
  551. read ntpip
  552. if [ "$ntpip" = "" ]
  553. then
  554. ntpip=$i
  555. fi
  556. echo "$num * * * * /usr/sbin/ntpdate $ntpip" >> $newfile
  557. done
  558. unset num
  559. else
  560. echo "you can assign max three ntp server's ip!"
  561. echo
  562. for ((i=0;i<3;i++))
  563. do
  564. echo -n "enter the new ntp server ip-addr:"
  565. read ntpip
  566. if [ ! "$ntpip" = "" ]
  567. then
  568. echo "$i * * * * /usr/sbin/ntpdate $ntpip" >> $newfile
  569. fi
  570. done
  571. fi
  572. cp $newfile $orifile
  573. echo
  574. echo "the new root's crontab is"
  575. crontab -l
  576. echo
  577. fi
  578. echo
  579. }
  580. c_autostart()
  581. {
  582. ############################################################################
  583. echo -n "Do you want to active vsftpd service now? {y|n} [n] "
  584. read myselect
  585. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  586. then
  587. unset myselect
  588. clear
  589. if [ "$se_type" = "y" ];then
  590. service xinetd restart
  591. else
  592. chkconfig vsftpd on
  593. service vsftpd restart
  594. fi
  595. fi
  596. echo
  597. ############################################################################
  598. echo -n "Do you want to active telnet service now? {y|n} [n] "
  599. read myselect
  600. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  601. then
  602. unset myselect
  603. clear
  604. service xinetd restart
  605. fi
  606. echo
  607. ############################################################################
  608. echo -n "Do you want to active bonding now? {y|n} [n] "
  609. read myselect
  610. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  611. then
  612. unset myselect
  613. clear
  614. service network restart
  615. fi
  616. echo
  617. ############################################################################
  618. echo "Caution:the following operation will cause you log out the GUI destop!"
  619. echo -n "Do you want to active xdmcp now? {y|n} [n] "
  620. read myselect
  621. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  622. then
  623. unset myselect
  624. clear
  625. /usr/sbin/gdm-restart
  626. echo "the xdmcp/gdm has been restart."
  627. fi
  628. echo
  629. }
  630. ############################################################################
  631. for ((i=1;;i++))
  632. do
  633. menu
  634. case "$choice" in
  635. "0")
  636. c_netinfo
  637. ;;
  638. "1")
  639. c_hosts
  640. ;;
  641. "2")
  642. c_gateway
  643. ;;
  644. "3")
  645. c_vsftpd
  646. ;;
  647. "4")
  648. c_bond
  649. ;;
  650. "5")
  651. c_telnet
  652. ;;
  653. "6")
  654. c_xdmcp
  655. ;;
  656. "7")
  657. c_ntp
  658. ;;
  659. "8")
  660. c_autostart
  661. ;;
  662. "9")
  663. ;;
  664. "a")
  665. c_netinfo
  666. c_gateway
  667. c_hosts
  668. c_vsftpd
  669. c_bond
  670. c_telnet
  671. c_xdmcp
  672. c_ntp
  673. c_autostart
  674. exit 0
  675. ;;
  676. "b")
  677. unset choice
  678. ;;
  679. "q")
  680. exit 0
  681. ;;
  682. esac
  683. if [ ! "$choice" = "" ]
  684. then
  685. echo "press any key to return!"
  686. read
  687. fi
  688. done
2
  1. #!/bin/sed -f
  2. $ a\alias bond0 bonding\
  3. options bond0 miimon=100 mode=0
3
  1. #!/bin/sed -f
  2. #to call:sripte_name /etc/vsftpd/vsftpd.conf
  3. /anonymous_enable=YES/ c\anonymous_enable=NO
  4. /#chroot_list_enable=YES/ c\#orig_line chroot_list_enable=YES\
  5. chroot_local_user=YES
  6. /chroot_list_file=\/etc\/vsftpd/ c\chroot_list_file=\/etc\/vsftpd\/chroot_list
其实,后2个辅助脚本完全可以融合在主脚本中,懒得的修改了,浅薄之作,望不吝赐教~
 
 
阅读(844) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~