-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.sh
executable file
·81 lines (64 loc) · 2.04 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
#
# Start.sh
#
# Copyright Jaroslav Vacha
# 2021/01/15 Jaroslav Vacha <[email protected]>
#
echo "$(date) - ** Dockerized PLCComS - Communication server for TECO PLC (Foxtrot, TC700 and SoftPLC) **"
export MALLOC_CHECK_=4
# define the path to the log file
TECO_LOG="$TECO_LOG_DIR/$TECO_LOG_FILE"
# create log file if not exists
touch ${TECO_LOG}
# get platform architecture string
ARCH=`uname -m`
echo "$(date) - PLCComS arch: $ARCH"
# echo the PLCComS ini file path
echo "$(date) - PLCComS ini file is set to $TECO_CONF_DIR/$TECO_CONF_FILE"
# echo the timezone
echo "$(date) - Timezone set to $TZ"
# use it for script logging as well as for PLCcomS
#exec >> $TECO_LOG
#exec 2>> $TECO_LOG
case $ARCH in
i586|i686) PLCCOMS_BIN="PLCComS"
LIBSDIR="lib_x86"
;;
x86_64) PLCCOMS_BIN="PLCComS_x86_64"
LIBSDIR="lib_x86_64"
;;
armv6l) PLCCOMS_BIN="PLCComS_arm_eabihf"
LIBSDIR="lib_rpi"
;;
armv7l) PLCCOMS_BIN="PLCComS_arm_eabihf"
LIBSDIR="lib_rpi2"
;;
aarch64) PLCCOMS_BIN="PLCComS_aarch64"
LIBSDIR=""
;;
*) echo "Unknown or unsupported architecture: $ARCH"
exit 1
;;
esac
echo "$(date) - PLCComS binary file based on platform is set to $PLCCOMS_BIN"
TECO_LIB_DIR="$TECO_DIR/lib/$LIBSDIR";
export LD_LIBRARY_PATH=$TECO_LIB_DIR
echo "$(date) - PLCComS LD_LIBRARY_PATH is set to $LD_LIBRARY_PATH"
# define function to restore missing configuration files
restoreConfigurationFile ()
{
if [ ! -e "$TECO_CONF_DIR/$1" ] ; then
echo "$(date) - $1 missing from $TECO_CONF_DIR - initialising default"
cp -a "$TECO_DIR/etc_defaults/$1" "$TECO_CONF_DIR/$1"
fi
}
# ensure configuration files are restored on first run
restoreConfigurationFile "$TECO_CONF_FILE"
restoreConfigurationFile "$FOXTROT_CONF_FILE"
# launch PLCComS binary
echo "$(date) - launching PLCComS binary from $TECO_DIR/$PLCCOMS_BIN"
# launch (do NOT use the "-d" flag)
exec "$TECO_DIR/$PLCCOMS_BIN" \
-c "$TECO_CONF_DIR/$TECO_CONF_FILE" \
-l "$TECO_LOG"