79 lines
1.2 KiB
Bash
79 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
MoveCurr(){
|
|
cpt=$1
|
|
if [[ $cpt -ge 4 ]]
|
|
then
|
|
cpt=1
|
|
else
|
|
((cpt++))
|
|
fi
|
|
case $1 in
|
|
1) echo '/' $cpt;;
|
|
2) echo '-' $cpt;;
|
|
3) echo '\' $cpt;;
|
|
4) echo '|' $cpt;;
|
|
esac
|
|
|
|
|
|
}
|
|
|
|
|
|
Download (){
|
|
Rep=$1
|
|
cpt=1
|
|
#tput ed
|
|
|
|
tput sc
|
|
while [[ ! -z $(ps axf| grep reposync | grep -v grep) ]]
|
|
do
|
|
read -r Curr cpt <<< $(MoveCurr $cpt)
|
|
Orpm=${Rpm}
|
|
OrpmName=$(basename ${Orpm:-/}| sed 's/-[0-9]/|/g' | cut -d"|" -f1)
|
|
Rpm=$(find $Rep -type f -name "*.rpm" -printf "%T@ %p\n" | sort -n | cut -d' ' -f 2- | tail -n 1)
|
|
RpmName=$(basename ${Rpm:-/}| sed 's/-[0-9]/|/g' | cut -d"|" -f1)
|
|
Txt="Downloading ${RpmName:-/}"
|
|
if [[ "${RpmName}" == "$OrpmName" ]] && [[ "$RpmName" != "/" ]]
|
|
then
|
|
RpmSize=$(du -s $Rpm|awk '{print $1}')
|
|
OrpmSize=$(du -s $Orpm|awk '{print $1}')
|
|
[[ "$RpmSize" -eq "$OrpmSize" ]] && Txt="Sync - RPM Signature"
|
|
fi
|
|
[[ "$RpmName" != "/" ]] && Txt="Syncing metada"
|
|
|
|
tput rc; tput el
|
|
echo -ne "\r[${Curr}] - $Txt\r"
|
|
|
|
|
|
sleep 0.2
|
|
done
|
|
|
|
|
|
|
|
}
|
|
Action() {
|
|
echo -n "$1 : "
|
|
shift
|
|
$* &> /dev/null
|
|
if [[ $? -eq 0 ]]
|
|
then
|
|
echo "$(tput setaf 2)OK$(tput sgr0)"
|
|
else
|
|
echo "$(tput setaf 1)FAILED$(tput sgr0)"
|
|
|
|
fi
|
|
Tot=$((Tot+$1))
|
|
|
|
}
|
|
|
|
WhileTrue() {
|
|
|
|
while true
|
|
do
|
|
sleep 1
|
|
done
|
|
|
|
}
|
|
|
|
|