mirror of
https://github.com/hardenedlinux/harbian-audit.git
synced 2025-07-27 15:44:33 +02:00
Modify basic function add_option_to_fstab
This commit is contained in:
parent
b5cff8047a
commit
62ceb5f36d
12
lib/utils.sh
12
lib/utils.sh
@ -344,13 +344,17 @@ add_option_to_fstab() {
|
|||||||
# sed -ie "s;\(^[^#].*${PARTITION}\)\(\s.*\)\(\s\w.*\)\(\s[0-2]\s*[0-2]\);\1\2\3,${OPTION}\4;" /etc/fstab
|
# sed -ie "s;\(^[^#].*${PARTITION}\)\(\s.*\)\(\s\w.*\)\(\s[0-2]\s*[0-2]\);\1\2\3,${OPTION}\4;" /etc/fstab
|
||||||
MOUNT_OPTION=$(grep -v "^#" /etc/fstab | awk '$2=="${PARTITION}" {print $4}')
|
MOUNT_OPTION=$(grep -v "^#" /etc/fstab | awk '$2=="${PARTITION}" {print $4}')
|
||||||
CURLINE=$(grep -v "^#" /etc/fstab -n | grep "/home" | awk -F: '{print $1}')
|
CURLINE=$(grep -v "^#" /etc/fstab -n | grep "/home" | awk -F: '{print $1}')
|
||||||
|
#This case is for option of starting with "no", example: nosuid noexec nodev
|
||||||
|
NOTNOOPTION=$(echo $OPTION | cut -c 3-)
|
||||||
|
|
||||||
if [ "${MOUNT_OPTION}" == "defaults" ]; then
|
if [ "${MOUNT_OPTION}" == "defaults" ]; then
|
||||||
NEWOP='rw,nosuid,nodev,noexec,auto,async'
|
NEWOP='rw,nosuid,nodev,noexec,auto,async'
|
||||||
sed -i "s${CURLINE}/$MOUNT_OPTION/$NEWOP/"
|
sed -i "${CURLINE}s/$MOUNT_OPTION/$NEWOP/" /etc/fstab
|
||||||
elif [ $(echo $MOUNT_OPTION | grep -w $(echo $OPTION | cut -c 3-) | wc -l) -gt 0 ]; then
|
#This case is for option of starting with "no", example: nosuid noexec nodev
|
||||||
|
elif [ $(echo $MOUNT_OPTION | grep -cw ${NOTNOOPTION}) -gt 0 ]; then
|
||||||
|
sed -i "${CURLINE}s/${NOTNOOPTION}/${OPTION}/" /etc/fstab
|
||||||
|
elif [ $(echo $MOUNT_OPTION | grep -cw $OPTION)) -eq 0 ]; then
|
||||||
|
sed -i "${CURLINE}s/${MOUNT_OPTION}/${MOUNT_OPTION},${OPTION}/" /etc/fstab
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user