summaryrefslogtreecommitdiffstats
path: root/lava-master
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2019-01-08 09:54:27 +0100
committerCorentin LABBE <clabbe@baylibre.com>2019-01-14 14:22:05 +0100
commitf3d0e211a5b7c4fca8221e22631266d283209e78 (patch)
treed831b2ff36c1b2be07c0b584bb62b4060fd537b8 /lava-master
parent2b5da0fc18215febc4d982ed298e9be4485a7789 (diff)
lava-master: better check of already existing users
lava-server manage users list does not display inactive users. Furthermore the return code of this action is not tested. lava-server manage users list display also firstname/lastname and this need to be filtered. This patch fix thoses problem.
Diffstat (limited to 'lava-master')
-rwxr-xr-xlava-master/scripts/setup.sh16
1 files changed, 14 insertions, 2 deletions
diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh
index 6153c9d..c22a06f 100755
--- a/lava-master/scripts/setup.sh
+++ b/lava-master/scripts/setup.sh
@@ -55,12 +55,24 @@ if [ -e /root/lava-users ];then
if [ $SUPERUSER -eq 1 ];then
USER_OPTION="$USER_OPTION --superuser"
fi
- lava-server manage users list | grep -q "[[:space:]]$USER$"
+ lava-server manage users list --all > /tmp/allusers
+ if [ $? -ne 0 ];then
+ echo "ERROR: cannot generate user list"
+ exit 1
+ fi
+ #filter first name/last name (enclose by "()")
+ sed -i 's,[[:space:]](.*$,,' /tmp/allusers
+ grep -q "[[:space:]]${USER}$" /tmp/allusers
if [ $? -eq 0 ];then
echo "Skip already existing $USER DEBUG(with $TOKEN / $PASSWORD / $USER_OPTION)"
else
echo "Adding username $USER DEBUG(with $TOKEN / $PASSWORD / $USER_OPTION)"
- lava-server manage users add --passwd $PASSWORD $USER_OPTION $USER || exit 1
+ lava-server manage users add --passwd $PASSWORD $USER_OPTION $USER
+ if [ $? -ne 0 ];then
+ echo "ERROR: Adding user $USER"
+ cat /tmp/allusers
+ exit 1
+ fi
if [ ! -z "$TOKEN" ];then
echo "Adding token to user $USER"
lava-server manage tokens add --user $USER --secret $TOKEN || exit 1