Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # /etc/rc.d/init.d/<servicename>
  4. #
  5. # <description of the *service*>
  6. # <any general comments about this init script>
  7. #
  8. # chkconfig: 2345 60 40
  9. #
  10. # <tags -- see below for tag definitions. *Every line* from the top
  11. # of the file to the end of the tags section must begin with a #
  12. # character. After the tags section, there should be a blank line.
  13. # This keeps normal comments in the rest of the file from being
  14. # mistaken for tags, should they happen to fit the pattern.>
  15.  
  16. # Source function library.
  17. . /etc/init.d/functions
  18.  
  19. RAMDISK_PATH='/var/spool/exim/';
  20. BACKUP_PATH='/var/ramdisk-backup/';
  21.  
  22. case "$1" in
  23. start)
  24. pidof exim > /dev/null 2>&1
  25. if [[ $? == 0 ]];
  26. then
  27. echo "Can't restore ramdisk contents due to exim is already running"
  28. echo [`date +"%Y-%m-%d %H:%M"`] "Can't restore ramdisk contents due to exim is already running" >> /var/log/ramdisk_sync.log
  29. else
  30. echo "Copying files to ramdisk"
  31. rsync -av $BACKUP_PATH $RAMDISK_PATH
  32. echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched from HD >> /var/log/ramdisk_sync.log
  33. fi
  34. ;;
  35. stop)
  36. echo "Synching files from ramdisk to Harddisk"
  37. echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk_sync.log
  38. rsync -av --delete --recursive --force $RAMDISK_PATH $BACKUP_PATH
  39. ;;
  40. sync)
  41. echo "Synching files from ramdisk to Harddisk"
  42. echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk_sync.log
  43. rsync -av --delete --recursive --force $RAMDISK_PATH $BACKUP_PATH
  44. ;;
  45. *)
  46. echo "Usage: exim-ramdisk {start|stop|sync}"
  47. exit 1
  48. ;;
  49. esac
  50. exit $?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement