mirror of
https://github.com/azlux/log2ram.git
synced 2023-10-10 13:37:24 +02:00
a967244a73
thank hardvk0 from armbian forum
39 lines
853 B
Bash
39 lines
853 B
Bash
#!/bin/sh
|
|
|
|
HDD_LOG=/var/log.hdd/
|
|
RAM_LOG=/var/log/
|
|
SIZE=40M
|
|
USE_RSYN=false
|
|
|
|
case "$1" in
|
|
start)
|
|
[ -d $HDD_LOG ] || mkdir $HDD_LOG
|
|
mount --bind $RAM_LOG $HDD_LOG
|
|
mount --make-private $HDD_LOG
|
|
mount -t tmpfs -o nosuid,noexec,nodev,mode=0755,size=$SIZE log2ram $RAM_LOG
|
|
if ["$USE_RSYN" = true]; then
|
|
rsync -aXWv --delete --links $HDD_LOG $RAM_LOG
|
|
else
|
|
cp -rfup $HDD_LOG -T $RAM_LOG
|
|
fi
|
|
;;
|
|
|
|
stop)
|
|
if ["$USE_RSYN" = true]; then
|
|
rsync -aXWv --delete --links $RAM_LOG $HDD_LOG
|
|
else
|
|
cp -rfup $RAM_LOG -T $HDD_LOG
|
|
fi
|
|
umount -l $RAM_LOG
|
|
umount -l $HDD_LOG
|
|
;;
|
|
|
|
write)
|
|
if ["$USE_RSYN" = true]; then
|
|
rsync -aXWv --delete --links $RAM_LOG $HDD_LOG
|
|
else
|
|
cp -rfup $RAM_LOG -T $HDD_LOG
|
|
fi
|
|
;;
|
|
esac
|