Skip to content

updatehoneypotip.sh fails trying to add piid #322

@Bill-Thorsteinson

Description

@Bill-Thorsteinson

Update to version 98 today. After installation, the following error was logged for the cron job running "/srv/dshield/updatehoneypotip.sh"

grep: dshield.ini: No such file or directory
sed: -e expression #1, char 1: unknown command: `^'

After investigating, I found the error was related to a missing path for the grep query checking to see if "piid" had been set. The following patch prevents the sed command from being run when piid has already been defined. I don't believe it fixes the sed expression failure.

diff --git a/bin/updatehoneypotip.sh b/bin/updatehoneypotip.sh
index 1d45894..935f920 100755
--- a/bin/updatehoneypotip.sh
+++ b/bin/updatehoneypotip.sh
@@ -15,9 +15,9 @@ fi
 honeypotip=$(curl -s https://www4.dshield.org/api/myip?json | jq .ip | tr -d '"')
 if echo -n $honeypotip | egrep -q '^[0-9\.]+$'; then
     sed -i "s/^honeypotip=.*/honeypotip=$honeypotip/" /srv/dshield/etc/dshield.ini
-    if ! grep -q '^piid=' dshield.ini; then
+    if ! grep -q '^piid=' /srv/dshield/etc/dshield.ini; then
        piid=$(openssl rand -hex 10)
-       sed -i "^apikey/a piid=$piid"  /srv/dshield/etc/dshield.ini
+       sed -i "^apikey/a piid=$piid" /srv/dshield/etc/dshield.ini
     fi
 else
     echo "Bad IP address"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions