Skip to content

Commit

Permalink
do not produce output when using grep command
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtapolasek committed Aug 23, 2023
1 parent 773162d commit cc8b8ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions shared/macros/10-bash.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ Ensures that given mount point is in :code:`/etc/fstab`.
mount_point_match_regexp="$(printf "^[[:space:]]*[^#].*[[:space:]]%s[[:space:]]" {{{ mount_point }}})"

# If the mount point is not in /etc/fstab, get previous mount options from /etc/mtab
if ! grep "$mount_point_match_regexp" /etc/fstab; then
if ! grep -q "$mount_point_match_regexp" /etc/fstab; then
# runtime opts without some automatic kernel/userspace-added defaults
previous_mount_opts=$(grep "$mount_point_match_regexp" /etc/mtab | head -1 | awk '{print $4}' \
| sed -E "s/(rw|defaults|seclabel|{{{ mount_opt }}})(,|$)//g;s/,$//")
Expand All @@ -1738,7 +1738,7 @@ if ! grep "$mount_point_match_regexp" /etc/fstab; then
fi
echo "{{{ fs_spec }}} {{{ mount_point }}} {{{ type }}} defaults,${previous_mount_opts}{{{ mount_opt }}} 0 0" >> /etc/fstab
# If the mount_opt option is not already in the mount point's /etc/fstab entry, add it
elif ! grep "$mount_point_match_regexp" /etc/fstab | grep "{{{ mount_opt }}}"; then
elif ! grep "$mount_point_match_regexp" /etc/fstab | grep -q "{{{ mount_opt }}}"; then
previous_mount_opts=$(grep "$mount_point_match_regexp" /etc/fstab | awk '{print $4}')
sed -i "s|\(${mount_point_match_regexp}.*${previous_mount_opts}\)|\1,{{{ mount_opt }}}|" /etc/fstab
fi
Expand Down

0 comments on commit cc8b8ec

Please sign in to comment.