summaryrefslogtreecommitdiffstats
path: root/lava-master/scripts/setup.sh
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2018-07-04 15:35:13 +0200
committerCorentin LABBE <clabbe@baylibre.com>2018-07-19 21:16:22 +0200
commit70bffaef36b2afe7c732d6f20afca008c5ef1445 (patch)
treea4f70f46f0b6c9e007516b7f2f313d2e0ca09051 /lava-master/scripts/setup.sh
parent32221a4e8fe36fd5c3c972039932cb53a25b1d5c (diff)
Made the database persistent
Until now, each docker-compose down will loose all data (jobs, devices, etc...). By creating a docker volume, the database will now be persistent other restart. Due to a risk of the lava package reseting the password, it is always reseted at start. This patch add also another volume for job output which are stored in the filesystem and not in database.
Diffstat (limited to 'lava-master/scripts/setup.sh')
-rwxr-xr-xlava-master/scripts/setup.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh
index 585499e..c00cb02 100755
--- a/lava-master/scripts/setup.sh
+++ b/lava-master/scripts/setup.sh
@@ -1,5 +1,12 @@
#!/bin/bash
+# always reset the lavaserver user, since its password could have been reseted in a "docker build --nocache"
+if [ ! -e /root/pg_lava_password ];then
+ < /dev/urandom tr -dc A-Za-z0-9 | head -c16 > /root/pg_lava_password
+fi
+sudo -u postgres psql -c "ALTER USER lavaserver WITH PASSWORD '$(cat /root/pg_lava_password)';" || exit $?
+sed -i "s,^LAVA_DB_PASSWORD=.*,LAVA_DB_PASSWORD='$(cat /root/pg_lava_password)'," /etc/lava-server/instance.conf || exit $?
+
if [ -e /root/lava-users ];then
for ut in $(ls /root/lava-users)
do