From 4e45dd1733db505049f7bc997d95cbbce5a58deb Mon Sep 17 00:00:00 2001 From: Magnus Andersson Date: Tue, 3 Sep 2024 12:43:13 +0200 Subject: [PATCH] genusersondepartmentlists: Add som logic for error handling --- templates/mariadb/genuserdeplists.sh.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/mariadb/genuserdeplists.sh.erb b/templates/mariadb/genuserdeplists.sh.erb index 36d7d90..54d06b4 100644 --- a/templates/mariadb/genuserdeplists.sh.erb +++ b/templates/mariadb/genuserdeplists.sh.erb @@ -2,6 +2,7 @@ <% basedir="statistics:drive-server-coms" -%> <% cupath="/opt/mariadb/statistics/users/" -%> +status=0 <% @custdata.each do |cust,data| -%> #Customer <%= cust %> has no billing departments. @@ -13,6 +14,10 @@ chmod '0700' /opt/mariadb/statistics/users/<%= cust %> if jq . <%= cupath + cust %>/users-<%= dom.gsub(/[.]/, '-') %>.json &>/dev/null then timeout 30s rclone copy -c --no-check-certificate --webdav-headers "Host,sunet.drive.sunet.se" --use-cookies <%= cupath + cust %>/users-<%= dom.gsub(/[.]/, '-') %>.json <%= basedir%>/<%= cust %>-<%= @environment%>/ + [[ $? -eq 0 ]] || { status=1 ; echo "Error: Upload of user data failed." ; } +else + echo "Error in json data" + status=1 fi <% end -%> <% end -%>