From dcff80c5b367fe74036577753361d4e46c1100aa Mon Sep 17 00:00:00 2001 From: Theo Chatzimichos Date: Nov 12 2017 18:38:19 +0000 Subject: use sudo in specific commands on the prepare show_highstate env script this way we can run it as a normal user as well on our workstations, which brings us one step closer to be able to run all the tests locally as well --- diff --git a/bin/prepare_test_show_highstate_env.sh b/bin/prepare_test_show_highstate_env.sh index f01aca5..ccb74b9 100755 --- a/bin/prepare_test_show_highstate_env.sh +++ b/bin/prepare_test_show_highstate_env.sh @@ -2,11 +2,22 @@ # Prepares the CI runner environment to run the show_highstate tests -zypper -qn in --no-recommends salt git python3 python3-PyYAML -rm -rf /srv/{salt,pillar} -ln -s $PWD/salt /srv/salt -ln -s $PWD/pillar /srv/pillar +set -e + +if [[ $(whoami) != 'root' ]]; then + if [[ -f /usr/bin/sudo ]]; then + SUDO='/usr/bin/sudo' + else + echo 'Please install sudo first, or run this script as root' + exit 1 + fi +fi + +$SUDO zypper -qn in --no-recommends salt git python3 python3-PyYAML +$SUDO rm -rf /srv/{salt,pillar} +$SUDO ln -s $PWD/salt /srv/salt +$SUDO ln -s $PWD/pillar /srv/pillar +echo 'domain: infra.opensuse.org' | $SUDO tee /etc/salt/grains > /dev/null sed -i -e 's/^production:$/base:/' /srv/{salt,pillar}/top.sls -echo 'domain: infra.opensuse.org' > /etc/salt/grains ROLES=$(bin/get_roles.py --yaml) printf "city:\ncountry:\nsalt_cluster: opensuse\nvirt_cluster:\n$ROLES" > pillar/id/${HOSTNAME}.sls