diff --git a/fhem/contrib/signal/fhem_signal_docker_install.sh b/fhem/contrib/signal/fhem_signal_docker_install.sh new file mode 100755 index 000000000..5bdb9b955 --- /dev/null +++ b/fhem/contrib/signal/fhem_signal_docker_install.sh @@ -0,0 +1,421 @@ +#!/bin/bash +SCRIPTVERSION="$Id:2.1$" +# Author: Adimarantis +# License: GPL +#Install script for FHEM including signal-cli +FHEMVERSION=6.0 +FHEMUSER=fhem +FHEMGROUP=fhem +SIGNALVAR=/var/lib/signal-cli +SIGNALBOTSOURCE=https://github.com/bublath/FHEM-Signalbot +LOG=/tmp/docker_install.log +TMPFILE=/tmp/signal$$.tmp +OPERATION=$1 +BUILDDIR=$HOME/fhem +#Space separated list of additional packages, installed with apt (linux), cpan (perl) or npm (node.js) +APT="usbutils libimage-librsvg-perl perl libcpan-changes-perl liburi-perl" +CPAN="local::lib" +NPM= +#for signal-cli +APT="$APT wget default-jre zip base-files libdbus-1-dev zip build-essential" +#APT="$APT wget haveged default-jre qrencode pkg-config gcc zip libexpat1-dev libxml-parser-perl libtemplate-perl libxml-xpath-perl build-essential xml-twig-tools base-files" +CPAN="$CPAN Protocol::DBus" +#for DBLOG +APT="$APT default-mysql-client libdbd-mysql libdbd-mysql-perl" +#for FRITZBOX +#APT="$APT libjson-perl libwww-perl libsoap-lite-perl libjson-xs-perl libnet-telnet-perl" +#for GoogleCast +#APT="$APT python3 python3-pip python3-dev libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libglib2.0-dev libdbus-1-dev bluez libbluetooth-dev" +#CPAN="$PERL Protocol::WebSocket" +#for Alexa +#APT="$APT nodejs npm" +#NPM="$NPM alexa-fhem" +#gassistent +#APT="$APT nodejs npm libjson-perl" +#NPM="$NPM gassistant-fhem" + + +#Get OS data +if [ -e /etc/os-release ]; then + source /etc/os-release + cat /etc/os-release >$LOG +else + echo "Could not find OS release data - are you on Linux?" + exit +fi + +if grep -q docker /proc/1/cgroup; then + echo "Cannot install Docker inside Docker" + exit +fi + +USER=`id | grep root` +if [ -z "$USER" ]; then + echo "Docker Installation needs to run under root" + exit +fi + +FHEM_UID=`id -u $FHEMUSER` +FHEM_GID=`id -g $FHEMGROUP` + +echo "Will create a Docker FHEM instance including signal-cli for Signalbot usage" +echo +echo "Please verify that these settigns are correct:" +echo "FHEM-Version: $FHEMVERSION" +echo "SIGNALBOT Repository $SIGNALBOTSOURCE" +echo "BUILD directory $BUILDDIR" +echo "User $FHEMUSER ($FHEM_UID)" +echo "Group $FHEMGROUP ($FHEM_GID)" + +# +install_and_check() { +#Check availability of tools and install via apt if missing + TOOL=$1 + PACKAGE=$2 + echo -n "Checking for $TOOL..." + WHICH=`which $TOOL` + if [ -z "$WHICH" ]; then + echo -n "installing ($PACKAGE)" + apt-get -q -y install $PACKAGE >>$LOG + WHICH=`which $TOOL` + if [ -z "$TOOL" ]; then + echo "Failed to install $TOOL" + exit + else + echo "done" + fi + else + echo "available" + fi +} + +install_by_file() { +#Check availability of tools and install via apt if missing + FILE=$1 + PACKAGE=$2 + echo -n "Checking for $FILE..." + if ! [ -e "$FILE" ]; then + echo -n "installing ($PACKAGE)" + apt-get -q -y install $PACKAGE >>$LOG + if ! [ -e "$FILE" ]; then + echo "Failed to install $FILE" + exit + else + echo "done" + fi + else + echo "available" + fi +} + + +check_and_create_path() { +#Check if path is available and create of not + CHECK=$1 + echo -n "Checking for $CHECK..." + if ! [ -d $CHECK ]; then + mkdir $1 + if ! [ -d $CHECK ]; then + echo "Failed to create $CHECK - did you run on sudo?" + exit + else + echo "created" + fi + else + echo "found" + fi + if ! [ -w $CHECK ]; then + echo "Cannot write to $CHECK - did you start this script with sudo?" + exit + fi +} + +check_and_compare_file() { +#Check if a file exists and compare if its the same as our internal reference file + CHECK=$1 + COMPARE=$2 + echo -n "Checking for $CHECK..." + if [ -e $CHECK ]; then + echo "found" + diff $CHECK $COMPARE + DIFF=`diff -q $CHECK $COMPARE` + if ! [ -z "$DIFF" ]; then + echo "$CHECK differs, update (Y/n)? " + read REPLY + if [ "$REPLY" = "y" ]; then + cp $COMPARE $CHECK + echo "$CHECK updated" + else + echo "$CHECK left untouched" + fi + fi + else + cp $COMPARE $CHECK + echo "$CHECK installed" + fi +} + +#Main part - do always, check basic system requirements like OS, packages etc - does not install any signal specific stuff + +ARCH=`arch` +OSNAME=`uname` +RASPI="" + +if [ $OSNAME != "Linux" ]; then + echo "Only Linux systems are supported (you: $OSNAME), quitting" + exit +fi + +if [ "$ID" = "raspbian" ] || [ "$ID" = "Raspian" ] || [ "$ARCH" = "armv7l" ]; then + echo "You seem to be on a Raspberry pi with $ARCH" + RASPI=1 +else + if [ "$ID" = "ubuntu" ] || [ "$ID" = "Ubuntu" ]; then + echo "You seem to run Ubuntu on $ARCH" + else + echo "Your configuration" + uname -a + echo "has not been tested, continue at own risk" + fi +fi + +check_and_update() { + +APTCMD=`which apt` + +if [ -z "$APTCMD" ]; then + echo "Can't find apt command - are you on a supported system?" + exit +fi + +check_and_create_path $BUILDDIR + +install_and_check docker docker.io +install_and_check wget wget + +cd $BUILDDIR + +cat >docker-compose.yml <Dockerfile <entry.sh </tmp/start.log 2>/tmp/start.err +fi + sudo -u $FHEMUSER perl fhem.pl fhem.cfg + echo -n "Waiting for fhem to terminate." + WAIT="runs" + while [ -n "\$WAIT" ] + do + WAIT=\`ps -eo pid,command | grep fhem.pl | grep -v grep\` + echo -n "." + sleep 1 + done +echo "stopped" +EOF + + +cat >org.asamk.Signal.conf < + + + + + + + + + + + + + + + +EOF + +cat >org.asamk.Signal.service <$TMPFILE </var/log/signal.log 2>/var/log/signal.err & + sudo -u $SIGNALUSER ./signal-cli --config $SIGNALVAR daemon --system >/var/log/signal.log 2>/var/log/signal.err & WAITCHECK="grep dbus /var/log/signal.err" fi echo -n "Waiting for signal-cli to become ready." @@ -553,6 +554,10 @@ if [ -z "$OPERATION" ] || [ "$OPERATION" = "system" ] || [ "$OPERATION" = "insta fi fi +if [ $OPERATION = "docker" ]; then + OPERATION="" +fi + # Main flow without option: intall, register if [ -z "$OPERATION" ] || [ $OPERATION = "all" ] || [ $OPERATION = "system" ]; then check_and_update diff --git a/fhem/thirdparty/signal-cli-packages/README b/fhem/thirdparty/signal-cli-packages/README index 683bea7d5..df3396aa6 100644 --- a/fhem/thirdparty/signal-cli-packages/README +++ b/fhem/thirdparty/signal-cli-packages/README @@ -3,20 +3,25 @@ FHEM Module: Signalbot Content: Debian packages to install signal-cli (https://github.com/AsamK/signal-cli) on Debian compatible systems for X86 and ARM CPUs -Name: signal-cli-dbus_0.9.0-1_buster_armhf.deb +Name: signal-cli-dbus_0.9.0-1_glibc2.28_armhf.deb License: GPL-3.0 Source: https://github.com/AsamK/signal-cli -Version with binary libraries for Raspberry OS "Buster" on armv7l hardware +Version with binary libraries for Raspberry OS "Buster" on armv7l hardware (using glibc2.28) + +Name: signal-cli-dbus_0.9.0-1_glibc2.28_amd64.deb +License: GPL-3.0 +Source: https://github.com/AsamK/signal-cli +Version with binary libraries for Debian 10 "Buster" on amd64 hardware (using glibc2.28) Name: signal-cli-dbus_0.9.0-1_glibc2.27_amd64.deb License: GPL-3.0 Source: https://github.com/AsamK/signal-cli -Version with binary libraries for Debian with glibc2.27 (e.g. Ubuntu 18.04) +Version with binary libraries for Ubuntu 18.04 on amd64 (using glibc2.27) Name: signal-cli-dbus_0.9.0-1_glibc2.31_amd64.deb License: GPL-3.0 Source: https://github.com/AsamK/signal-cli -Version with binary libraries for Debian with glibc2.31 (e.g. Ubuntu 20.04) +Version with binary libraries for Ubuntu 20.04 on amd64 (using glibc2.31) The contained binary libraries can be found here: diff --git a/fhem/thirdparty/signal-cli-packages/signal-cli-dbus_0.9.0-1_glibc2.28_amd64.deb b/fhem/thirdparty/signal-cli-packages/signal-cli-dbus_0.9.0-1_glibc2.28_amd64.deb new file mode 100644 index 000000000..734b7b9c8 Binary files /dev/null and b/fhem/thirdparty/signal-cli-packages/signal-cli-dbus_0.9.0-1_glibc2.28_amd64.deb differ