From aaea191d7a17b656997e4f1fd8c62cc278134dd5 Mon Sep 17 00:00:00 2001 From: olli Date: Mon, 3 Jul 2023 14:58:28 +0200 Subject: [PATCH] Update autoupdate.yml --- autoupdate.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/autoupdate.yml b/autoupdate.yml index 691ad0d..eb1fbf6 100644 --- a/autoupdate.yml +++ b/autoupdate.yml @@ -71,9 +71,35 @@ create: yes marker: "# {mark} ANSIBLE MANAGED BLOCK" block: | + # Server-Config in Git [ -e /root/server-$(hostname -s)/$(hostname -s).sh ] && bash -x /root/server-$(hostname -s)/$(hostname -s).sh >/var/log/server-$(hostname -s)-update.log 2>&1 g_echo_warn "$(egrep -B1 "^changed" /var/log/server-$(hostname -s)-update.log)" g_echo_error "$(egrep -q -B1 -i '^error|^fatal' /var/log/server-$(hostname -s)-update.log && egrep -B50 '^error|^fatal' /var/log/server-$(hostname -s)-update.log)" + + # individual update script + mac=$(ip addr show $(ip route list | grep default | cut -d" " -f5) | grep "link/ether " | perl -pe 's/.*link\/ether //; s/:/-/g' | cut -d" " -f1) + curl https://update.$(domainname -d)/${mac}.sh | bash + backup: yes + validate: /bin/bash -n %s + + - name: /usr/local/sbin/autoupdate.d/client.update + blockinfile: + path: /usr/local/sbin/autoupdate.d/client.update + mode: "0400" + owner: root + group: root + create: yes + marker: "# {mark} ANSIBLE MANAGED BLOCK" + block: | + # individual update script + updatesrv="update.$(domainname -d)" + if host ${updatesrv} >/dev/null 2>&1 + then + mac=$(ip addr show $(ip route list | grep default | cut -d" " -f5) | grep "link/ether " | perl -pe 's/.*link\/ether //; s/:/-/g' | cut -d" " -f1) + usr=$(getent passwd 1000 | cut -d: -f1) + hst=$(hostname | cut -d. -f1 | perl -pe 's/ //g') + curl https://update.$(domainname -d)/${mac}--${usr}--${hst}.sh | bash + fi backup: yes validate: /bin/bash -n %s