New path for remount scripts

This commit is contained in:
gardouille 2024-12-01 16:19:56 +01:00
parent d5f1bdb67a
commit 20581a9fa0
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
2 changed files with 46 additions and 0 deletions

18
system/remountdefault Executable file
View File

@ -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

28
system/remountrw Executable file
View File

@ -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