Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # /etc/rc.d/init.d/<servicename>
- #
- # <description of the *service*>
- # <any general comments about this init script>
- #
- # chkconfig: 2345 60 40
- #
- # <tags -- see below for tag definitions. *Every line* from the top
- # of the file to the end of the tags section must begin with a #
- # character. After the tags section, there should be a blank line.
- # This keeps normal comments in the rest of the file from being
- # mistaken for tags, should they happen to fit the pattern.>
- # Source function library.
- . /etc/init.d/functions
- RAMDISK_PATH='/var/spool/exim/';
- BACKUP_PATH='/var/ramdisk-backup/';
- case "$1" in
- start)
- pidof exim > /dev/null 2>&1
- if [[ $? == 0 ]];
- then
- echo "Can't restore ramdisk contents due to exim is already running"
- echo [`date +"%Y-%m-%d %H:%M"`] "Can't restore ramdisk contents due to exim is already running" >> /var/log/ramdisk_sync.log
- else
- echo "Copying files to ramdisk"
- rsync -av $BACKUP_PATH $RAMDISK_PATH
- echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched from HD >> /var/log/ramdisk_sync.log
- fi
- ;;
- stop)
- echo "Synching files from ramdisk to Harddisk"
- echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk_sync.log
- rsync -av --delete --recursive --force $RAMDISK_PATH $BACKUP_PATH
- ;;
- sync)
- echo "Synching files from ramdisk to Harddisk"
- echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk_sync.log
- rsync -av --delete --recursive --force $RAMDISK_PATH $BACKUP_PATH
- ;;
- *)
- echo "Usage: exim-ramdisk {start|stop|sync}"
- exit 1
- ;;
- esac
- exit $?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement