gedankensplitter/code-snippets.md
2023-03-22 13:39:31 +01:00

2.1 KiB

Code Snippets

fritzbox reboot

  • does not work under openwrt/ash!
#!/usr/bin/env bash
# crontab-line
# 5 2 * * 7 /root/reboot_fritzbox.sh
# http://fritz.box:49000/tr64desc.xml
# https://wiki.fhem.de/wiki/FRITZBOX#TR-064
# https://avm.de/service/schnittstellen/

credentials=":password"
FB="fritz.box:49000"

location_ext='/tr064/upnp/control/deviceconfig'
location_int='/upnp/control/deviceconfig'
uri='urn:dslforum-org:service:DeviceConfig:1'
action='Reboot'

curl -v -4 -k --anyauth -u "${credentials}" http://${FB}${location_int} \
            -H 'Content-Type: text/xml; charset="utf-8"' \
                -H "SoapAction:${uri}#${action}" \
                    -d "<?xml version='1.0' encoding='utf-8'?>
        <s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
                xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body>
                        <u:${action} xmlns:u='${uri}'></u:${action}></s:Body></s:Envelope>"
                        # > /dev/null

fritzbox export debug report via call

#!/bin/bash
credentials="username:pw"
FB="10.0.1.1:49000"
Rufnummer="*99#";


curl -4 -k --anyauth -u "${credentials}"                                    \
     "http://${FB}/upnp/control/x_voip"                                     \
     -H 'Content-Type: text/xml; charset="utf-8"'                           \
     -H 'SoapAction: urn:dslforum-org:service:X_VoIP:1#X_AVM-DE_DialNumber' \
     -d '<?xml version="1.0" encoding="utf-8"?>
         <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                     xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
            <s:Body>
               <u:X_AVM-DE_DialNumber xmlns:u="urn:dslforum-org:service:X_VoIP:1">
                 <NewX_AVM-DE_PhoneNumber>'${Rufnummer}'</NewX_AVM-DE_PhoneNumber>
               </u:X_AVM-DE_DialNumber>
            </s:Body>
         </s:Envelope>' 
#> /dev/null 2>&1

socat as syslog server

socat -u udp4-listen:514,bind=192.0.2.10, open:/tmp/syslog,creat,append

grep on binary text data

tr '[\000-\011\013\177-\377]' '.' < Logfile.txt | grep anything