From cd9e3037f7a444e545eb75837ef433955b6c5551 Mon Sep 17 00:00:00 2001 From: sbts Date: Sun, 2 Jul 2017 00:12:21 +0800 Subject: [PATCH 1/3] Improve setting apt config --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e75cc8b..8059205 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM debian:jessie MAINTAINER Freelock john@freelock.com -RUN echo -n "APT::Install-Recommends \"0\";\nAPT::Install-Suggests \"0\";\n" >> /etc/apt/apt.conf +RUN echo "APT::Install-Recommends \"false\";\nAPT::Install-Suggests \"false\";\n" > /etc/apt/apt.conf.d/00recommends # Install Perl, Tex, Starman, psql client, and all dependencies From 8f3875acb02050141e993160188fd9f85efcee1f Mon Sep 17 00:00:00 2001 From: sbts Date: Sun, 2 Jul 2017 00:52:36 +0800 Subject: [PATCH 2/3] drop need to write config file to /srv/ledgersmb Instead write it to /tmp. Also don't copy the entire example file, just write the bits we need --- Dockerfile | 3 --- start.sh | 23 +++++++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index e75cc8b..3f510e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,8 +86,5 @@ RUN mkdir -p /tmp && \ # Internal Port Expose EXPOSE 5762 -# If ledgersmb.conf does not exist, www-data user needs to be able to create it. -RUN chown www-data /srv/ledgersmb -USER www-data CMD ["start.sh"] diff --git a/start.sh b/start.sh index 248c7b1..83b13b4 100755 --- a/start.sh +++ b/start.sh @@ -4,14 +4,20 @@ update_ssmtp.sh cd /srv/ledgersmb if [[ ! -f ledgersmb.conf ]]; then - cp conf/ledgersmb.conf.default ledgersmb.conf - sed -i \ - -e "s/\(cache_templates = \).*\$/cache_templates = 1/g" \ - -e "s/\(host = \).*\$/\1$POSTGRES_HOST/g" \ - -e "s/\(port = \).*\$/\1$POSTGRES_PORT/g" \ - -e "s/\(default_db = \).*\$/\1$DEFAULT_DB/g" \ - -e "s%\(sendmail = \).*%\1/usr/sbin/ssmtp%g" \ - /srv/ledgersmb/ledgersmb.conf + cat </tmp/ledgersmb.conf +[main] +cache_templates = 1 + +[database] +host = $POSTGRES_HOST +port = $POSTGRES_PORT +default_db = $DEFAULT_DB + +[mail] +sendmail = /usr/sbin/ssmtp + +EOF + export LSMB_CONFIG_FILE='/tmp/ledgersmb.conf' fi # Currently unmaintained/untested @@ -23,6 +29,7 @@ fi # Needed for modules loaded by cpanm export PERL5LIB + for PerlLib in /usr/lib/perl5* /usr/local/lib/perl5*/site_perl/* ; do [[ -d "$PerlLib" ]] && { PERL5LIB="$PerlLib"; From fd7c04d1702f931b3eb508de8722d76472c2acd3 Mon Sep 17 00:00:00 2001 From: sbts Date: Sun, 9 Jul 2017 14:09:45 +0800 Subject: [PATCH 3/3] remove stray script that was accidentally committed --- start-lsmb-and-postgres-containers.sh | 105 -------------------------- 1 file changed, 105 deletions(-) delete mode 100755 start-lsmb-and-postgres-containers.sh diff --git a/start-lsmb-and-postgres-containers.sh b/start-lsmb-and-postgres-containers.sh deleted file mode 100755 index ef2be9b..0000000 --- a/start-lsmb-and-postgres-containers.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash - -clear - -PGuser='postgres' -PGpass='password' - -PGcontainerName='lsmb-postgres' -LSMBcontainerName='myledger' - - -export POSTGRES_HOST='postgres' -export POSTGRES_PORT='5432' -export DEFAULT_DB='lsmb' - -CheckWhatIsRunning() { - isrunning_pg=false; - isrunning_lsmb=false; - while read -t10 line || { echo; false; } do - if [[ $line =~ $PGcontainerName ]]; then isrunning_pg=true; fi - if [[ $line =~ $LSMBcontainerName ]]; then isrunning_lsmb=true; fi - done < <( docker ps ) -} - -StartPostgres() { - if $isrunning_pg; then - echo "Postgres container $PGcontainerName is already running"; - else - echo "Starting Postgres container $PGcontainerName" - if docker inspect $PGcontainerName &>/dev/null; then # container exists so start it - docker start $PGcontainerName - else # container doesn't exist so run it - docker run --name $PGcontainerName -e POSTGRES_PASSWORD="$PGpass" -d postgres - fi - fi -} - -StartLedgerSMB() { - if $isrunning_lsmb; then - echo "LedgerSMB container $LSMBcontainerName is already running"; - else - echo "Starting LedgerSMB container $LSMBcontainerName" - if docker inspect $LSMBcontainerName &>/dev/null; then # container exists so start it - docker start $LSMBcontainerName >/dev/null - else # container doesn't exist so run it - docker run --name $LSMBcontainerName --link lsmb-postgres:postgres -d ledgersmb/ledgersmb - fi - fi -} - -GetIPs() { - containerIPlsmbPostgres=`docker inspect -f '{{ .NetworkSettings.IPAddress }}' lsmb-postgres` - containerIPlsmb=`docker inspect -f '{{ .NetworkSettings.IPAddress }}' myledger` -} - -PrintInfo() { - printf " %32s: IP %s\n" "$PGcontainerName" "$containerIPlsmbPostgres" - printf " %32s: IP %s\n" "$LSMBcontainerName" "$containerIPlsmb" - - echo -} - -TestLSMB() { # If any arg is passed then don't echo anything - if wget --tries=1 --timeout=2 -O /dev/null -q http://$containerIPlsmb:5762/setup.pl; then - [[ -z $1 ]] && echo "LSMB server accessible" - return 0 - else - [[ -z $1 ]] && echo "Failed to connect to LSMB server" - return 1 - fi -} - -timestamp() { - date "+%s" -} - -WaitForContainers() { - timer=60 - read -st10 timeoutAt < <( timestamp ) - (( timeoutAt = timeoutAt + timer )) - (( now = `timestamp` )) - (( lasttimestamp = now )) - echo - echo "wait at least $timer seconds for containers to start" - echo -en "\r$(( timeoutAt - now )) " - while { now=`timestamp`; (( now < timeoutAt )); } do - echo -en "\r$(( timeoutAt - now )) " - if (( now <= lasttimestamp )); then continue; fi - (( lasttimestamp = now )) - if [[ -z $containerIPlsmb ]]; then GetIPs &>/dev/null; fi - echo -en "\r$(( timeoutAt - now )) " - TestLSMB -s - if (( $? == 0 )); then echo; break; fi - echo -en "\r$(( timeoutAt - now )) " - done - echo -} - -CheckWhatIsRunning -StartPostgres -StartLedgerSMB -WaitForContainers -TestLSMB - -PrintInfo