#!/bin/bash 
#
#program to archive cosqm network data
y=2022
mo=03
cosqm_addr=(102.53.11.178:5080)
cosqm_name=(Oukaimeden)
cd /var/www/html/DATA/CoSQM-Network
n=0
while [ $n -le ${#cosqm_addr[*]} ]
do addr=${cosqm_addr[$n]}
   name=${cosqm_name[$n]}
   let n=n+1
   /bin/echo "Downloading " $name " ..." $n"/"${#cosqm_addr[*]}
   /bin/rm -fr $addr
   /usr/bin/wget -np -q --cut-dirs 3 -r  -R "index.html*" http://$addr/data/$y/$mo/
   echo $name " done."
   if [ ! -s "$name/data/$y" ]; then /bin/mkdir $name/data/$y; fi
   if [ ! -s "$name/data/$y/$mo" ]; then /bin/mkdir $name/data/$y/$mo; fi
   /bin/cp -fr $addr/* $name/data/$y/$mo/
   /bin/rm -fr $addr
done
