tpotce/docker/tpotinit/dist/bin/updateip.sh

50 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
# Let's add the first local ip to the /tmp/etc/issue and external ip to ews.ip file
# If the external IP cannot be detected, the internal IP will be inherited.
myUUID=$(cat /data/uuid)
myLOCALIP=$(ip address show | awk '/inet .*brd/{split($2,a,"/"); print a[1]; exit}')
myEXTIP=$(/opt/tpot/bin/myip.sh)
if [ "$myEXTIP" = "" ];
then
myEXTIP=$myLOCALIP
fi
2022-02-03 23:32:34 +00:00
myBLACKHOLE_STATUS=$(ip r | grep "blackhole" -c)
if [ "$myBLACKHOLE_STATUS" -gt "500" ];
2022-02-03 23:32:34 +00:00
then
myBLACKHOLE_STATUS="| BLACKHOLE: [ ENABLED ]"
2022-02-03 23:32:34 +00:00
else
myBLACKHOLE_STATUS="| BLACKHOLE: [ DISABLED ]"
2022-02-03 23:32:34 +00:00
fi
2022-02-09 19:13:18 +00:00
# Build issue
echo "" > /tmp/etc/issue
echo "T-Pot 23.12" >> /tmp/etc/issue
echo >> /tmp/etc/issue
echo ",---- [ \n ] [ \d ] [ \t ]" >> /tmp/etc/issue
echo "|" >> /tmp/etc/issue
echo "| IP: $myLOCALIP ($myEXTIP)" >> /tmp/etc/issue
echo "| SSH: ssh -l tsec -p 64295 $myLOCALIP" >> /tmp/etc/issue
#if [ "$myCHECKIFSENSOR" == "0" ];
# then
echo "| WEB: https://$myLOCALIP:64297" >> /tmp/etc/issue
#fi
echo "| ADMIN: https://$myLOCALIP:64294" >> /tmp/etc/issue
echo "$myBLACKHOLE_STATUS" >> /tmp/etc/issue
echo "|" >> /tmp/etc/issue
echo "\`----" >> /tmp/etc/issue
echo >> /tmp/etc/issue
tee /data/ews/conf/ews.ip << EOF
[MAIN]
ip = $myEXTIP
EOF
tee /data/tpot/etc/compose/elk_environment << EOF
2020-10-15 09:14:30 +00:00
HONEY_UUID=$myUUID
MY_EXTIP=$myEXTIP
MY_INTIP=$myLOCALIP
MY_HOSTNAME=$HOSTNAME
EOF
chown tpot:tpot /data/ews/conf/ews.ip
2019-05-08 11:16:48 +00:00
chmod 770 /data/ews/conf/ews.ip