forked from AndyTaylorTweet/Pi-Star_Binaries_sbin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpistar-functions
executable file
·42 lines (37 loc) · 1.31 KB
/
pistar-functions
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
# Common script functions for Pi-Star routines:
# meant to be paired in a given routine: first write mode check, then read mode check;
# one pair for root rw/ro, one pair for root+boot rw/ro;
# valid for routines in Buster, Bullseye, Bookworm;
# designed so that a routine retains the read/write state entering and exiting.
function mount-rw() {
fs=$(sed -n "s|/dev/.* / ext4 \(r[ow]\).*|\1|p" /proc/mounts)
if [ "$fs" == "ro" ]; then
sudo mount -o remount,rw /
fi
}
function mount-ro() {
# fs=$(sed -n "s|/dev/.* / ext4 \(r[ow]\).*|\1|p" /proc/mounts)
if [ "$fs" == "ro" ]; then
sudo mount -o remount,ro /
fi
}
function mount-rw-boot() {
fs=$(sed -n "s|/dev/.* / ext4 \(r[ow]\).*|\1|p" /proc/mounts)
fw=$(sed -n "s|/dev/.*/boot\(.*\) [ve].*|\1|p" /proc/mounts)
if [ "$fs" == "ro" ]; then
sudo mount -o remount,rw /
sudo mount -o remount,rw /boot${fw}
fi
}
function mount-ro-boot() {
# fs=$(sed -n "s|/dev/.* / ext4 \(r[ow]\).*|\1|p" /proc/mounts)
# fw=$(sed -n "s|/dev/.*/boot\(.*\) [ve].*|\1|p" /proc/mounts)
if [ "$fs" == "ro" ]; then
sudo mount -o remount,ro /
sudo mount -o remount,ro /boot${fw}
fi
}
function set-fs-fw() {
fs=$(sed -n "s|/dev/.* / ext4 \(r[ow]\).*|\1|p" /proc/mounts)
fw=$(sed -n "s|/dev/.*/boot\(.*\) [ve].*|\1|p" /proc/mounts)
}