Add: install script
This commit is contained in:
parent
60b6ff35e6
commit
783deec3cf
1 changed files with 131 additions and 0 deletions
131
install.sh
Executable file
131
install.sh
Executable file
|
@ -0,0 +1,131 @@
|
|||
#!/bin/bash
|
||||
|
||||
SUDO=""
|
||||
# default versions
|
||||
CDS_VERSION=4.0.0.0
|
||||
EDGE_VERSION=4.0.0.0
|
||||
# Overload versions, when they are passed as command line arguments
|
||||
[ ! -z $1 ] && CDS_VERSION=$1
|
||||
[ ! -z $2 ] && EDGE_VERSION=$2
|
||||
|
||||
URL="https://store.codesys.com/ftp_download/3S/LinuxSL/2302000005/${CDS_VERSION}/CODESYS%20Control%20for%20Linux%20SL%20${CDS_VERSION}.package"
|
||||
EDGE_URL="https://store.codesys.com/ftp_download/3S/EdgeGatewayLinux/000120/${EDGE_VERSION}/CODESYS%20Edge%20Gateway%20for%20Linux%20${EDGE_VERSION}.package"
|
||||
|
||||
# check if this linux system is debian based
|
||||
if ! which dpkg >/dev/zero; then
|
||||
echo "This install script only runs on debian based distributions"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if we are running as root, or we have sudoers access to dpkg
|
||||
if [ "$USER" != "root" ]; then
|
||||
if ! which sudo >/dev/zero; then
|
||||
echo "You are not running as root, and don't have sudo installed."
|
||||
exit 1
|
||||
fi
|
||||
echo "You are running as non-root user. We try to get sudo access to dpkg."
|
||||
if ! sudo dpkg --version >/dev/zero; then
|
||||
echo "You have no access to dpkg. Please rerun the script as root"
|
||||
exit 1
|
||||
fi
|
||||
SUDO="sudo"
|
||||
fi
|
||||
|
||||
# check necessary tools
|
||||
if ! which wget >/dev/zero; then
|
||||
echo "We need the tool 'wget' to download the CODESYS package."
|
||||
echo "You may try:"
|
||||
echo " apt-get install wget"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! which unzip >/dev/zero; then
|
||||
echo "We need the tool 'unzip' to unpack the CODESYS package."
|
||||
echo "You may try:"
|
||||
echo " apt-get install unzip"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if /lib64 is available
|
||||
if ! -d /lib64; then
|
||||
echo "Seems that you are not running on a traditional multi arch system."
|
||||
echo "As a workaround, you can link /lib to /lib64."
|
||||
echo "ln -s /lib /lib64"
|
||||
fi
|
||||
|
||||
# check availability of ipv4, and try to install xinetd forwarding if not
|
||||
ipv4=$(ip -4 addr list scope global)
|
||||
ipv6=$(ip -6 addr list scope global)
|
||||
|
||||
if [ -z "${ipv4}" -a ! -z "${ipv6}" ]; then
|
||||
echo "You are running on an ipv6 only host. CODESYS doesn't support this, yet."
|
||||
echo "So we try to install an ipv6 forwarding, using xinetd."
|
||||
# check if xinetd is installed
|
||||
if [ ! -d /etc/xinetd.d ]; then
|
||||
echo "We need the tool 'xinetd' to tunnel between ipv4 and ipv6"
|
||||
echo "You may try:"
|
||||
echo " apt-get install xinetd"
|
||||
exit 1
|
||||
fi
|
||||
address=$(ip -6 addr list scope global dev eth0 | grep -v " fd" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p' | head -n 1)
|
||||
cat <<EOF >/etc/xinetd.d/codesys-ipv6
|
||||
service codesys-tcp
|
||||
{
|
||||
flags = IPv6
|
||||
disable = no
|
||||
type = UNLISTED
|
||||
socket_type = stream
|
||||
protocol = tcp
|
||||
user = nobody
|
||||
wait = no
|
||||
redirect = 127.0.0.1 11740
|
||||
port = 11740
|
||||
bind = ${address}
|
||||
}
|
||||
service codesys-gw
|
||||
{
|
||||
flags = IPv6
|
||||
disable = no
|
||||
type = UNLISTED
|
||||
socket_type = stream
|
||||
protocol = tcp
|
||||
user = nobody
|
||||
wait = no
|
||||
redirect = 127.0.0.1 1217
|
||||
port = 1217
|
||||
bind = ${address}
|
||||
}
|
||||
service codesys-edge
|
||||
{
|
||||
flags = IPv6
|
||||
disable = no
|
||||
type = UNLISTED
|
||||
socket_type = stream
|
||||
protocol = tcp
|
||||
user = nobody
|
||||
wait = no
|
||||
redirect = 127.0.0.1 11743
|
||||
port = 11743
|
||||
bind = ${address}
|
||||
}
|
||||
EOF
|
||||
systemctl reload xinetd
|
||||
fi
|
||||
|
||||
# start installation
|
||||
if [ -z "${TRY_RUN}" ]; then
|
||||
# download and install the edge package
|
||||
[ ! -f /tmp/edge.package ] && wget --output-document=/tmp/edge.package ${EDGE_URL}
|
||||
(
|
||||
unzip -p /tmp/edge.package '*.deb' >/tmp/edge.deb &&
|
||||
${SUDO} dpkg -i /tmp/edge.deb
|
||||
)
|
||||
# download and install the control package
|
||||
[ ! -f /tmp/codesys.package ] && wget --output-document=/tmp/codesys.package ${URL}
|
||||
(
|
||||
unzip -p /tmp/codesys.package '*codemeter*.deb' >/tmp/codemeter.deb &&
|
||||
${SUDO} dpkg -i /tmp/codemeter.deb
|
||||
unzip -p /tmp/codesys.package '*codesyscontrol*.deb' >/tmp/codesys.deb &&
|
||||
${SUDO} dpkg -i /tmp/codesys.deb
|
||||
)
|
||||
fi
|
Loading…
Add table
Reference in a new issue