diff --git a/scripts/fninstr.py b/scripts/fninstr.py index 110be4b..926acc7 100644 --- a/scripts/fninstr.py +++ b/scripts/fninstr.py @@ -109,7 +109,8 @@ def merge(v, vors): if args.read: for filename in rest: print("FILE [%s] " % filename) - y = yaml.load(open(filename)) + with open(filename, 'r') as file: + y = yaml.safe_load(file) assert (y is not None), "Missing output file from fninstr" for x in y: # print x diff --git a/scripts/setup_postgres.sh b/scripts/setup_postgres.sh index 6177ea9..745dedb 100755 --- a/scripts/setup_postgres.sh +++ b/scripts/setup_postgres.sh @@ -1,6 +1,12 @@ #!/bin/bash set -ex +# shellcheck disable=SC2034 +sudo="" +if [ $EUID -ne 0 ]; then + SUDO=sudo +fi + PGPASS="${HOME}/.pgpass" if [ ! -f "${PGPASS}" ]; then @@ -10,17 +16,17 @@ if [ ! -f "${PGPASS}" ]; then pg_hba="/etc/postgresql/${postgres_version}/main/pg_hba.conf" postgres_password='postgrespostgres' - sudo sed -i.bak -E 's/^(local\s+all\s+postgres\s+)md5$/\1peer/' "${pg_hba}" - sudo service postgresql reload + $SUDO sed -i.bak -E 's/^(local\s+all\s+postgres\s+)md5$/\1peer/' "${pg_hba}" + $SUDO service postgresql reload password_sql="ALTER USER postgres WITH PASSWORD '${postgres_password}';" - sudo -u postgres psql -c "${password_sql}" + $SUDO -u postgres psql -c "${password_sql}" echo "*:*:*:postgres:${postgres_password}" > "${PGPASS}" chmod 600 "${PGPASS}" - sudo sed -i.bak -E 's/^(local\s+all\s+postgres\s+)peer$/\1md5/' "${pg_hba}" - sudo service postgresql reload + $SUDO sed -i.bak -E 's/^(local\s+all\s+postgres\s+)peer$/\1md5/' "${pg_hba}" + $SUDO service postgresql reload fi # Define the PostgreSQL version @@ -31,12 +37,12 @@ PG_CONF="/etc/postgresql/${PG_VERSION}/main/postgresql.conf" PG_HBA="/etc/postgresql/${PG_VERSION}/main/pg_hba.conf" # Update listen_addresses and password_encryption in postgresql.conf -sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '0.0.0.0, localhost'/g" $PG_CONF -sed -i "s/#password_encryption = scram-sha-256/password_encryption = md5/g" $PG_CONF +$SUDO sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '0.0.0.0, localhost'/g" $PG_CONF +$SUDO sed -i "s/#password_encryption = scram-sha-256/password_encryption = md5/g" $PG_CONF # Update pg_hba.conf -echo "host all all 0.0.0.0/0 md5" >> $PG_HBA -sed -i 's/scram-sha-256/md5/g' $PG_HBA +$SUDO echo "host all all 0.0.0.0/0 md5" >> $PG_HBA +$SUDO sed -i 's/scram-sha-256/md5/g' $PG_HBA # Restart PostgreSQL service -service postgresql restart +$SUDO service postgresql restart diff --git a/scripts/vars.sh b/scripts/vars.sh index cacc390..a8eebb9 100644 --- a/scripts/vars.sh +++ b/scripts/vars.sh @@ -66,8 +66,8 @@ if [ "$(jq -r .injfixupsscript $json)" != "null" ]; then injfixupsscript="${injfixupsscript/\{bug_build\}/$bug_build}" fi -# buildhost="$(jq -r '.buildhost // "docker"' $json)" -buildhost="localhost" +buildhost="$(jq -r '.buildhost // "docker"' $json)" +# buildhost="localhost" pandahost="$(jq -r '.pandahost // "docker"' $json)" testinghost="$(jq -r '.testinghost // "docker"' $json)" logs="$output_dir/$name/logs"