Skip to content

Commit

Permalink
use bash script for postgress too. Also I think requirements.txt nede…
Browse files Browse the repository at this point in the history
…d to be redone
  • Loading branch information
AndrewQuijano committed Jul 10, 2024
1 parent 7ea6e16 commit 5dce35d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 70 deletions.
8 changes: 5 additions & 3 deletions init-host.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ def main():
# summon tar and qcow files
if not isfile(join(TAR_DIR, basename(TAR_URL))):
progress("Downloading %s".format(basename(TAR_URL)))
run(["wget", TAR_URL], cwd=TAR_DIR)
os.chdir(TAR_DIR)
run(["wget", TAR_URL])
os.chdir(LAVA_DIR)
else:
progress("Found existing target_bins/{}".format(basename(TAR_URL)))

if not isfile(join(LAVA_DIR, basename(QCOW_URL))):
if not isfile(join(LAVA_DIR, basename(QCOW_FILE_NAME))):
progress("Downloading {}".format(basename(QCOW_URL)))
run(["wget", "--no-check-certificate", QCOW_URL, "-O", QCOW_FILE_NAME])
else:
Expand All @@ -86,7 +88,7 @@ def main():
progress("Building host.json")
# Build host.json
json_configs = {}
json_configs["qemu"] = "anda-system-i386"
json_configs["qemu"] = "panda-system-i386"
json_configs["qcow_dir"] = LAVA_DIR
json_configs["output_dir"] = join(LAVA_DIR, "target_injections")
json_configs["config_dir"] = join(LAVA_DIR, "target_configs")
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ progress "Installed build dependencies"
$SUDO pip3 install --upgrade pip

# This seems to be the better replacement to have all python packages
$SUDO pip3 install -r docker/requirements.txt
$SUDO pip3 install -r requirements.txt
progress "Installed Python requirements"

$SUDO python3 setup_container.py
./setup_container.sh

progress "Installed LAVA"
22 changes: 9 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
SQLAlchemy==1.0.14
zmq==0.0.0
pyzmq==15.2.0
psycopg2==2.6.1
lockfile==0.10.2
tabulate==0.7.5
pexpect==3.2
psutil==5.6.6
ipython==2.3.0
colorama==0.3.2
numpy==1.8.2
argparse==1.2.1
pandare
colorama
db
ipython
lockfile
numpy
pandare
PyYAML
SQLAlchemy
tabulate
24 changes: 24 additions & 0 deletions scripts/setup_postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -ex

PGPASS="${HOME}/.pgpass"

if [ ! -f "${PGPASS}" ]; then
postgres_depends=$(dpkg-query -W -f='${depends}' 'postgresql')
postgres_pkg=$(echo "${postgres_depends}" | grep -oP 'postgresql-[0-9]+.?[0-9]+')
postgres_version=${postgres_pkg/postgresql-/}
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

password_sql="ALTER USER postgres WITH PASSWORD '${postgres_password}';"
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
fi
52 changes: 0 additions & 52 deletions setup_postgres.py

This file was deleted.

0 comments on commit 5dce35d

Please sign in to comment.