Skip to content

Commit e899200

Browse files
committed
Code refactoring.
- Legacy-Id: 10475
1 parent 674332c commit e899200

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

docker/docker-init.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@ if ! id -u "$USER" &> /dev/null; then
5858
fi
5959

6060
VIRTDIR="/opt/home/$USER/$TAG"
61-
if [ ! -d /opt/home/$USER ]; then
61+
echo "Checking that there's a virtual environment for $TAG ..."
62+
if [ ! -f $VIRTDIR/bin/activate ]; then
6263
echo "Setting up python virtualenv at /opt/home/$USER ..."
6364
mkdir -p /opt/home/$USER
6465
chown $USER /opt/home/$USER
6566
mkdir $VIRTDIR
6667
virtualenv --system-site-packages $VIRTDIR
68+
cat $VIRTDIR/bin/activate >> /etc/bash.bashrc
69+
cat /usr/local/share/datatracker/setprompt >> /etc/bash.bashrc
6770
fi
6871

69-
echo "Activating a virtual python environment ..."
70-
cat $VIRTDIR/bin/activate >> /etc/bash.bashrc
71-
cat /usr/local/share/datatracker/setprompt >> /etc/bash.bashrc
72+
echo "Activating the virtual python environment ..."
7273
. $VIRTDIR/bin/activate
7374

74-
7575
if ! python -c "import django"; then
7676
echo "Installing requirements ..."
7777
pip install -r /usr/local/share/datatracker/requirements.txt

docker/run

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ longopts=download-data,help,ietfdb-url=,mysqldata=,no-mysqldir,port=,docker-repo
7979

8080
# Default values
8181
MYSQLDIR=$parent/data/mysql
82-
NOMYMAP=""
82+
FILEDIR=$parent/../data/
8383
PORT=8000
84-
REPO="levkowetz/datatracker"
84+
REPO="ietf/datatracker-environment"
8585
TAG=$(basename $(svn info $parent | grep ^URL | awk '{print $2}'))
8686
URL=https://www.ietf.org/lib/dt/sprint/ietf_utf8.bin.tar.bz2
8787
WHO=$(whoami)
@@ -103,9 +103,9 @@ while true ; do
103103
case "$1" in
104104
-d| --download-data) DOWNLOAD=1;; # Download and set up the database files
105105
-h| --help) usage; exit;; # Show this help, then exit
106+
-f| --filedir) FILEDIR=$2; shift;; # Set the desired location of drafts, charters etc.
106107
-i| --ietfdb-url) URL=$2; shift;; # Use an alternative database tarball URL
107-
-m| --mysqldir) MYSQLDIR=$2; shift;; # Set the desired location for MySQL's database files
108-
-M| --no-mysqldir) NOMYMAP=1;; # Don't map the mysql dir to an external dir
108+
-m| --mysqldir) MYSQLDIR=$2; shift;; # Set the desired location of MySQL's database files
109109
-p| --port) PORT=$2; shift;; # Bind the container's port 8000 to external port PORT
110110
-r| --docker-repo) REPO=$2; shift;; # Use the given docker repository, instead of the default
111111
-t| --tag) TAG=$2; shift;; # Use this docker image tag, instead of the svn branch name
@@ -179,10 +179,16 @@ if ! docker images $REPO | grep -q $TAG; then
179179
fi
180180
fi
181181

182-
if [ -n "$NOMYMAP" ]; then
183-
docker run -ti -p $PORT:8000 -v $HOME:/home/$WHO -e USER=$WHO -e DATADIR=${parent#$HOME/}/data -e CWD=${PWD#$HOME/} -e TAG=$TAG $REPO:$TAG
182+
if [ -z "$MYSQLDIR" ]; then
183+
docker run -ti -p $PORT:8000 -v $HOME:/home/$WHO \
184+
-e USER=$WHO -e DATADIR=${parent#$HOME/}/data -e CWD=${PWD#$HOME/} \
185+
-e TAG=$TAG -e FILEDIR=${FILEDIR#$HOME} \
186+
$REPO:$TAG
184187
else
185-
docker run -ti -p $PORT:8000 -v $HOME:/home/$WHO -v $MYSQLDIR:/var/lib/mysql -e USER=$WHO -e DATADIR=${parent#$HOME/}/data -e CWD=${PWD#$HOME/} -e TAG=$TAG $REPO:$TAG
188+
docker run -ti -p $PORT:8000 -v $HOME:/home/$WHO -v $MYSQLDIR:/var/lib/mysql\
189+
-e USER=$WHO -e DATADIR=${parent#$HOME/}/data -e CWD=${PWD#$HOME/} \
190+
-e TAG=$TAG -e FILEDIR=${FILEDIR#$HOME} \
191+
$REPO:$TAG
186192
fi
187193

188194
echo ""

0 commit comments

Comments
 (0)