Skip to content

Commit afdfd8f

Browse files
committed
Merged in a patch from mark@painless-security.com to add caching options to docker/run
- Legacy-Id: 17860
1 parent ac52ce6 commit afdfd8f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

docker/run

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)";
7474
# Option parsing
7575

7676
# Options
77-
shortopts=dhi:m:Mp:r:t:vVu:
78-
longopts=download-data,help,ietfdb-url=,mysqldata=,no-mysqldir,port=,docker-repo=,tag=,verbose,version,user=,
77+
shortopts=dhi:m:Mp:r:t:vVu:cC
78+
longopts=download-data,help,ietfdb-url=,mysqldata=,no-mysqldir,port=,docker-repo=,tag=,verbose,version,user=,cached,no-cached
7979

8080
# Default values
8181
MYSQLDIR=$parent/data/mysql
@@ -86,6 +86,7 @@ DBURL=https://www.ietf.org/lib/dt/sprint/ietf_utf8.bin.tar.bz2
8686
WHO=$(whoami)
8787
WHOUID=$(id -u $WHO)
8888
WHOGID=$(id -g $WHO)
89+
CACHED=''
8990

9091
if [ "$(uname)" = "Linux" ]; then
9192
args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@")
@@ -98,10 +99,15 @@ else
9899
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
99100
set -- $args
100101
sed="sed -E"
102+
if [ "$(uname)" = "Darwin" ]; then
103+
CACHED=':cached'
104+
fi
101105
fi
102106

103107
while true ; do
104108
case "$1" in
109+
-c| --cached) CACHED=':cached';; # Use cached disk access to reduce system load
110+
-C| --no-cached) CACHED='';; # Use fully synchronized disk access
105111
-d| --download-data) DOWNLOAD=1;; # Download and set up the database files
106112
-h| --help) usage; exit;; # Show this help, then exit
107113
-f| --filedir) FILEDIR=$2; shift;; # Set the desired location of drafts, charters etc.
@@ -225,14 +231,15 @@ else
225231
echo -e "\nThe web interface for 'runserver' should appear on $URL\n"
226232
echo -e "User $WHO ($WHOUID:$WHOGID)"
227233
if [ -z "$MYSQLDIR" ]; then
228-
docker run -ti -p $PORT:8000 -v "$HOME:/home/$WHO" \
234+
docker run -ti -p $PORT:8000 -v "$HOME:/home/$WHO$CACHED" \
229235
-e USER="$WHO" -e DATADIR="${parent#$HOME/}/data" -e CWD="${PWD#$HOME/}" \
230236
-e TAG="$TAG" -e FILEDIR=${FILEDIR#$HOME} -e UID="$WHOUID" -e GID="$WHOGID" \
231237
"$REPO:$TAG" "$@"
232238
else
233-
docker run -ti -p $PORT:8000 -v "$HOME:/home/$WHO" -v "$MYSQLDIR:/var/lib/mysql"\
234-
-e USER="$WHO" -e DATADIR="${parent#$HOME/}/data" -e CWD="${PWD#$HOME/}" \
235-
-e TAG="$TAG" -e FILEDIR=${FILEDIR#$HOME} -e UID="$WHOUID" -e GID="$WHOGID" \
239+
docker run -ti -p $PORT:8000 -v "$HOME:/home/$WHO$CACHED" \
240+
-v "$MYSQLDIR:/var/lib/mysql" -e USER="$WHO" \
241+
-e DATADIR="${parent#$HOME/}/data" -e CWD="${PWD#$HOME/}" -e TAG="$TAG" \
242+
-e FILEDIR=${FILEDIR#$HOME} -e UID="$WHOUID" -e GID="$WHOGID" \
236243
"$REPO:$TAG" "$@"
237244
fi
238245

0 commit comments

Comments
 (0)