blob: 538c968758b196c5a68a4071952d84fbee45c4a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/bin/bash
NVMP=/tmp/.rwfs
SOMP=/var/sofs
clean_var_volatile_tmp() {
rm -rf $NVMP/.overlay/var/volatile/tmp/* || :
}
do_sync() {
rsync -a --delete --exclude='**/var/volatile/tmp/**' /tmp/.overlay/ $NVMP/.overlay
sync $NVMP/.overlay
}
stop_nv() {
history -a
do_sync
mount -o remount,ro $NVMP
mount -o remount,ro $SOMP
exit 0
}
# register cleanup function
trap stop_nv SIGINT
trap stop_nv SIGTERM
trap stop_nv EXIT
# make sure the mount points are RW
mount -o remount,rw $NVMP
mount -o remount,rw $SOMP
clean_var_volatile_tmp
# Run rsync periodically to sync the overlay to NV storage
while true; do
do_sync
sleep 10
done
|