aboutsummaryrefslogtreecommitdiffstats
path: root/lava-master
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2018-07-02 15:03:50 +0200
committerCorentin LABBE <clabbe@baylibre.com>2018-07-12 14:30:20 +0200
commit3e0ed7a2bb5f52ba54fdc1a6fbbe258f42397fbe (patch)
tree51edc1b51822ef42cf69dcc975a093bdef67638c /lava-master
parenta86807eafd93f0f53933929f616ee3a73d807d7c (diff)
Add device-types and tokens at startup
This patch remove the use of setup.sh during build. So setup.sh is now ran during startup. Since setup.sh could ran multiple times (start -> stop -> start) against the same database, we need to handle already existing objects (user, devices,...) So all "add objects" are done only after a check that this object is not already present.
Diffstat (limited to 'lava-master')
-rw-r--r--lava-master/Dockerfile1
-rwxr-xr-xlava-master/scripts/setup.sh24
-rwxr-xr-xlava-master/scripts/start.sh3
3 files changed, 20 insertions, 8 deletions
diff --git a/lava-master/Dockerfile b/lava-master/Dockerfile
index 4407f0b..3e64627 100644
--- a/lava-master/Dockerfile
+++ b/lava-master/Dockerfile
@@ -77,7 +77,6 @@ COPY device-types/ /root/device-types/
COPY users/ /root/lava-users/
COPY tokens/ /root/lava-callback-tokens/
COPY scripts/setup.sh /
-RUN /start.sh && /setup.sh && /stop.sh
#uncomment if you want to use squid
# warning the address used must be network accessible by all slave
diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh
index 3ab2abd..585499e 100755
--- a/lava-master/scripts/setup.sh
+++ b/lava-master/scripts/setup.sh
@@ -20,10 +20,15 @@ if [ -e /root/lava-users ];then
if [ $SUPERUSER -eq 1 ];then
USER_OPTION="$USER_OPTION --superuser"
fi
- echo "Adding username $USER DEBUG(with $TOKEN / $PASSWORD / $USER_OPTION)"
- lava-server manage users add --passwd $PASSWORD $USER_OPTION $USER || exit 1
- if [ ! -z "$TOKEN" ];then
- lava-server manage tokens add --user $USER --secret $TOKEN || exit 1
+ lava-server manage users list | grep -q "[[:space:]]$USER$"
+ 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
+ if [ ! -z "$TOKEN" ];then
+ lava-server manage tokens add --user $USER --secret $TOKEN || exit 1
+ fi
fi
done
fi
@@ -56,9 +61,14 @@ if [ -e /root/device-types ];then
do
cp $i /etc/lava-server/dispatcher-config/device-types/
devicetype=$(basename $i |sed 's,.jinja2,,')
- echo "Adding custom $devicetype"
- lava-server manage device-types add $devicetype || exit $?
- touch /root/.lavadocker/devicetype-$devicetype
+ lava-server manage device-types list | grep -q "[[:space:]]$devicetype[[:space:]]"
+ if [ $? -eq 0 ];then
+ echo "Skip already known $devicetype"
+ else
+ echo "Adding custom $devicetype"
+ lava-server manage device-types add $devicetype || exit $?
+ touch /root/.lavadocker/devicetype-$devicetype
+ fi
done
fi
diff --git a/lava-master/scripts/start.sh b/lava-master/scripts/start.sh
index 0e223b5..c34fe34 100755
--- a/lava-master/scripts/start.sh
+++ b/lava-master/scripts/start.sh
@@ -25,6 +25,9 @@ start () {
rm -f /var/run/lava-*.pid 2> /dev/null
/etc/init.d/postgresql start
+
+/setup.sh || exit $?
+
start apache2 || exit $?
start lava-logs || exit $?
start lava-master || exit $?