This repository was archived by the owner on Nov 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,8 @@ LOCAL_MARKER_GROUP="iam-synced-users" # Dedicated UNIX group to mark im
114
114
LOCAL_GROUPS="GROUPNAMES" # Comma seperated list of UNIX groups to add the users in
115
115
USERADD_PROGRAM="/usr/sbin/useradd" # The useradd program to use. defaults to `/usr/sbin/useradd`
116
116
USERADD_ARGS="--create-home --shell /bin/bash" # Arguments for the useradd program. defaults to `--create-home --shell /bin/bash`
117
+ USERDEL_PROGRAM="/usr/sbin/userdel" # The userdel program to use. defaults to `/usr/sbin/userdel`
118
+ USERDEL_ARGS="--force --remove" # Arguments for the userdel program. defaults to `--force --remove`
117
119
```
118
120
119
121
The LOCAL_MARKER_GROUP will be created if it does not exist. BEWARE: DO NOT add any manually created users
Original file line number Diff line number Diff line change 54
54
# Possibility to provide custom useradd arguments
55
55
: ${USERADD_ARGS:= " --user-group --create-home --shell /bin/bash" }
56
56
57
+ # Possibility to provide a custom userdel program
58
+ : ${USERDEL_PROGRAM:= " /usr/sbin/userdel" }
59
+
60
+ # Possibility to provide custom userdel arguments
61
+ : ${USERDEL_ARGS:= " --force --remove" }
62
+
57
63
# Initizalize INSTANCE variable
58
64
INSTANCE_ID=$( curl -s http://169.254.169.254/latest/meta-data/instance-id)
59
65
REGION=$( curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" ' {print $4}' )
@@ -211,7 +217,8 @@ function delete_local_user() {
211
217
/usr/bin/pkill -9 -u " ${1} " || true
212
218
sleep 1
213
219
# Remove account now that all processes for the user are gone
214
- /usr/sbin/userdel -f -r " ${1} "
220
+ ${USERDEL_PROGRAM} ${USERDEL_ARGS} " ${1} "
221
+
215
222
log " Deleted user ${1} "
216
223
}
217
224
Original file line number Diff line number Diff line change @@ -42,9 +42,11 @@ LOCAL_GROUPS=""
42
42
ASSUME_ROLE=" "
43
43
USERADD_PROGRAM=" "
44
44
USERADD_ARGS=" "
45
+ USERDEL_PROGRAM=" "
46
+ USERDEL_ARGS=" "
45
47
RELEASE=" master"
46
48
47
- while getopts :hva:i:l:s:p:u:r: opt
49
+ while getopts :hva:i:l:s:p:u:d:f: r: opt
48
50
do
49
51
case $opt in
50
52
h)
72
74
u)
73
75
USERADD_ARGS=" $OPTARG "
74
76
;;
77
+ d)
78
+ USERDEL_PROGRAM=" $OPTARG "
79
+ ;;
80
+ f)
81
+ USERDEL_ARGS=" $OPTARG "
82
+ ;;
75
83
r)
76
84
RELEASE=" $OPTARG "
77
85
;;
@@ -93,6 +101,8 @@ export LOCAL_GROUPS
93
101
export ASSUME_ROLE
94
102
export USERADD_PROGRAM
95
103
export USERADD_ARGS
104
+ export USERDEL_PROGRAM
105
+ export USERDEL_ARGS
96
106
97
107
# check if AWS CLI exists
98
108
if ! [ -x " $( which aws) " ]; then
@@ -147,6 +157,16 @@ then
147
157
echo " USERADD_ARGS=\" ${USERADD_ARGS} \" " >> $MAIN_CONFIG_FILE
148
158
fi
149
159
160
+ if [ " ${USERDEL_PROGRAM} " != " " ]
161
+ then
162
+ echo " USERDEL_PROGRAM=\" ${USERDEL_PROGRAM} \" " >> $MAIN_CONFIG_FILE
163
+ fi
164
+
165
+ if [ " ${USERDEL_ARGS} " != " " ]
166
+ then
167
+ echo " USERDEL_ARGS=\" ${USERDEL_ARGS} \" " >> $MAIN_CONFIG_FILE
168
+ fi
169
+
150
170
./install_configure_selinux.sh
151
171
152
172
./install_configure_sshd.sh
You can’t perform that action at this time.
0 commit comments