Commit f8bbb6df authored by 神楽坂玲奈's avatar 神楽坂玲奈

Initial commit

parents
FROM debian
RUN apt update && apt install -y \
dnsutils \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY ddns-route.sh .
CMD ["/usr/src/app/ddns-route.sh"]
#!/bin/bash
#DOMAIN=$1
#PROTO=$2
#TAIL=$3
while :
do
EXISTING_ROUTE=$(ip route | grep "proto $PROTO")
EXISTING=$(ip route | grep "proto $PROTO" | awk '{print $1}')
CURRENT=$(dig $DOMAIN +short)
if [ $? != 0 ]; then
echo "DNS error"
exit 1
fi
echo $EXISTING $CURRENT
if [ "$EXISTING" == "$CURRENT" ]; then
echo "Same"
else
echo "Diff"
DEL_CMD="ip route del $EXISTING_ROUTE"
ADD_CMD="ip route add $CURRENT proto $PROTO $TAIL"
echo $DEL_CMD
echo $ADD_CMD
bash -c "$DEL_CMD"
bash -c "$ADD_CMD"
fi
sleep 60
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment