Skip to content

Commit 6ecdabf

Browse files
committed
capturing output in containerbau.log
1 parent 4495a0d commit 6ecdabf

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

setup.sh

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ LOGIN=
2727
PASS=
2828
DEMOACCOUNT=1 # 1 or 0
2929

30+
### predefine settings for ssh-tunnel
31+
SSH_MIDDLEMAN_SERVER=
32+
SSH_MIDDLEMAN_USER=
33+
3034
### Name des Containers
3135
### Kann entweder als Parameter übergeben werden oder unten eingesetzt
3236
if test -n "${1}"
@@ -67,7 +71,6 @@ RUBY_VERSION=3.0.0
6771

6872

6973

70-
SILENT_INSTALL=0 # 0 verbose output
7174
#### return codes
7275
###
7376
### 2 falsche LDX-Version
@@ -82,12 +85,10 @@ SILENT_INSTALL=0 # 0 verbose output
8285
### Speicherort der Konfiguration des ssh-tunnels
8386
SSH_TUNNEL_LOCATION="/etc/network/if-up.d/reverse_ssh_tunnel"
8487

85-
86-
if [ $SILENT_INSTALL -ne 0 ] ; then
87-
SILENT=" 2>&1>/dev/null"
88-
else
89-
SILENT=
90-
fi
88+
### Alle Ausgaben in die Datei containerbau.log umleiten
89+
rm containerbau.log
90+
touch containerbau.log
91+
SILENT=containerbau.log
9192

9293

9394
if test -n "${2}"
@@ -152,7 +153,7 @@ fi
152153
echo "-------------------------"
153154
echo "Containter: $CONTAINER"
154155
echo "Login: $LOGIN"
155-
echo "Password: $PASS"
156+
echo "Password: **** " # $PASS"
156157
echo "Demoaccount: `if [ $DEMOACCOUNT -eq 1 ] ; then echo "ja" ; else echo "nein"; fi ` "
157158
echo "PORT: $SSH_PORT_NUMBER"
158159
echo "Backport: $SSH_MONITORING_PORT_NUMBER"
@@ -279,17 +280,17 @@ init_container(){
279280
sleep $LXD_DELAY
280281

281282
echo "Installiere Java Das dauert einige Minuten ..."
282-
$access_container sudo apt update $SILENT
283-
$access_container sudo apt install -y openjdk-14-jre $SILENT
283+
$access_container sudo apt update >> $SILENT
284+
$access_container sudo apt install -y openjdk-14-jre >> $SILENT
284285

285286
# testen, ob java installiert ist:
286287
# $access_container dpkg -s openjdk-14-jre | grep -c installed
287-
288+
echo "Falls java an dieser Stelle nicht installiert wurde ... wir holen dies später noch nach!"
288289
lxc file push $IB_PROGRAM $CONTAINER/home/ubuntu/
289290
echo "Installiere ${PRODUCT}. Das dauert einige Minuten ..."
290291
#$access_container DISPLAY= $IB_PROGRAM <<<""$'\n'
291-
lxc exec --user 1000 --group 1000 --env "DISPLAY=" $CONTAINER -- bash --login /home/ubuntu/$IB_PROGRAM <<<""$'\n'
292-
#$SILENT
292+
lxc exec --user 1000 --group 1000 --env "DISPLAY=" $CONTAINER -- bash --login /home/ubuntu/$IB_PROGRAM <<<""$'\n' >> $SILENT
293+
# >> $SILENT
293294
return 0
294295
else
295296
echo "Container ist nicht leer."
@@ -309,19 +310,19 @@ apply_ibc(){
309310
echo "IBC-$IBC_VERSION ist bereits lokal vorhanden "
310311
else
311312
echo "Hole IBC-Archib vom Git-Archiv"
312-
wget $IBC_PATH $SILENT
313+
wget $IBC_PATH >> $SILENT
313314
fi
314315
## Erstelle ibc-Verzeichnis im Container
315316
if [ `$access_container find /home/ubuntu -type d -name ibc | wc -l ` -ne 0 ] ; then
316317
echo "Verzeichnis ibc bereits vorhanden. "
317318
echo "Installation von IBC wird übersprungen."
318319
echo "Es wird keine crontab installiert."
319320
else
320-
$access_container sudo apt install -y openjdk-14-jre $SILENT
321+
$access_container sudo apt install -y openjdk-14-jre >> $SILENT
321322
$access_container mkdir ibc
322-
$access_container sudo apt install -y unzip cron $SILENT
323+
$access_container sudo apt install -y unzip cron >> $SILENT
323324
lxc file push $ibc_file $CONTAINER/home/ubuntu/ibc/
324-
$access_container unzip ibc/$ibc_file -d ibc $SILENT
325+
$access_container unzip ibc/$ibc_file -d ibc >> $SILENT
325326
$access_container chmod a+x ibc/gatewaystart.sh
326327
$access_container chmod a+x ibc/twsstart.sh
327328
$access_container chmod a+x ibc/scripts/ibcstart.sh
@@ -366,18 +367,19 @@ install_simple_monitor(){
366367
if [ `$access_container find /home/ubuntu -type d -name simple-monitor | wc -l ` -ne 0 ] ; then
367368
echo "simple monitor ist bereits angelegt"
368369
return 1
369-
else
370+
else
371+
{
370372
$access_container sudo apt-get install -y software-properties-common
371373
$access_container sudo apt-add-repository -y ppa:rael-gc/rvm
372-
$access_container sudo apt-get update
373-
$access_container sudo apt-get install -y rvm
374+
$access_container sudo apt-get update
375+
$access_container sudo apt-get install -y rvm elinks git tmux # vim
374376
$access_container sudo usermod -a -G rvm ubuntu
375-
$access_container rvm install $RUBY_VERSION
376-
$access_container sudo apt -y install tmux vim elinks git
377-
$access_container git clone https://github.com/ib-ruby/simple-monitor.git
378-
$access_container gem install bundler
377+
$access_container rvm install $RUBY_VERSION
378+
$access_container git clone https://github.com/ib-ruby/simple-monitor.git
379+
$access_container gem install bundler
379380
lxc file push install_simple_monitor.sh $CONTAINER/home/ubuntu/
380-
$access_container ./install_simple_monitor.sh
381+
$access_container ./install_simple_monitor.sh
382+
} >> $SILENT
381383
return 0
382384
fi
383385
}
@@ -391,7 +393,7 @@ setup_reverse_tunnel(){
391393
if [ `$access_container find /home/ubuntu -type d -name .ssh | wc -l ` -ne 0 ] ; then
392394
echo "Verzeichnis .ssh ist bereits vorhanden."
393395
else
394-
$access_container sudo apt install -y openssh-server autossh # add .ssh dir
396+
$access_container sudo apt install -y openssh-server autossh >> $SILENT # add .ssh dir
395397
# https://stackoverflow.com/questions/43235179/how-to-execute-ssh-keygen-without-prompt
396398
$access_container ssh-keygen -q -t rsa -N '' -f /home/ubuntu/.ssh/id_rsa <<<y 2>&1 >/dev/null
397399
# download public-key and install it locally

0 commit comments

Comments
 (0)