tools -> scripts
This commit is contained in:
30
scripts/duckdns/update.sh
Executable file
30
scripts/duckdns/update.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1091
|
||||
thisdir="$( dirname "$(readlink -e -- "${BASH_SOURCE[0]}")")"
|
||||
|
||||
log() {
|
||||
timestamp="$(date +'%Y-%m-%d %H:%M:%S')"
|
||||
datestamp="$(date +'%Y-%m-%d')"
|
||||
[ ! -d "$thisdir/log" ] && mkdir "$thisdir/log"
|
||||
echo "[$timestamp] $*" >> "$thisdir/log/$datestamp.log"
|
||||
}
|
||||
|
||||
[ ! -f "$thisdir/.env" ] && {
|
||||
log "ERROR: .env not exists"
|
||||
exit 1
|
||||
}
|
||||
|
||||
source "$thisdir/.env"
|
||||
|
||||
[ -z "$DUCK_TOKEN" ] && {
|
||||
log "ERROR: env var DUCK_TOKEN not specified"
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -z "$DUCK_DOMAINS" ] && {
|
||||
log "ERROR: env var DUCK_DOMAINS not specified"
|
||||
exit 1
|
||||
}
|
||||
|
||||
result=$(curl -s "https://www.duckdns.org/update?domains=${DUCK_DOMAINS}&token=${DUCK_TOKEN}&ip=${DUCK_IP}")
|
||||
log "$result"
|
||||
Reference in New Issue
Block a user