From 2296af62f547e158aafbc355029aaac3c0891bc6 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Tue, 2 Dec 2025 20:29:03 +0100 Subject: [PATCH 1/2] Tidy up scripts --- doit.pl | 3 ++- init-psqldb.sh | 17 ++++++++--------- init.sh | 8 +++----- psqldb-env.sh | 11 ++++++----- push.sh | 6 ++++-- setup.sh | 8 +++++--- update.sh | 16 ++++++++-------- 7 files changed, 36 insertions(+), 33 deletions(-) mode change 100644 => 100755 doit.pl mode change 100644 => 100755 init-psqldb.sh mode change 100644 => 100755 init.sh mode change 100644 => 100755 push.sh mode change 100644 => 100755 setup.sh diff --git a/doit.pl b/doit.pl old mode 100644 new mode 100755 index 4c2f2ef..d347ce9 --- a/doit.pl +++ b/doit.pl @@ -1,3 +1,4 @@ +#!/usr/bin/env perl use Data::Dumper; use Cwd; @@ -62,7 +63,7 @@ } # -# Read existing entires. +# Read existing entries. # If option A and `newId` is defined is used the commit will be assumed done. # If option B is used and `cached` is defined the commit messages # will be re-done, but the contents will not be re-done. diff --git a/init-psqldb.sh b/init-psqldb.sh old mode 100644 new mode 100755 index cff200e..321bd34 --- a/init-psqldb.sh +++ b/init-psqldb.sh @@ -1,13 +1,13 @@ -. ./psqldb-env.sh +#!/usr/bin/env bash +set -euo pipefail -set -e +# Create the psql database -# create the psql database +. ./psqldb-env.sh -if findmnt psqldb -then - pgctl stop - sudo umount psqldb +if findmnt psqldb && [[ -e ${PGDIR} ]]; then + pgctl stop + sudo umount psqldb fi mkdir -p psqldb @@ -28,7 +28,6 @@ max_wal_size = 512MB EOF pgctl start -createdb $DBNAME +createdb "$DBNAME" psql scowl -f comp/util-fun.sql psql scowl -f comp/comp-init.sql - diff --git a/init.sh b/init.sh old mode 100644 new mode 100755 index 255a672..54e7d7f --- a/init.sh +++ b/init.sh @@ -1,9 +1,7 @@ -# create the tmp git repo - -set -e +#!/usr/bin/env bash +set -euo pipefail mkdir -p git sudo mount -t tmpfs -o size=512M none git cd git -ln -s ../git-disk/.git - +ln -s ../git-disk/.git . diff --git a/psqldb-env.sh b/psqldb-env.sh index f5a620e..f5ab2ab 100644 --- a/psqldb-env.sh +++ b/psqldb-env.sh @@ -1,11 +1,11 @@ # set this to the absolute path of the root directly you are running the # scripts from. -ROOTDIR=/home/kevina/wordlist/diff/ +ROOTDIR="${HOME}/wordlist/diff/" export DBNAME=scowl -export PGVER=11 -export PGBINDIR=/usr/lib/postgresql/11/bin +export PGVER=18 +export PGBINDIR=/usr/lib/postgresql/18/bin export PATH="$PGBINDIR":"$PATH" @@ -15,7 +15,8 @@ export PGDIR="$DBROOT"/scowl export PGHOST="$DBROOT" export PGPORT=${PGPORT:-5437} -alias psql=`which psql` +alias psql=$(command -v psql) + pgctl () { - pg_ctl -D "$PGDIR" -l "$PGDIR"/log "$@" + pg_ctl -D "$PGDIR" -l "$PGDIR"/log "$@" } diff --git a/push.sh b/push.sh old mode 100644 new mode 100755 index f18ea6e..a9e57cb --- a/push.sh +++ b/push.sh @@ -1,2 +1,4 @@ -git push diff diff \ - $( for f in `git tag -l | fgrep diff/`; do echo $f:`basename $f`; done ) +#!/usr/bin/env bash +set -euo pipefail + +git push diff diff $( for f in $(git tag -l | grep -F diff/); do echo $f:$(basename $f); done ) diff --git a/setup.sh b/setup.sh old mode 100644 new mode 100755 index 0e3c545..2d294ff --- a/setup.sh +++ b/setup.sh @@ -1,11 +1,13 @@ -# setup the git-disk repo +#!/usr/bin/env bash +set -euo pipefail -set -e +# Setup the git-disk repo +rm -rf git-disk git init git-disk cd git-disk git remote add src git@github.com:en-wl/wordlist.git -#git remote add src /home/kevina/wordlist/v2-pub +#git remote add src "${HOME}/wordlist/v2-pub" git remote add diff git@github.com:en-wl/wordlist-diff.git git fetch src v1 git fetch src diff --git a/update.sh b/update.sh index 012cc21..753aa9f 100755 --- a/update.sh +++ b/update.sh @@ -1,15 +1,13 @@ -#!/bin/sh +#!/usr/bin/env bash +set -euo pipefail -# this will update an already populated git-disk - -set -ex +# This will update an already populated git-disk : ${SCOWL_BRANCH:=v2} export SCOWL_BRANCH : ${DIFF_BRANCH:=diff} export DIFF_BRANCH ROOTDIR="$PWD" - cd git-disk git reset --hard @@ -23,9 +21,11 @@ git reset --hard src/"$SCOWL_BRANCH" cd .. -if ! mountpoint -q git; then sh init.sh; fi +if ! mountpoint -q git; then + ./init.sh +fi cd git -PATH="$ROOTDIR/bin:$PATH" perl ../doit.pl +PATH="$ROOTDIR/bin:$PATH" ../doit.pl -echo 'now do: cd git; sh ../push.sh' +echo 'now do: cd git; ../push.sh' From 7f12a7013e344953b6508435914d6bf4b879fb39 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Tue, 2 Dec 2025 20:35:10 +0100 Subject: [PATCH 2/2] Add requirements to docs --- README-scripts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README-scripts b/README-scripts index 6fe8296..874124a 100644 --- a/README-scripts +++ b/README-scripts @@ -1,3 +1,7 @@ +Requirements: + python-psycopg2 + postgresql + After initial checkout: (1) run setup.sh to setup the git-disk repo (2) edit psqldb-env.sh to suit your environment @@ -30,7 +34,3 @@ and rerun update.sh. The creation of the tmpfs mounts is for both speed and to reduce SSD wear. The mounts are not strictly needed and the scripts can easily be hacked to avoid requiring them. - - - -