mirror of
https://github.com/ovh/debian-cis.git
synced 2025-06-22 02:33:42 +02:00
10.5_lock_inactive_user_account.sh 11.1_warning_banners.sh 11.2_remove_os_info_warning_banners.sh 11.3_graphical_warning_banners.sh
This commit is contained in:
18
lib/utils.sh
18
lib/utils.sh
@ -123,8 +123,9 @@ add_line_file_before_pattern() {
|
||||
local LINE=$2
|
||||
local PATTERN=$3
|
||||
|
||||
backup_file "$1"
|
||||
backup_file "$FILE"
|
||||
debug "Inserting $LINE before $PATTERN in $FILE"
|
||||
PATTERN=$(sed 's@/@\/@g' <<< $PATTERN)
|
||||
debug "sed -i '/$PATTERN/i $LINE' $FILE"
|
||||
sed -i "/$PATTERN/i $LINE" $FILE
|
||||
FNRET=0
|
||||
@ -135,13 +136,26 @@ replace_in_file() {
|
||||
local SOURCE=$2
|
||||
local DESTINATION=$3
|
||||
|
||||
backup_file "$1"
|
||||
backup_file "$FILE"
|
||||
debug "Replacing $SOURCE to $DESTINATION in $FILE"
|
||||
SOURCE=$(sed 's@/@\/@g' <<< $SOURCE)
|
||||
debug "sed -i 's/$SOURCE/$DESTINATION/g' $FILE"
|
||||
sed -i "s/$SOURCE/$DESTINATION/g" $FILE
|
||||
FNRET=0
|
||||
}
|
||||
|
||||
delete_line_in_file() {
|
||||
local FILE=$1
|
||||
local PATTERN=$2
|
||||
|
||||
backup_file "$FILE"
|
||||
debug "Deleting lines from $FILE containing $PATTERN"
|
||||
PATTERN=$(sed 's@/@\/@g' <<< $PATTERN)
|
||||
debug "sed -i '/$PATTERN/d' $FILE"
|
||||
sed -i "/$PATTERN/d" $FILE
|
||||
FNRET=0
|
||||
}
|
||||
|
||||
#
|
||||
# Users and groups
|
||||
#
|
||||
|
Reference in New Issue
Block a user