83 lines
2.9 KiB
Bash
Executable File
83 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
toolName="fhem"
|
|
toolUser="$toolName"
|
|
toolHome="/opt/fhem"
|
|
toolVersion="6.0"
|
|
toolDpkg="fhem-${toolVersion}.deb"
|
|
toolUrl="http://fhem.de/$toolDpkg"
|
|
# default deps listed at https://debian.fhem.de/
|
|
toolDeps="perl-base libdevice-serialport-perl libwww-perl libio-socket-ssl-perl libcgi-pm-perl libjson-perl sqlite3 libdbd-sqlite3-perl libtext-diff-perl libtimedate-perl libmail-imapclient-perl libgd-graph-perl libtext-csv-perl libxml-simple-perl liblist-moreutils-perl fonts-liberation2 libimage-librsvg-perl libgd-text-perl libsocket6-perl libio-socket-inet6-perl libmime-base64-urlsafe-perl libimage-info-perl libusb-1.0-0-dev libnet-server-perl"
|
|
toolDeps2="libdate-manip-perl libhtml-treebuilder-xpath-perl libmojolicious-perl libxml-bare-perl libauthen-oath-perl libconvert-base32-perl libmodule-pluggable-perl libnet-bonjour-perl libcrypt-urandom-perl"
|
|
# for rounding operations e.g.:
|
|
# { use Math::Round qw/nearest/;; nearest('0.01',ReadingsVal("1WT_28_5728E9070000", "temperature", 0)-1.1);; }
|
|
toolDeps2+=" libmath-round-perl"
|
|
# for fritzbox connection
|
|
toolDeps2+=" libsoap-lite-perl libjson-xs-perl"
|
|
# for xmpp support (no special solution needed for raspbian buster)
|
|
toolDeps2+=" libnet-xmpp-perl libxml-stream-perl libnet-jabber-perl"
|
|
|
|
|
|
# Get script working directory
|
|
# (when called from a different directory)
|
|
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
|
|
WSUBDIR="${WDIR}/${toolName}"
|
|
#CONFIG_FILE="$WDIR/${toolName}.cfg"
|
|
#CONFIG_FILE_DEFAULT="${CONFIG_FILE}.example"
|
|
|
|
#step_config() {
|
|
# echo "Called once before executing steps."
|
|
# echo "e.g. to source a config file:"
|
|
# #. "$CONFIG_FILE"
|
|
#}
|
|
|
|
step_1_info() { echo "Install prerequisits for $toolName"; }
|
|
step_1_alias() { ALIAS="install"; }
|
|
step_1() {
|
|
local aptOpt=
|
|
if [ $QUIET != 0 ] ; then
|
|
aptOpt="-y"
|
|
fi
|
|
#exe apt update
|
|
exe apt install $toolDeps $toolDeps2 "$aptOpt"
|
|
#exe apt install "$toolDeps2" "$aptOpt"
|
|
endReturn -o $? "Installation of prerequisits failed"
|
|
}
|
|
|
|
step_2_info() { echo "Download and install $toolName version $toolVersion"; }
|
|
step_2() {
|
|
exe wget "$toolUrl" -O "$downPath"
|
|
endReturn -o $? "Download of $toolName failed"
|
|
exe dpkg -i "$downPath"
|
|
endReturn -o $? "Installation of $toolName failed"
|
|
}
|
|
downPath="/tmp/$toolDpkg"
|
|
|
|
step_3_info() { echo "Start $toolName service"; }
|
|
step_3() {
|
|
exe systemctl restart fhem.service
|
|
}
|
|
|
|
step_20_info() { echo "List $toolName prerequisits"; }
|
|
step_20_alias() { ALIAS="listdeps"; }
|
|
step_20() {
|
|
echo " [I] $toolName prerequisits:"
|
|
echo "$toolDeps $toolDeps2"
|
|
}
|
|
|
|
step_30_info() { echo "Create user $toolUser"; }
|
|
step_30() {
|
|
exe useradd --system --home "$toolHome" --gid dialout --shell /bin/false "$toolUser"
|
|
endReturn -o $? "Creating user $toolUser failed"
|
|
}
|
|
|
|
step_32_info() { echo "Create $toolName systemd service"; }
|
|
step_32() {
|
|
exe cp "${toolHome}/contrib/init-scripts/fhem.service" "$systemdConfigLoc"
|
|
exe systemctl daemon-reload
|
|
}
|
|
systemdConfigLoc="/etc/systemd/system"
|
|
|
|
VERSION_SEQREV=11
|
|
. /usr/local/bin/sequencer.sh
|