Last active
February 19, 2017 12:05
-
-
Save SergeyStorm/7e1247d346bd5d494cdd54e7cc98fc19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# /etc/rc.d/init.d/exim-qtmpfs | |
# | |
# <description of the *service*> | |
# <any general comments about this init script> | |
# | |
# chkconfig: 2345 60 40 | |
# | |
# Tested on CentOS release 6.6 (Final) | |
# Source function library. | |
. /etc/init.d/functions | |
QTMPFS_PATH='/var/spool/exim/'; | |
BACKUP_PATH='/var/qtmpfs-backup/'; | |
case "$1" in | |
start) | |
pidof exim > /dev/null 2>&1 | |
if [[ $? == 0 ]]; | |
then | |
echo "Can't restore tmpfs content due to exim is already running" | |
echo [`date +"%Y-%m-%d %H:%M"`] "Can't restore tmpfs contents due to exim is already running" >> /var/log/qtmpfs_sync.log | |
else | |
echo "Copying files to tmpfs" | |
rsync -av $BACKUP_PATH $QTMPFS_PATH | |
echo [`date +"%Y-%m-%d %H:%M"`] tmpfs synched from HD >> /var/log/qtmpfs_sync.log | |
fi | |
;; | |
stop) | |
echo "Synching files from tmpfs to Harddisk" | |
echo [`date +"%Y-%m-%d %H:%M"`] tmpfs synched to HD >> /var/log/qtmpfs_sync.log | |
rsync -av --delete --recursive --force $QTMPFS_PATH $BACKUP_PATH | |
;; | |
sync) | |
echo "Synching files from tmpfs to Harddisk" | |
echo [`date +"%Y-%m-%d %H:%M"`] tmpfs synched to HD >> /var/log/qtmpfs_sync.log | |
rsync -av --delete --recursive --force $QTMPFS_PATH $BACKUP_PATH | |
;; | |
*) | |
echo "Usage: exim-qtmpfs {start|stop|sync}" | |
exit 1 | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment