Skip to content

Commit

Permalink
Merge pull request os-autoinst#1957 from kalikiana/bootstrap-rerun-er…
Browse files Browse the repository at this point in the history
…rors

bootstrap: make errors fatal and deal with re-runs
  • Loading branch information
okurz authored Jan 16, 2019
2 parents a1e4dde + a5a8942 commit e6cc92f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
9 changes: 6 additions & 3 deletions script/fetchneedles
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
set -e
: ${dbuser:="geekotest"}

: ${dist:="opensuse"}
: ${giturl:="git://github.com/os-autoinst/os-autoinst-distri-opensuse.git"}
: ${branch:="master"}
Expand All @@ -17,10 +19,10 @@ dir="/var/lib/openqa/share/tests"
if [ -w / ]; then
if [ ! -e "$dir/$dist" ]; then
mkdir -p "$dir/$dist"
chown geekotest:www "$dir/$dist"
chown $dbuser:www "$dir/$dist"
fi
echo "running as root, re-exec as geekotest ..."
exec sudo -u geekotest env \
echo "running as root, re-exec as $dbuser ..."
exec sudo -u $dbuser env \
dist="$dist" \
giturl="$giturl" \
branch="$branch" \
Expand Down Expand Up @@ -48,6 +50,7 @@ needlesdir()
do_fetch()
{
local target=$1
echo fetching $target
git fetch -q
git rebase -q
if [ "$needles_separate" = 1 ]; then
Expand Down
15 changes: 9 additions & 6 deletions script/openqa-bootstrap
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash -x
set -e
: ${dbname:="openqa"}
: ${dbuser:="geekotest"}


# add extra repos for leap
Expand All @@ -16,15 +19,15 @@ zypper -n install --no-recommends openQA-local-db apache2 openQA-worker qemu-kvm

# setup database
systemctl enable --now postgresql
su postgres -c "createuser -D geekotest"
su postgres -c "createdb -O geekotest openqa"
getent passwd $dbuser || su postgres -c "createuser -D $dbuser"
su postgres -c "psql -lqt" | cut -d \| -f 1 | grep -qw $dbname || su postgres -c "createdb -O $dbuser $dbname"


# setup webserver and fake-auth
# from script/setup-single-instance (https://github.com/os-autoinst/openQA/pull/1933)
for i in headers proxy proxy_http proxy_wstunnel rewrite ; do a2enmod $i ; done
sed -i -e 's/^.*httpsonly.*$/httpsonly = 0/g' /etc/openqa/openqa.ini
sed -i -e 's/#.*method.*OpenID.*$/&\nmethod = Fake/' /etc/openqa/openqa.ini
sed -i -e 's/#*.*method.*=.*$/method = Fake/' /etc/openqa/openqa.ini
sed "s/#ServerName.*$/ServerName $(hostname)/" /etc/apache2/vhosts.d/openqa.conf.template > /etc/apache2/vhosts.d/openqa.conf


Expand All @@ -50,8 +53,8 @@ fi

if ping -c1 gitlab.suse.de. ; then
# clone SLE needles if run from within SUSE network
git clone https://gitlab.suse.de/openqa/os-autoinst-needles-sles.git /var/lib/openqa/tests/opensuse/products/sle/needles
chown -R geekotest: /var/lib/openqa/tests/opensuse/products/sle/needles
[ -d /var/lib/openqa/tests/opensuse/products/sle/needles ] || git clone https://gitlab.suse.de/openqa/os-autoinst-needles-sles.git /var/lib/openqa/tests/opensuse/products/sle/needles
chown -R $dbuser: /var/lib/openqa/tests/opensuse/products/sle/needles
fi


Expand All @@ -77,7 +80,7 @@ done
curl http://localhost/login # create demo user (id=2)
API_KEY=$(hexdump -n 8 -e '2/4 "%08X" 1 "\n"' /dev/random)
API_SECRET=$(hexdump -n 8 -e '2/4 "%08X" 1 "\n"' /dev/random)
echo "INSERT INTO api_keys (key, secret, user_id, t_created, t_updated) VALUES ('${API_KEY}', '${API_SECRET}', 2, NOW(), NOW());" | su postgres -c 'psql openqa'
echo "INSERT INTO api_keys (key, secret, user_id, t_created, t_updated) VALUES ('${API_KEY}', '${API_SECRET}', 2, NOW(), NOW());" | su postgres -c "psql $dbname"

cat >> /etc/openqa/client.conf <<EOF
[localhost]
Expand Down

0 comments on commit e6cc92f

Please sign in to comment.