LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
12
返回列表 发新帖
楼主: JBug

用fetchmail接收和发送gmail邮箱的邮件

[复制链接]
发表于 2006-3-9 07:32:30 | 显示全部楼层
奉献上支持chkconfig的脚本:
  1. #!/bin/bash
  2. #
  3. # fetchmail        This shell script enables the automatic use of fetchmail.
  4. # Author        An Jiangze <gnap.an AT gmail.com>
  5. #
  6. # chkconfig:        5 35 62
  7. #
  8. # description:        fetchmail daemon for automically retrive mails on remote server.
  9. # processname:        fetchmail
  10. # config: /etc/fetchmailrc
  11. . /etc/rc.d/init.d/functions
  12. lockfile=/var/lock/subsys/fetchmail
  13. RETVAL=0
  14. start() {
  15.         echo -n "Starting fetchmail..."
  16.         /usr/bin/fetchmail -f /etc/fetchmailrc && touch "$lockfile" && success || failure
  17.         RETVAL=$?
  18.         echo
  19. }
  20. stop()  {
  21.         echo -n  "Stopping fetchmail..."
  22.         killall /usr/bin/fetchmail && rm -f "$lockfile" && success || failure
  23.         RETVAL=$?
  24.         echo
  25. }
  26. restart(){
  27.         stop
  28.         sleep 1
  29.                start
  30. }
  31. case "$1" in
  32.   start)
  33.         start
  34.         ;;
  35.   stop)
  36.           stop
  37.         ;;
  38.   restart|force-reload)
  39.           restart
  40.         ;;
  41.   reload)
  42.           ;;
  43.   condrestart)
  44.           [ -f "$lockfile" ] && restart
  45.         ;;
  46.   status)
  47.           if [ -f "$lockfile" ]; then
  48.                 echo $"Fetchmail is running."
  49.                 RETVAL=0
  50.         else
  51.                 echo $"Fetchmail is not running."
  52.                 RETVAL=3
  53.         fi
  54.         ;;
  55.   *)
  56.           echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
  57.         exit 1
  58. esac
  59. exit $RETVAL
复制代码
这个脚本使你可以用chkconfig控制fetchmail的自动启动和运行级别。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表