config/functions: match user only at beginning of line

This commit is contained in:
MilhouseVH 2017-12-07 21:05:51 +00:00
parent 4c9ad98ae2
commit dcd653b5a4

View File

@ -365,7 +365,7 @@ add_user() {
# Usage: add_user "username" "password" "userid" "groupid" "description" "home" "shell"
mkdir -p ${INSTALL}/etc
touch ${INSTALL}/etc/passwd
if [ -z "`grep "$1:" ${INSTALL}/etc/passwd`" ]; then
if ! grep -q "^$1:" ${INSTALL}/etc/passwd; then
echo "$1:x:$3:$4:$5:$6:$7" >> ${INSTALL}/etc/passwd
fi
@ -376,7 +376,7 @@ add_user() {
if [ "$PASSWORD" = "x" ]; then
PASSWORD="*"
fi
if [ -z "`grep "$1:" ${INSTALL}/usr/config/shadow`" ]; then
if ! grep -q "^$1:" ${INSTALL}/usr/config/shadow; then
echo "$1:$PASSWORD:::::::" >> ${INSTALL}/usr/config/shadow
fi
}