basics.yml aktualisiert

This commit is contained in:
olli 2024-02-21 17:37:31 +01:00
parent c70eb028bb
commit 2cb8bbc874

View File

@ -761,49 +761,59 @@
message=$(echo -e "$subj\n$message")
fi
## SSH
if [ -n "$SSH_ORIGINAL_COMMAND" ]
then
subj=$(echo "$SSH_ORIGINAL_COMMAND" | sed 's#^/usr/local/bin/notify.sh##; s/^ *//; s/^\"//; s/\"$//')
message=$(echo -e "$subj$message")
fi
## MAIL
if [ -n "$tomail" ]
then
echo "$message" | mail -s "notify.sh: $subj" $tomail
fi
if ! [ -f /home/signal/.local/share/signal-cli/data/accounts.json ]
## MATRIX
if [ -f /home/docker/matrix.$(hostname)/matrix-commander-data/credentials.json ]
then
echo "No Signal account?!"
exit 1
docker compose -f /home/docker/matrix.$(hostname)/docker-compose.yml run -T matrix.$(hostname)--commander -m "$message" --log-level WARNING WARNING
fi
account=$(cat /home/signal/.local/share/signal-cli/data/accounts.json | jq -r '.accounts[0].number' | sed 's/+/_/')
if [ -z "$account" ]
## SIGNAL
if [ -f /home/signal/.local/share/signal-cli/data/accounts.json ]
then
echo "Didn't get Signal account"
exit 1
fi
if [ -n "$togroup" ]
then
# Send to group via dbus
# Get group ID via dbus according to: https://github.com/AsamK/signal-cli/issues/1046
groupid=$(dbus-send --system --type=method_call --print-reply --dest='org.asamk.Signal' /org/asamk/Signal/${account} org.asamk.Signal.listGroups | grep "$togroup" -B3 | head -n2 | perl -pe 's/\n/ /g;' | perl -pe 's/ +/ /g; s/ $//; s/ /,0x/g; s/^,//')
if [ -z "$groupid" ]
account=$(cat /home/signal/.local/share/signal-cli/data/accounts.json | jq -r '.accounts[0].number' | sed 's/+/_/')
if [ -z "$account" ]
then
g_echo_error "Group(ID) $togroup not found (id=$groupid). Does Group really exist? -- Groups $(dbus-send --system --type=method_call --print-reply --dest='org.asamk.Signal' /org/asamk/Signal/${account} org.asamk.Signal.listGroups)"
echo "Didn't get Signal account"
exit 1
fi
dbus-send --system --type=method_call --print-reply --dest="org.asamk.Signal" /org/asamk/Signal/${account} org.asamk.Signal.sendGroupMessage string:"$message" array:string: array:byte:${groupid} | egrep -v '^method return time=|^ int64 '
if [ -n "$togroup" ]
then
# Send to group via dbus
# Get group ID via dbus according to: https://github.com/AsamK/signal-cli/issues/1046
groupid=$(dbus-send --system --type=method_call --print-reply --dest='org.asamk.Signal' /org/asamk/Signal/${account} org.asamk.Signal.listGroups | grep "$togroup" -B3 | head -n2 | perl -pe 's/\n/ /g;' | perl -pe 's/ +/ /g; s/ $//; s/ /,0x/g; s/^,//')
if [ -z "$groupid" ]
then
g_echo_error "Group(ID) $togroup not found (id=$groupid). Does Group really exist? -- Groups $(dbus-send --system --type=method_call --print-reply --dest='org.asamk.Signal' /org/asamk/Signal/${account} org.asamk.Signal.listGroups)"
exit 1
fi
dbus-send --system --type=method_call --print-reply --dest="org.asamk.Signal" /org/asamk/Signal/${account} org.asamk.Signal.sendGroupMessage string:"$message" array:string: array:byte:${groupid} | egrep -v '^method return time=|^ int64 '
fi
if [ -n "$to" ]
then
# Sent to a single Number via dbus
dbus-send --system --type=method_call --print-reply --dest="org.asamk.Signal" /org/asamk/Signal/${account} org.asamk.Signal.sendMessage string:"${message}" array:string: string:${to} | egrep -v '^method return time=|^ int64 '
fi
fi
if [ -n "$to" ]
then
# Sent to a single Number via dbus
dbus-send --system --type=method_call --print-reply --dest="org.asamk.Signal" /org/asamk/Signal/${account} org.asamk.Signal.sendMessage string:"${message}" array:string: string:${to} | egrep -v '^method return time=|^ int64 '
fi
backup: yes
validate: /bin/bash -n %s