From 20581a9fa02c887c0b715350b9a39fabd8da6978 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Sun, 1 Dec 2024 16:19:56 +0100 Subject: [PATCH] New path for remount scripts --- system/remountdefault | 18 ++++++++++++++++++ system/remountrw | 28 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 system/remountdefault create mode 100755 system/remountrw diff --git a/system/remountdefault b/system/remountdefault new file mode 100755 index 0000000..811811a --- /dev/null +++ b/system/remountdefault @@ -0,0 +1,18 @@ +#!/bin/sh + +# Remount with default values from /etc/fstab all mountpath + +if [ "$(id -u)" -eq 0 ]; then + # get the mountpath list from fstab + for mountpath in $(grep -v -E "(^#)" /etc/fstab | awk '{print $2}'); do + # ensure "${mountpath}" is already mounted + if grep -q " ${mountpath} " /etc/mtab; then + mount "${mountpath}" -o remount + #printf '%b\n' "mount ${mountpath} -o remount" + fi + done +else + sudo "${0}" +fi + +exit 0 diff --git a/system/remountrw b/system/remountrw new file mode 100755 index 0000000..1dfccef --- /dev/null +++ b/system/remountrw @@ -0,0 +1,28 @@ +#!/bin/sh + +# Remount some partitions with less restrictive permissions, e.g : +# * to be able to run updates (apt, dpkg, grub,…) + +if [ "$(id -u)" -eq 0 ]; then + # RW permissions + ## get the mountpath list from fstab + for mountpath in /boot /opt /usr /var; do + # ensure "${mountpath}" is already mounted + if grep -q " ${mountpath} " /etc/mtab; then + mount "${mountpath}" -o remount,rw,suid,dev + fi + done + + # EXEC + RW permissions + ## get the mountpath list from fstab + for mountpath in /tmp /var/tmp /dev/shm; do + # ensure "${mountpath}" is already mounted + if grep -q " ${mountpath} " /etc/mtab; then + mount "${mountpath}" -o remount,rw,suid,dev,exec + fi + done +else + sudo "${0}" +fi + +exit 0