#!/bin/bash
sorgenti=( 'https://ufficiozero.mirror.garr.it/3rd-party-software/arubasign/22.1.6/ArubaSign-latest-LINUX.tar.bz2' \
 'https://sourceforge.net/projects/ufficiozero/files/3rd-party-software/arubasign/22.1.6/ArubaSign-latest-LINUX.tar.bz2' \ 
'https://ftp.acc.umu.se/mirror/ufficiozero.org/3rd-party-software/arubasign/22.1.6/ArubaSign-latest-LINUX.tar.bz2' \ 
'https://ftp.icm.edu.pl/pub/Linux/dist/ufficiozero/3rd-party-software/arubasign/22.1.6/ArubaSign-latest-LINUX.tar.bz2' \ 
'https://mirrors.dotsrc.org/ufficiozero/3rd-party-software/arubasign/22.1.6/ArubaSign-latest-LINUX.tar.bz2' \
'https://ftp.nluug.nl/pub/os/Linux/distr/ufficiozero/3rd-party-software/arubasign/22.1.6/ArubaSign-latest-LINUX.tar.bz2' \
'https://quantum-mirror.hu/mirrors/pub/ufficiozero/3rd-party-software/arubasign/22.1.6/ArubaSign-latest-LINUX.tar.bz2' )

if mkdir -p ~/.arubasign && cd ~/.arubasign; then
    x=0
    while [ "$x" -lt ${#sorgenti[*]} ]; do
        wget -O ArubaSign-latest-LINUX.tar.bz2 ${sorgenti[$x]} && break
        let x++
    done
    
    if [ "$x" -lt ${#sorgenti[*]} ]; then
        tar -xjvf ArubaSign-latest-LINUX.tar.bz2
        f_name=`ls -d ArubaSign-[0-9]* | sort | tail -1`
        if [ -d "$f_name" ]; then
            chmod +x ./"$f_name"/users/install.sh &&
            ./"$f_name"/users/install.sh
        fi
    fi
fi
