#!/bin/bash
# Wrapper for the docker run (or compose?) launch command(s)
#
# Edit History
# [001] 02-Sep-16 Add $TERM param to pass our host environment TERM
#                 to the container. (Seems a bit awkward but not sure
#                 how else to do it since the container seems to start 
#                 with TERM=xterm, and we can't hard-code in in the 
#                 Dockerfile.) /jdm
# [002] 04-Sep-16 publish a few ports (ideally I'd like to publish a 
#                 range, or even all, but not sure if that's possible) /jdm
# [003] 09-Sep-16 create a $HOME/client.conf file with the docker0 ip
#                 and bind-mount it on /etc/cups/client.conf /jdm
#                 And sync the container timezone with the host by
#                 mounting /etc/localtime on it /jdm
# [004] 02-Jul-26 Switch SYS64: to SYS70: /jdm
#
echo ServerName `/usr/sbin/ip route|awk '/docker0/ { print $9 }'` \
  > $HOME/cups-client.conf

# Directory note: replace the -v /vm/miame:/vm/miame with an appropriate 
# mount for your own $MIAME directory (with disk devices beneath it). 
# The container will come up with a clean set of 001004,002002,and 007006
# files in the dynamically-created device SYS70: which will be searched
# before SYS:, CMD:, and BAS:
# 
# Port note: the following publishes ports 39899-39904 for general
# use by server containers. PLXSV1 typically uses 39899; SUBMIT2
# port defined in OPR:SUBMIT.INI (and via SUBMIT2/LISTEN:####)

# User/gid note: following uses the current user with gid 1000;
# change as needed (may require coordination with run.sh)
# (Note however that despite run.sh reporting the correct user,
# ashell and systat seem to think the user is root)

# -v $HOME/cups-client.conf:/etc/cups/client.conf:ro 

docker run -it -v /vm/dockertest:/vm/miame --network=host \
 --publish 39899:39899 --publish 39900:39900 --publish 39001:39001 \
 --publish 39002:39002 --publish 39003:39003 --publish 39004:39004 \
 -v /etc/localtime:/etc/localtime:ro \
 $1 `whoami` 1000 $TERM


