Skip to content

Commit

Permalink
rewrite remount in awk
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuseteam committed Oct 17, 2024
1 parent bef9db1 commit 9b15d01
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions remount
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
#!/usr/bin/env bash
if [ $(rorw) = "ro" ]; then
set -x
sudo -K
sudo mount -t tmpfs tmpfs /var/lib/apt
sudo mount -t tmpfs tmpfs /var/cache/apt
sudo mount -o remount,rw /
sudo -K
elif [ $(rorw) = "rw" ]; then
set -x
sudo -k mount -o remount,ro /
fi
#!/usr/bin/awk -f
BEGIN {
FS = "[ ,]"
ARGC=2;
ARGV[1]="/proc/mounts";
}
{
if ( $2 == "/" && $3 != "rootfs" ) {
if ( $4 == "ro" ) {
print "remounting rootfs as readwrite";
system("sudo -K");
system("set -x; sudo mount -t tmpfs tmpfs /var/lib/apt");
system("set -x; sudo mount -t tmpfs tmpfs /var/cache/apt");
system("set -x; sudo mount -o remount,rw /");
system("sudo -K");
}
if ( $4 == "rw" ) {
print "remounting rootfs as readonly";
system("sudo -K");
system("set -x; sudo mount -o remount,ro /");
system("sudo -K");
}
}
}

0 comments on commit 9b15d01

Please sign in to comment.