-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread-only-config.sh
More file actions
65 lines (53 loc) · 1.68 KB
/
read-only-config.sh
File metadata and controls
65 lines (53 loc) · 1.68 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# Remove sd card writes by linking to tmpfs files.
# Logic for fake-hwclock updates.
#
# sudo cp ~/bin/shellscripts/read-only-config.sh /etc/systemd/system
# sudo cp ~/bin/shellscripts/read-only-config.service /etc/systemd/system
# sudo cp ~/bin/shellscripts/read-only-config_stop.service /etc/systemd/system
# systemctl enable read-only-config.service read-only-config_stop.service
CLOCK_SAVE=/var/tmp/WRITE_CLK
startup() {
rm -f $CLOCK_SAVE
touch /tmp/plymouth-boot-duration
if [ ! -L /var/lib/plymouth/boot-duration ]; then
ln -sf /tmp/plymouth-boot-duration /var/lib/plymouth/boot-duration
fi
#The existence of a link for random-seed and clock is enough to disable writes.
if [ ! -L /var/lib/systemd/random-seed ]; then
ln -sf /tmp/random-seed /var/lib/systemd/random-seed
fi
if [ ! -L /var/lib/systemd/clock ]; then
ln -sf /tmp/clock /var/lib/systemd/clock
chown systemd-timesync:systemd-timesync /var/lib/systemd/clock
fi
touch /tmp/dhcpdcd-eth0.lease
if [ ! -L /var/lib/dhcpcd5/dhcpcd-eth0.lease ]; then
ln -sf /tmp/dhcpdcd-eth0.lease /var/lib/dhcpcd5/dhcpcd-eth0.lease
fi
touch /tmp/resolv.conf
if [ ! -L /etc/resolv.conf ]; then
ln -sf /tmp/resolv.conf /etc/resolv.conf
fi
#touch /tmp/fake-hwclock.data
#if [ ! -L /etc/fake-hwclock.data ]; then
# ln -sf /tmp/fake-hwclock.data /etc/fake-hwclock.data
#fi
}
shutdown() {
if [ -f $CLOCKSAVE ]; then
mount -o remount,rw /
fake-hwclock save
mount -o remount,ro /
fi
}
case "${1:-}" in
stop|reload|restart|force-reload)
shutdown ;;
start)
startup ;;
*)
echo "Usage: ${0:-} {start|stop|status|restart|reload|force-reload}" >&2
exit 1
;;
esac