|
@@ -1,5 +1,9 @@ |
|
|
#!/usr/bin/env bash |
|
|
#!/usr/bin/env bash |
|
|
|
|
|
|
|
|
|
|
|
# HTs 2024-09-25: - repeated start) (without stop) does not cause additional "mount --bind" anymore |
|
|
|
|
|
# - LOG2RAM_LOG, extended by sync_to_disk, is rescued to hdd.path |
|
|
|
|
|
# - cleanup at stop) |
|
|
|
|
|
|
|
|
. /etc/log2ram.conf |
|
|
. /etc/log2ram.conf |
|
|
|
|
|
|
|
|
if [ -z "$PATH_DISK" ]; then |
|
|
if [ -z "$PATH_DISK" ]; then |
|
@@ -51,6 +55,10 @@ sync_to_disk() { |
|
|
else |
|
|
else |
|
|
cp -rfup --sparse=always "$RAM_LOG"/ -T "$HDD_LOG"/ 2>&1 | tee -a "$LOG2RAM_LOG" |
|
|
cp -rfup --sparse=always "$RAM_LOG"/ -T "$HDD_LOG"/ 2>&1 | tee -a "$LOG2RAM_LOG" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# ++HTs 2024-09-25: LOG2RAM_LOG, extended by sync_to_disk, needs to be rescued separately |
|
|
|
|
|
cp "$LOG2RAM_LOG" "$HDD_LOG"/ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
## @fn sync_from_disk() |
|
|
## @fn sync_from_disk() |
|
@@ -127,20 +135,25 @@ start) |
|
|
HDD_LOG="${PATH_FIRST_PART}/hdd.${PATH_LAST_PART}" |
|
|
HDD_LOG="${PATH_FIRST_PART}/hdd.${PATH_LAST_PART}" |
|
|
LOG2RAM_LOG="${RAM_LOG}/${LOG_NAME}" |
|
|
LOG2RAM_LOG="${RAM_LOG}/${LOG_NAME}" |
|
|
|
|
|
|
|
|
[ -d "$HDD_LOG" ] || mkdir "$HDD_LOG" |
|
|
|
|
|
|
|
|
|
|
|
mount --bind "$RAM_LOG"/ "$HDD_LOG"/ |
|
|
|
|
|
mount --make-private "$HDD_LOG"/ |
|
|
|
|
|
wait_for "$HDD_LOG" |
|
|
|
|
|
|
|
|
|
|
|
if [ "$ZL2R" = true ]; then |
|
|
|
|
|
create_zram_log_drive |
|
|
|
|
|
mount -t ext4 -o nosuid,noexec,noatime,nodev,user=log2ram "/dev/zram${RAM_DEV}" "$RAM_LOG"/ |
|
|
|
|
|
else |
|
|
|
|
|
mount -t tmpfs -o "nosuid,noexec,noatime,nodev,mode=0755,size=${SIZE}" log2ram "$RAM_LOG"/ |
|
|
|
|
|
|
|
|
# ++HTs 2024-09-25: if HDD_LOG is already mounted, log2ram was started. mounting a second time is counterproductive |
|
|
|
|
|
mount | grep "$HDD_LOG" 2>&1 > /dev/null |
|
|
|
|
|
if [ $? != 0 ]; then |
|
|
|
|
|
# not found, it seems log2ram (for this path) is not started yet |
|
|
|
|
|
[ -d "$HDD_LOG" ] || mkdir "$HDD_LOG" |
|
|
|
|
|
|
|
|
|
|
|
mount --bind "$RAM_LOG"/ "$HDD_LOG"/ |
|
|
|
|
|
mount --make-private "$HDD_LOG"/ |
|
|
|
|
|
wait_for "$HDD_LOG" |
|
|
|
|
|
|
|
|
|
|
|
if [ "$ZL2R" = true ]; then |
|
|
|
|
|
create_zram_log_drive |
|
|
|
|
|
mount -t ext4 -o nosuid,noexec,noatime,nodev,user=log2ram "/dev/zram${RAM_DEV}" "$RAM_LOG"/ |
|
|
|
|
|
else |
|
|
|
|
|
mount -t tmpfs -o "nosuid,noexec,noatime,nodev,mode=0755,size=${SIZE}" log2ram "$RAM_LOG"/ |
|
|
|
|
|
fi |
|
|
|
|
|
wait_for "$RAM_LOG" |
|
|
|
|
|
sync_from_disk |
|
|
fi |
|
|
fi |
|
|
wait_for "$RAM_LOG" |
|
|
|
|
|
sync_from_disk |
|
|
|
|
|
done |
|
|
done |
|
|
exit 0 |
|
|
exit 0 |
|
|
;; |
|
|
;; |
|
@@ -161,6 +174,10 @@ stop) |
|
|
umount -l "$HDD_LOG"/ |
|
|
umount -l "$HDD_LOG"/ |
|
|
# Unsure as even with Root permision denied |
|
|
# Unsure as even with Root permision denied |
|
|
#echo ${ZRAM_LOG} > /sys/class/zram-control/hot_remove |
|
|
#echo ${ZRAM_LOG} > /sys/class/zram-control/hot_remove |
|
|
|
|
|
|
|
|
|
|
|
# ++HTs 2024-09-25: cleanup |
|
|
|
|
|
rm -rf "$HDD_LOG" |
|
|
|
|
|
|
|
|
done |
|
|
done |
|
|
exit 0 |
|
|
exit 0 |
|
|
;; |
|
|
;; |
|
|