From 86a183ec2126c1c241ffc739209d6e1440ee81b9 Mon Sep 17 00:00:00 2001
From: Nicolas Giard <github@ngpixel.com>
Date: Tue, 25 Apr 2023 16:42:46 -0400
Subject: [PATCH] chore: cleanup of legacy scripts

---
 docker/misc/build                | 96 -------------------------------
 docker/misc/copydb               | 97 --------------------------------
 docker/scripts/app-init.sh       |  5 --
 docker/scripts/db-include-fix.py | 33 -----------
 4 files changed, 231 deletions(-)
 delete mode 100644 docker/misc/build
 delete mode 100644 docker/misc/copydb
 delete mode 100644 docker/scripts/db-include-fix.py

diff --git a/docker/misc/build b/docker/misc/build
deleted file mode 100644
index b3cc97e52..000000000
--- a/docker/misc/build
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/bin/bash
-
-version=0.20
-program=${0##*/}
-progdir=${0%/*}
-if [ "$progdir" = "$program" ]; then progdir="."; fi
-if [ "$progdir" = "." ]; then progdir="$PWD"; fi
-parent=$(dirname "$progdir")
-if [ "$parent" = "." ]; then parent="$PWD"; fi
-if [[ $(uname) =~ CYGWIN.* ]]; then parent=$(echo "$parent" | sed -e 's/^\/cygdrive\/\(.\)/\1:/'); fi
-
-
-function usage() {
-    cat <<EOF
-NAME
-	$program - Build the datatracker docker images
-
-SYNOPSIS
-	$program [OPTIONS]
-
-DESCRIPTION
-	This script builds a Ubuntu-based docker image that has been
-	set up with the dependencies needed to easily run the IETF
-	datatracker in development mode.  It uses docker/app.Dockerfile and
-    db.Dockerfile; i.e., the Dockerfiles in the same directory as this script.
-
-OPTIONS
-EOF
-    grep -E '^\s+-[a-zA-Z])' "$0" | sed -E -e 's/\)[^#]+#/ /'
-    cat <<EOF
-
-AUTHOR
-	Written by:
-        Henrik Levkowetz, <henrik@levkowetz.com>
-        Lars Eggert, <lars@eggert.org>
-
-COPYRIGHT
-	Copyright (c) 2016 IETF Trust and the persons identified as authors of
-	the code. All rights reserved. Redistribution and use in source and
-	binary forms, with or without modification, is permitted pursuant to,
-	and subject to the license terms contained in, the Revised BSD
-	License set forth in Section 4.c of the IETF Trust’s Legal Provisions
-	Relating to IETF Documents(https://trustee.ietf.org/license-info).
-
-EOF
-}
-
-
-function die() {
-    echo -e "\n$program: error: $*" >&2
-    exit 1
-}
-
-
-function version() {
-	echo -e "$program $version"
-}
-
-
-trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
-
-# Default values
-IMAGE=ietf/datatracker-environment
-TAG=$(basename "$(svn info "$parent" | grep ^URL | awk '{print $2}' | tr -d '\r')")
-LOCAL=1
-
-# Option parsing
-shortopts=hut:V
-args=$(getopt -o$shortopts $*)
-if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
-set -- $args
-
-while true ; do
-    case "$1" in
-    	-h)    usage; exit;;	# Show this help, then exit
-    	-u)    LOCAL=0;;		# Upload image to repository after build
-    	-t)    TAG=$2; shift;;	# Use this docker image tag
-    	-V)    version; exit;;	# Show program version, then exit
-    	--)    shift; break;;
-    	*) die "Internal error, inconsistent option specification: '$1'";;
-    esac
-    shift
-done
-
-# The program itself
-docker rmi -f $IMAGE:trunk 2>/dev/null || true
-docker build --progress plain -t "$IMAGE-app:$TAG" -f docker/app.Dockerfile .
-docker build --progress plain -t "$IMAGE-db:$TAG" -f docker/db.Dockerfile .
-docker tag "$(docker images -q $IMAGE-app | head -n 1)" $IMAGE-app:latest
-docker tag "$(docker images -q $IMAGE-db | head -n 1)" $IMAGE-db:latest
-if [ -z "$LOCAL" ]; then
-    docker push $IMAGE-app:latest
-    docker push "$IMAGE-app:$TAG"
-    docker push $IMAGE-db:latest
-    docker push "$IMAGE-db:$TAG"
-fi
\ No newline at end of file
diff --git a/docker/misc/copydb b/docker/misc/copydb
deleted file mode 100644
index 748189bd6..000000000
--- a/docker/misc/copydb
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/bash
-
-version=0.11
-program=${0##*/}
-progdir=${0%/*}
-if [ "$progdir" = "$program" ]; then progdir="."; fi
-if [ "$progdir" = "." ]; then progdir="$PWD"; fi
-parent=$(dirname "$progdir")
-if [ "$parent" = "." ]; then parent="$PWD"; fi
-if [[ $(uname) =~ CYGWIN.* ]]; then parent=$(echo "$parent" | sed -e 's/^\/cygdrive\/\(.\)/\1:/'); fi
-
-
-function usage() {
-    cat <<EOF
-NAME
-	$program - Make a tarball of the MySQL database files and upload it
-
-SYNOPSIS
-	$program [OPTIONS]
-
-DESCRIPTION
-	This script creates a compressed tarball from the MySQL database files
-	on disk, and uploads it to the ietf datatracker developer area on
-	www.ietf.org.
-
-	It is intended to be used with the docker datatracker environment, after
-	you have set up the database with docker/setupdb, started the docker
-	image with docker/run, and updated the database with docker/updatedb.
-
-	To use it, exit from the docker container, to make sure that mysqldb
-	isn't running and all the files consistent and available for copy.  Then
-	run docker/$program outside the docker container.  You need to have ssh
-	access to www.ietf.org in order for the scp command to succeed.
-
-OPTIONS
-EOF
-    grep -E '^\s+-[a-zA-Z])' "$0" | sed -E -e 's/\)[^#]+#/ /'
-    cat <<EOF
-
-AUTHOR
-	Written by:
-		Henrik Levkowetz, <henrik@levkowetz.com>
-		Lars Eggert, <lars@eggert.org>
-
-COPYRIGHT
-	Copyright (c) 2016 IETF Trust and the persons identified as authors of
-	the code. All rights reserved. Redistribution and use in source and
-	binary forms, with or without modification, is permitted pursuant to,
-	and subject to the license terms contained in, the Revised BSD
-	License set forth in Section 4.c of the IETF Trust’s Legal Provisions
-	Relating to IETF Documents(https://trustee.ietf.org/license-info).
-
-EOF
-}
-
-
-function die() {
-    echo -e "\n$program: error: $*" >&2
-    exit 1
-}
-
-
-function version() {
-	echo -e "$program $version"
-}
-
-
-trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
-
-# Option parsing
-shortopts=hV
-args=$(getopt -o$shortopts $*)
-if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
-set -- $args
-
-while true ; do
-    case "$1" in
-    	-h)    usage; exit;;		# Show this help, then exit
-    	-V)    version; exit;;		# Show program version, then exit
-    	--)    shift; break;;
-    	*) die "Internal error, inconsistent option specification: '$1'";;
-    esac
-    shift
-done
-
-# The program itself
-if [ -e "/.dockerenv" -o -n "$(grep -s '/docker/' /proc/self/cgroup)" ]; then
-   die "It looks as if you're running inside docker -- please quit docker first."
-fi
-
-workdir=$(realpath $progdir/../data/mysql/..)
-echo "Working directory: $workdir"
-cd $workdir
-echo "Building tarfile ..."
-tar cjf ietf_utf8.bin.tar.bz2 mysql
-echo "Copying tarfile to ietfa.amsl.com ..."
-scp ietf_utf8.bin.tar.bz2 ietfa.amsl.com:/a/www/www6s/lib/dt/sprint/
\ No newline at end of file
diff --git a/docker/scripts/app-init.sh b/docker/scripts/app-init.sh
index 4e39da955..e32014b45 100755
--- a/docker/scripts/app-init.sh
+++ b/docker/scripts/app-init.sh
@@ -28,7 +28,6 @@ yarn build
 yarn legacy:build
 
 # Copy config files if needed
-cp $WORKSPACEDIR/docker/configs/settings_mysqldb.py $WORKSPACEDIR/ietf/settings_mysqldb.py
 cp $WORKSPACEDIR/docker/configs/settings_postgresqldb.py $WORKSPACEDIR/ietf/settings_postgresqldb.py
 
 if [ ! -f "$WORKSPACEDIR/ietf/settings_local.py" ]; then
@@ -65,10 +64,6 @@ else
     fi
 fi
 
-# Recondition settings to make changing databases easier. (Remember that we may have developers starting with settings_local from earlier work)
-python docker/scripts/db-include-fix.py
-cat $WORKSPACEDIR/ietf/settings_local.py | sed 's/from ietf.settings_mysqldb import DATABASES/from ietf.settings_postgresqldb import DATABASES/' > /tmp/settings_local.py && mv /tmp/settings_local.py $WORKSPACEDIR/ietf/settings_local.py
-
 # Create data directories
 
 echo "Creating data directories..."
diff --git a/docker/scripts/db-include-fix.py b/docker/scripts/db-include-fix.py
deleted file mode 100644
index 05336641b..000000000
--- a/docker/scripts/db-include-fix.py
+++ /dev/null
@@ -1,33 +0,0 @@
-from pathlib import Path
-content = Path('/workspace/ietf/settings_local.py').read_text()
-newcontent = content.replace(
-    """DATABASES = {
-    'default': {
-        'HOST': 'db',
-        'PORT': 3306,
-        'NAME': 'ietf_utf8',
-        'ENGINE': 'django.db.backends.mysql',
-        'USER': 'django',
-        'PASSWORD': 'RkTkDPFnKpko',
-        'OPTIONS': {
-            'sql_mode': 'STRICT_TRANS_TABLES',
-            'init_command': 'SET storage_engine=InnoDB; SET names "utf8"',
-        },
-    },
-}""",
-    "from ietf.settings_postgresqldb import DATABASES",
-).replace(
-    """DATABASES = {
-    'default': {
-        'HOST': 'pgdb',
-        'PORT': 5432,
-        'NAME': 'ietf',
-        'ENGINE': 'django.db.backends.postgresql_psycopg2',
-        'USER': 'django',
-        'PASSWORD': 'RkTkDPFnKpko',
-    },
-}""",
-    "from ietf.settings_postgresqldb import DATABASES",
-)
-with Path('/workspace/ietf/settings_local.py').open('w') as replacementfile:
-    replacementfile.write(newcontent)