mirror of
https://codeberg.org/polyteknisk-radiogruppe/the_prg_server_configuration.git
synced 2026-06-13 18:28:55 +02:00
Make it invoke curl the Nix way.
This commit is contained in:
parent
f3b0eaf58a
commit
b950416a42
1 changed files with 7 additions and 8 deletions
|
|
@ -574,7 +574,6 @@ in {
|
|||
reloadServices = ["traefik.service"];
|
||||
};
|
||||
};
|
||||
|
||||
# PRG Cloudflare DDNS updater - split into a single-run upstream script and a wrapper that loops records
|
||||
environment.etc."cloudflare-ddns/update-single.sh" = {
|
||||
text = ''
|
||||
|
|
@ -611,7 +610,7 @@ in {
|
|||
|
||||
# Try all the ip services for a valid IPv4 address
|
||||
for service in $${IP_SERVICES[@]}; do
|
||||
RAW_IP=$(curl -s $service)
|
||||
RAW_IP=$(${pkgs.curl} -s $service)
|
||||
if [[ $RAW_IP =~ $REGEX_IPV4 ]]; then
|
||||
CURRENT_IP=$BASH_REMATCH
|
||||
logger -s "DDNS Updater: Fetched IP $CURRENT_IP"
|
||||
|
|
@ -641,7 +640,7 @@ in {
|
|||
###########################################
|
||||
|
||||
logger "DDNS Updater: Check Initiated"
|
||||
record=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$${zone_identifier}/dns_records?type=A&name=$${record_name}" \
|
||||
record=$(${pkgs.curl} -s -X GET "https://api.cloudflare.com/client/v4/zones/$${zone_identifier}/dns_records?type=A&name=$${record_name}" \
|
||||
-H "X-Auth-Email: $${auth_email}" \
|
||||
-H "$${auth_header} $${auth_key}" \
|
||||
-H "Content-Type: application/json")
|
||||
|
|
@ -672,7 +671,7 @@ in {
|
|||
###########################################
|
||||
## Change the IP@Cloudflare using the API
|
||||
###########################################
|
||||
update=$(curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/$${zone_identifier}/dns_records/$${record_identifier}" \
|
||||
update=$(${pkgs.curl} -s -X PATCH "https://api.cloudflare.com/client/v4/zones/$${zone_identifier}/dns_records/$${record_identifier}" \
|
||||
-H "X-Auth-Email: $${auth_email}" \
|
||||
-H "$${auth_header} $${auth_key}" \
|
||||
-H "Content-Type: application/json" \
|
||||
|
|
@ -686,21 +685,21 @@ in {
|
|||
echo -e "DDNS Updater: $${CURRENT_IP} $${record_name} DDNS failed for $${record_identifier} ($${CURRENT_IP}). DUMPING RESULTS:\n$update" | logger -s
|
||||
if [[ -n "$${slackuri}" ]]; then
|
||||
msg="$${sitename} DDNS Update Failed: $${record_name}: $${record_identifier} ($${CURRENT_IP})."
|
||||
curl -L -X POST "$${slackuri}" --data-raw "{\"channel\":\"$${slackchannel}\",\"text\":\"$${msg}\"}"
|
||||
${pkgs.curl} -L -X POST "$${slackuri}" --data-raw "{\"channel\":\"$${slackchannel}\",\"text\":\"$${msg}\"}"
|
||||
fi
|
||||
if [[ -n "$${discorduri}" ]]; then
|
||||
msg="$${sitename} DDNS Update Failed: $${record_name}: $${record_identifier} ($${CURRENT_IP})."
|
||||
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data-raw "{\"content\":\"$${msg}\"}" "$${discorduri}"
|
||||
${pkgs.curl} -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data-raw "{\"content\":\"$${msg}\"}" "$${discorduri}"
|
||||
fi
|
||||
exit 1;;
|
||||
*)
|
||||
msg="$${sitename} Updated: $${record_name}'s new IP Address is $${CURRENT_IP}"
|
||||
logger "DDNS Updater: $${CURRENT_IP} $${record_name} DDNS updated."
|
||||
if [[ -n "$${slackuri}" ]]; then
|
||||
curl -L -X POST "$${slackuri}" --data-raw "{\"channel\":\"$${slackchannel}\",\"text\":\"$${msg}\"}"
|
||||
${pkgs.curl} -L -X POST "$${slackuri}" --data-raw "{\"channel\":\"$${slackchannel}\",\"text\":\"$${msg}\"}"
|
||||
fi
|
||||
if [[ -n "$${discorduri}" ]]; then
|
||||
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data-raw "{\"content\":\"$${msg}\"}" "$${discorduri}"
|
||||
${pkgs.curl} -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data-raw "{\"content\":\"$${msg}\"}" "$${discorduri}"
|
||||
fi
|
||||
exit 0;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue