Skip to content

Instantly share code, notes, and snippets.

@neofob
Forked from AutomationD/ramdisk-manage
Created January 28, 2016 16:10
Show Gist options
  • Save neofob/bb9f301ce93dde6152c7 to your computer and use it in GitHub Desktop.
Save neofob/bb9f301ce93dde6152c7 to your computer and use it in GitHub Desktop.
Ramdisk persitance daemon
#!/bin/sh
# /etc/init.d/ramdisk-manage
#
case "$1" in
start)
echo "Syncing files from harddisk to ramdisk"
rsync -av /var/lib/ramdisk-persisance/ /mnt/ramdisk/
echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched from HD >> /var/log/ramdisk-manage.log
;;
sync)
echo "Syncing files from ramdisk to harddisk"
echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk-manage.log
rsync -av --delete --recursive --force /mnt/ramdisk/ /var/lib/ramdisk-persisance/
;;
stop)
echo "Syncing files from ramdisk to harddisk"
echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk-manage.log
rsync -av --delete --recursive --force /mnt/ramdisk/ /var/lib/ramdisk-persisance/
;;
*)
echo "Usage: /etc/init.d/manage-ramdisk {start|stop|sync}"
exit 1
;;
esac
exit 0
update-rc.d ramdisk-manage defaults 00 99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment