From aea23bbf862994a2b150e90b9393963aacca347e Mon Sep 17 00:00:00 2001 From: Magnus Andersson Date: Fri, 30 Aug 2024 15:39:01 +0200 Subject: [PATCH] multinode-db1: Add initial upload logic of deprtment filtered user lists. --- templates/mariadb/genuserdeplists.sh.erb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/templates/mariadb/genuserdeplists.sh.erb b/templates/mariadb/genuserdeplists.sh.erb index dc2f5eb..36d7d90 100644 --- a/templates/mariadb/genuserdeplists.sh.erb +++ b/templates/mariadb/genuserdeplists.sh.erb @@ -1,12 +1,19 @@ #!/bin/bash +<% basedir="statistics:drive-server-coms" -%> +<% cupath="/opt/mariadb/statistics/users/" -%> + <% @custdata.each do |cust,data| -%> #Customer <%= cust %> has no billing departments. <% if defined?(data[@environment]["billdomains"]) && data[@environment]["billdomains"] -%> mkdir -p /opt/mariadb/statistics/users/<%= cust %> chmod '0700' /opt/mariadb/statistics/users/<%= cust %> <% data[@environment]["billdomains"].each do |dom| -%> - /root/tasks/listusersbydep.sh <%= cust %> <%= dom %> > /opt/mariadb/statistics/users/<%= cust %>/users-<%= dom.gsub(/[.]/, '-') %>.json +/root/tasks/listusersbydep.sh <%= cust %> <%= dom %> > /opt/mariadb/statistics/users/<%= cust %>/users-<%= dom.gsub(/[.]/, '-') %>.json +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%>/ +fi <% end -%> <% end -%> <% end -%>