From bf6cf1bf005635dbe008e61fb594b6ed3ba87cf7 Mon Sep 17 00:00:00 2001 From: Tristan PILAT Date: Fri, 15 Nov 2019 16:45:45 +0100 Subject: [PATCH] Introduce an OS condition to handle OpenBSD Amended functions are the following: is_repository_readonly() remount_repository_readwrite() remount_repository_readonly() --- evomaintenance.sh | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/evomaintenance.sh b/evomaintenance.sh index a459394..72b2d00 100755 --- a/evomaintenance.sh +++ b/evomaintenance.sh @@ -169,16 +169,31 @@ print_session_data() { } is_repository_readonly() { - mountpoint=$(stat -c '%m' $1) - findmnt ${mountpoint} --noheadings --output OPTIONS | grep -q -E "\bro\b" + if [ "$(get_system)" = "OpenBSD" ]; then + partition=$(stat -f '%Sd' $1) + mount | grep ${partition} | grep -q "read-only" + else + mountpoint=$(stat -c '%m' $1) + findmnt ${mountpoint} --noheadings --output OPTIONS | grep -q -E "\bro\b" + fi } remount_repository_readwrite() { - mountpoint=$(stat -c '%m' $1) - mount -o remount,rw ${mountpoint} + if [ "$(get_system)" = "OpenBSD" ]; then + partition=$(stat -f '%Sd' $1) + mount -u -w /dev/${partition} 2>/dev/null + else + mountpoint=$(stat -c '%m' $1) + mount -o remount,rw ${mountpoint} + fi } remount_repository_readonly() { - mountpoint=$(stat -c '%m' $1) - mount -o remount,ro ${mountpoint} 2>/dev/null + if [ "$(get_system)" = "OpenBSD" ]; then + partition=$(stat -f '%Sd' $1) + mount -u -r /dev/${partition} 2>/dev/null + else + mountpoint=$(stat -c '%m' $1) + mount -o remount,ro ${mountpoint} 2>/dev/null + fi } hook_commit() {