31 lines
715 B
Bash
Executable File
31 lines
715 B
Bash
Executable File
#!/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"
|