aboutsummaryrefslogtreecommitdiff
path: root/brweather/brweather
diff options
context:
space:
mode:
Diffstat (limited to 'brweather/brweather')
-rwxr-xr-xbrweather/brweather1063
1 files changed, 822 insertions, 241 deletions
diff --git a/brweather/brweather b/brweather/brweather
index 467adae..f61171d 100755
--- a/brweather/brweather
+++ b/brweather/brweather
@@ -6,49 +6,50 @@
# http://brweatherproject.blogspot.com/
# Distribuído sob licença GPLv3
-# Pasta base
-DIRNAME="$(dirname `dirname $0`)"
-
##Conferindo se o usuário não é root
if [ `whoami` = "root" ] ; then
-echo "Erro: O BrWeather deve ser usado apenas como usuário normal."
-exit 1
+ echo "Erro: O BrWeather deve ser usado apenas como usuário normal."
+ exit 1
fi
##Conferindo se já existe o arquivo de configuração
-conf(){
-mkdir ~/.brweather
-mkdir ~/.brweather/cache
-cp $DIRNAME/brweather/doc/brweather.conf.default ~/.brweather.conf
+CONF(){
+ echo "Criando pasta de configuração ~/.brweather..."
+ mkdir ~/.brweather
+ mkdir ~/.brweather/cache
}
-conf2(){
-cp $DIRNAME/brweather/doc/brweather.conf.default ~/.brweather.conf
+CONF2(){
+ echo "Criando arquivo de configuração ~/.brweather.conf"
+ cp /opt/brweather/doc/brweather.conf.default ~/.brweather.conf
}
-conf3(){
-mkdir ~/.brweather/cache
+CONF3(){
+ mkdir ~/.brweather/cache
}
-ls ~/.brweather &>/dev/null || conf
-cat ~/.brweather.conf &>/dev/null || conf2
-ls ~/.brweather/cache &>/dev/null || conf3
+
+cat ~/.brweather.conf &>/dev/null || CONF2
+ls ~/.brweather &>/dev/null || CONF
+ls ~/.brweather/cache &>/dev/null || CONF3
##Conferindo se foi utilizada alguma opção
if [ -z $1 ] ; then
-echo 'Utilize alguma opção.
+ echo ""
+ echo 'Utilize alguma opção.
Uso: brweather [OPÇÃO]
Tente "brweather --help" para mais opções.'
-exit 1
+ exit 1
fi
##Mensagens de Erro
+
LOG=`date "+%A %d/%m/%Y %H:%M:%S"`
-ERRO1="Log $LOG COD#`date +%s`
+ERROA1="Log $LOG COD#`date +%s`
Falha no cache INPE
Falha ao obter dados das previsões.
@@ -65,8 +66,8 @@ Se o erro persistir por vários dias, entre em contato com o desenvolvedor pelo
leandronkz@gmail.com"
-ERROG1="Log $LOG COD#`date +%s`
-Falha no cache Google
+ERROB1="Log $LOG COD#`date +%s`
+Falha no cache OPEN
Falha ao obter dados das previsões.
Isso pode ser causado por:
@@ -84,7 +85,7 @@ leandronkz@gmail.com"
##Versão do programa
-VERSION=`cat $DIRNAME/brweather/doc/version`
+VERSION=`cat /opt/brweather/doc/version`
##Ler arquivo de configuração
@@ -92,343 +93,923 @@ source ~/.brweather.conf
##Opções do programa que não precisam de Internet
case $1 in
- "--gerar-log") source $DIRNAME/brweather/bin/logs
- exit 0
+"--gerar-log") source /opt/brweather/bin/logs
+ exit 0
;;
- "--version") echo "BrWeather-$VERSION"
- exit 0
+"--version") echo "BrWeather-$VERSION"
+ exit 0
;;
- "--autor") echo "LeandroNKZ <leandronkz@gmail.com>"
- echo "http://brweatherproject.blogspot.com/"
- exit 0
+"--autor") echo "LeandroNKZ <leandronkz@gmail.com>"
+ echo "http://brweatherproject.blogspot.com/"
+ exit 0
;;
- "--help") cat $DIRNAME/brweather/doc/help
- exit 0
+"--help") cat /opt/brweather/doc/help
+ exit 0
;;
- "--help-default") cat $DIRNAME/brweather/doc/help-default
- exit 0
+"--help-default") cat /opt/brweather/doc/help-default
+ exit 0
;;
- "--help-google") cat $DIRNAME/brweather/doc/help-google
- exit 0
+"--help-open") cat /opt/brweather/doc/help-open
+ exit 0
;;
- "--man") man $DIRNAME/brweather/doc/man
- exit 0
+"--help-google")
+ echo "Opção descontinuada. Tente:
+ --help-open"
+ exit 0
;;
- "--clean-cache") rm ~/.brweather/log* 2>/dev/null & rm ~/.brweather/cache/* 2>/dev/null
- echo "Cache limpo!"
- exit 0
+"--man") man /opt/brweather/doc/man
+ exit 0
;;
- "--total-images") echo -e "imagem1\nimagem2\nimagem3\nimagem4\nimagem5\nimagem6\nimagem7\nimagem8\nimagem9\nimagem10"
- exit 0
+"--clean-cache") rm ~/.brweather/log* 2>/dev/null & rm ~/.brweather/cache/* 2>/dev/null
+ echo "Cache limpo!"
+ exit 0
;;
- "--changelog") cat $DIRNAME/brweather/doc/Changelog
- exit 0
+"--changelog") cat /opt/brweather/doc/Changelog
+ exit 0
;;
- "--option=LUA"*) source $DIRNAME/brweather/bin/moon $*
- exit 0
+"--option=LUA"*) source /opt/brweather/bin/moon $*
+ exit 0
;;
- "--season"*) source $DIRNAME/brweather/bin/seasons $*
- exit 0
+"--season"*) source /opt/brweather/bin/seasons $*
+ exit 0
+;;
+"--mode")
+ if [ $OPEN = "0" ] ; then
+ echo "O modo INPE está ativado."
+ else
+ echo "O modo OPEN está ativado."
+ fi
+exit 0
;;
esac
+
+if [ $1 = "--total-images" ] ; then
+ if [ `ls /opt/brweather/imagens/ | grep imagem | wc -l` -gt 7 ] ; then
+ echo -e "imagem1\nimagem2\nimagem3\nimagem4\nimagem5\nimagem6\nimagem7\nimagem8\nimagem9\nimagem10\nimagem11\nimagem12" && exit 0
+ else
+ echo -e "imagem1\nimagem2\nimagem3\nimagem4\nimagem5\nimagem6\nimagem7" && exit 0
+ fi
+fi
+
#Baixar cache de previsões
+if [ $OPEN = "0" ] ; then
cat ~/.brweather/cache/timer &>/dev/null || echo "0" > ~/.brweather/cache/timer
+
TIME=`date '+%s'`
TIME1=`cat ~/.brweather/cache/timer`
TIME2=$(($TIME+$TIMER))
-if [ $TIME1 -lt $TIME ]
-then
- if [ $GOOGLE = "0" ] ; then
- wget -q -T $TIME -O ~/.brweather/cache/previsao "http://tempo1.cptec.inpe.br/cidades/tempo/$CPTEC_INPE"
- echo $TIME2 > ~/.brweather/cache/timer
- cat ~/.brweather/cache/previsao | iconv -f iso-8859-1 -t $CODIGO -o ~/.brweather/cache/previsao
- else
- wget -q -T $TIME -O ~/.brweather/cache/previsaog "http://www.google.com/ig/api?weather=$CITY,$STATE,$COUNTRY&hl=pt-br"
- echo $TIME2 > ~/.brweather/cache/timer
- cat ~/.brweather/cache/previsaog | iconv -f iso-8859-1 -t $CODIGO -o ~/.brweather/cache/previsaog
- fi
- if [ $GOOGLE = "0" ] ; then
- if [ -f "`grep -m1 -A1 '<div id="subcid">' ~/.brweather/cache/previsao | cut -f2 -d'>' | cut -f1 -d'<' | tail -n1`" ] ; then
- echo "$ERRO1" > ~/.brweather/log
- echo $(($TIME+10)) > ~/.brweather/cache/timer
- else
- cat ~/.brweather/cache/previsao > ~/.brweather/cache/cache
- sed -i 's/\r//g' ~/.brweather/cache/cache
- date "+%H:%M:%S" > ~/.brweather/cache/lastupdate
- fi
- else
- if [ -f `cut -f23 -d= ~/.brweather/cache/previsaog | cut -f1 -d/ | cut -f2 -d'"'` ] ; then
- echo "$ERROG1" > ~/.brweather/log
- echo $(($TIME+10)) > ~/.brweather/cache/timer
- else
- cat ~/.brweather/cache/previsaog > ~/.brweather/cache/gcache
- date "+%H:%M:%S" > ~/.brweather/cache/lastupdate
- fi
- fi
+else
+cat ~/.brweather/cache/timer2 &>/dev/null || echo "0" > ~/.brweather/cache/timer2
+
+TIME=`date '+%s'`
+TIME1=`cat ~/.brweather/cache/timer2`
+TIME2=$(($TIME+$TIMER))
+fi
+
+
+
+if [ $TIME1 -lt $TIME ] ; then
+ if [ $OPEN = "0" ] ; then
+ wget -q -T $TIME -O ~/.brweather/cache/previsao "http://tempo1.cptec.inpe.br/cidades/tempo/$CPTEC_INPE"
+ echo $TIME2 > ~/.brweather/cache/timer
+ cat ~/.brweather/cache/previsao | iconv -f iso-8859-1 -t $CODIGO -o ~/.brweather/cache/previsao
+ else
+ wget -q -T $TIME -O ~/.brweather/cache/open1_A "http://openweathermap.org/data/2.1/weather/city/$OPEN_ID"
+ wget -q -T $TIME -O ~/.brweather/cache/open2_A "http://openweathermap.org/data/2.1/forecast/city/$OPEN_ID"
+ echo $TIME2 > ~/.brweather/cache/timer2
+ fi
+
+ if [ $OPEN = "0" ] ; then
+ if [ -f `grep -m1 -A1 '<div id="subcid">' ~/.brweather/cache/previsao | cut -f2 -d'>' | cut -f1 -d'<' | tail -n1` ] ; then
+ echo "$ERROA1" > ~/.brweather/log
+ echo $(($TIME+30)) > ~/.brweather/cache/timer
+ else
+ cat ~/.brweather/cache/previsao > ~/.brweather/cache/cache
+ sed -i 's/\r//g' ~/.brweather/cache/cache
+ date "+%H:%M:%S" > ~/.brweather/cache/lastupdate
+ fi
+ else
+ if [ -f $(awk -F"[,:]" '{for(i=1;i<=NF;i++){if($i~/name\042/){print$(i+1)}}}' ~/.brweather/cache/open1_A) ] ; then
+ echo "$ERROB1" > ~/.brweather/log
+ echo $(($TIME+50)) > ~/.brweather/cache/timer2
+ else
+ date "+%H:%M:%S" > ~/.brweather/cache/lastupdate
+ cat ~/.brweather/cache/open1_A > ~/.brweather/cache/open1
+ fi
+
+ if [ -f $(awk -F"[,:]" '{for(i=1;i<=NF;i++){if($i~/name\042/){print$(i+1)}}}' ~/.brweather/cache/open2_A) ] ; then
+ echo "$ERROB1" > ~/.brweather/log
+ echo $(($TIME+50)) > ~/.brweather/cache/timer2
+ else
+ cat ~/.brweather/cache/open2_A | sed 's/{"dt"/\n"{dt"/g' > ~/.brweather/cache/open2_B
+ grep "dt_calc" ~/.brweather/cache/open2_B | sed 's/id/cityid/g' > ~/.brweather/cache/open2
+ for i in `egrep ^'"{dt":' ~/.brweather/cache/open2_B | cut -f2 -d':' | cut -f1 -d','` ; do
+ DATE=`date -d "1/1/1970 + $i seconds" "+%a:%H"`
+ grep "\"{dt\":$i" ~/.brweather/cache/open2_B | sed -e "s/$i/$DATE:/" >> ~/.brweather/cache/open2
+ done
+ fi
+ fi
fi
#Imagens
IMAGE=`echo '${image'`
+if [ `ls /opt/brweather/imagens/ | grep imagem | wc -l` -gt 7 ] ; then
+
case $1 in
##CN
- "--imagem1=CN")
- IMAGEM=`echo "1"`
+"--imagem1=CN")
+IMAGEM="1"
+;;
+"--imagem2=CN")
+IMAGEM="2"
;;
- "--imagem2=CN")
- IMAGEM=`echo "2"`
+"--imagem3=CN")
+IMAGEM="3"
;;
- "--imagem3=CN")
- IMAGEM=`echo "3"`
+"--imagem4=CN")
+IMAGEM="4"
;;
- "--imagem4=CN")
- IMAGEM=`echo "4"`
+"--imagem5=CN")
+IMAGEM="5"
;;
- "--imagem5=CN")
- IMAGEM=`echo "5"`
+"--imagem6=CN")
+IMAGEM="6"
;;
- "--imagem6=CN")
- IMAGEM=`echo "6"`
+"--imagem7=CN")
+IMAGEM="7"
;;
- "--imagem7=CN")
- IMAGEM=`echo "7"`
+"--imagem8=CN")
+IMAGEM="8"
;;
- "--imagem8=CN")
- IMAGEM=`echo "8"`
+"--imagem9=CN")
+IMAGEM="9"
;;
- "--imagem9=CN")
- IMAGEM=`echo "9"`
+"--imagem10=CN")
+IMAGEM="10"
;;
- "--imagem10=CN")
- IMAGEM=`echo "10"`
+"--imagem11=CN")
+IMAGEM="11"
+;;
+"--imagem12=CN")
+IMAGEM="12"
+;;
+"--imagem"*=CN)
+echo "Tema de imagens não encontrado." && exit 1
;;
##C1
- "--imagem1=C1")
- IMAGEM=`echo "1"`
+"--imagem1=C1")
+IMAGEM="1"
+;;
+"--imagem2=C1")
+IMAGEM="2"
+;;
+"--imagem3=C1")
+IMAGEM="3"
;;
- "--imagem2=C1")
- IMAGEM=`echo "2"`
+"--imagem4=C1")
+IMAGEM="4"
;;
- "--imagem3=C1")
- IMAGEM=`echo "3"`
+"--imagem5=C1")
+IMAGEM="5"
;;
- "--imagem4=C1")
- IMAGEM=`echo "4"`
+"--imagem6=C1")
+IMAGEM="6"
;;
- "--imagem5=C1")
- IMAGEM=`echo "5"`
+"--imagem7=C1")
+IMAGEM="7"
;;
- "--imagem6=C1")
- IMAGEM=`echo "6"`
+"--imagem8=C1")
+IMAGEM="8"
;;
- "--imagem7=C1")
- IMAGEM=`echo "7"`
+"--imagem9=C1")
+IMAGEM="9"
;;
- "--imagem8=C1")
- IMAGEM=`echo "8"`
+"--imagem10=C1")
+IMAGEM="10"
;;
- "--imagem9=C1")
- IMAGEM=`echo "9"`
+"--imagem11=C1")
+IMAGEM="11"
;;
- "--imagem10=C1")
- IMAGEM=`echo "10"`
+"--imagem12=C1")
+IMAGEM="12"
+;;
+"--imagem"*=C1)
+echo "Tema de imagens não encontrado." && exit 1
;;
##C2
- "--imagem1=C2")
- IMAGEM=`echo "1"`
+"--imagem1=C2")
+IMAGEM="1"
+;;
+"--imagem2=C2")
+IMAGEM="2"
+;;
+"--imagem3=C2")
+IMAGEM="3"
+;;
+"--imagem4=C2")
+IMAGEM="4"
;;
- "--imagem2=C2")
- IMAGEM=`echo "2"`
+"--imagem5=C2")
+IMAGEM="5"
;;
- "--imagem3=C2")
- IMAGEM=`echo "3"`
+"--imagem6=C2")
+IMAGEM="6"
;;
- "--imagem4=C2")
- IMAGEM=`echo "4"`
+"--imagem7=C2")
+IMAGEM="7"
;;
- "--imagem5=C2")
- IMAGEM=`echo "5"`
+"--imagem8=C2")
+IMAGEM="8"
;;
- "--imagem6=C2")
- IMAGEM=`echo "6"`
+"--imagem9=C2")
+IMAGEM="9"
;;
- "--imagem7=C2")
- IMAGEM=`echo "7"`
+"--imagem10=C2")
+IMAGEM="10"
;;
- "--imagem8=C2")
- IMAGEM=`echo "8"`
+"--imagem11=C2")
+IMAGEM="11"
;;
- "--imagem9=C2")
- IMAGEM=`echo "9"`
+"--imagem12=C2")
+IMAGEM="12"
;;
- "--imagem10=C2")
- IMAGEM=`echo "10"`
+"--imagem"*=C2)
+echo "Tema de imagens não encontrado." && exit 1
;;
##C3
- "--imagem1=C3")
- IMAGEM=`echo "1"`
+"--imagem1=C3")
+IMAGEM="1"
;;
- "--imagem2=C3")
- IMAGEM=`echo "2"`
+"--imagem2=C3")
+IMAGEM="2"
;;
- "--imagem3=C3")
- IMAGEM=`echo "3"`
+"--imagem3=C3")
+IMAGEM="3"
;;
- "--imagem4=C3")
- IMAGEM=`echo "4"`
+"--imagem4=C3")
+IMAGEM="4"
;;
- "--imagem5=C3")
- IMAGEM=`echo "5"`
+"--imagem5=C3")
+IMAGEM="5"
;;
- "--imagem6=C3")
- IMAGEM=`echo "6"`
+"--imagem6=C3")
+IMAGEM="6"
;;
- "--imagem7=C3")
- IMAGEM=`echo "7"`
+"--imagem7=C3")
+IMAGEM="7"
;;
- "--imagem8=C3")
- IMAGEM=`echo "8"`
+"--imagem8=C3")
+IMAGEM="8"
;;
- "--imagem9=C3")
- IMAGEM=`echo "9"`
+"--imagem9=C3")
+IMAGEM="9"
;;
- "--imagem10=C3")
- IMAGEM=`echo "10"`
+"--imagem10=C3")
+IMAGEM="10"
+;;
+"--imagem11=C3")
+IMAGEM="11"
+;;
+"--imagem12=C3")
+IMAGEM="12"
+;;
+"--imagem"*=C3)
+echo "Tema de imagens não encontrado." && exit 1
;;
##C4
- "--imagem1=C4")
- IMAGEM=`echo "1"`
+"--imagem1=C4")
+IMAGEM="1"
+;;
+"--imagem2=C4")
+IMAGEM="2"
;;
- "--imagem2=C4")
- IMAGEM=`echo "2"`
+"--imagem3=C4")
+IMAGEM="3"
;;
- "--imagem3=C4")
- IMAGEM=`echo "3"`
+"--imagem4=C4")
+IMAGEM="4"
;;
- "--imagem4=C4")
- IMAGEM=`echo "4"`
+"--imagem5=C4")
+IMAGEM="5"
;;
- "--imagem5=C4")
- IMAGEM=`echo "5"`
+"--imagem6=C4")
+IMAGEM="6"
;;
- "--imagem6=C4")
- IMAGEM=`echo "6"`
+"--imagem7=C4")
+IMAGEM="7"
;;
- "--imagem7=C4")
- IMAGEM=`echo "7"`
+"--imagem8=C4")
+IMAGEM="8"
;;
- "--imagem8=C4")
- IMAGEM=`echo "8"`
+"--imagem9=C4")
+IMAGEM="9"
;;
- "--imagem9=C4")
- IMAGEM=`echo "9"`
+"--imagem10=C4")
+IMAGEM="10"
;;
- "--imagem10=C4")
- IMAGEM=`echo "10"`
+"--imagem11=C4")
+IMAGEM="11"
+;;
+"--imagem12=C4")
+IMAGEM="12"
+;;
+"--imagem"*=C4)
+echo "Tema de imagens não encontrado." && exit 1
;;
##C5
- "--imagem1=C5")
- IMAGEM=`echo "1"`
+"--imagem1=C5")
+IMAGEM="1"
+;;
+"--imagem2=C5")
+IMAGEM="2"
+;;
+"--imagem3=C5")
+IMAGEM="3"
;;
- "--imagem2=C5")
- IMAGEM=`echo "2"`
+"--imagem4=C5")
+IMAGEM="4"
;;
- "--imagem3=C5")
- IMAGEM=`echo "3"`
+"--imagem5=C5")
+IMAGEM="5"
;;
- "--imagem4=C5")
- IMAGEM=`echo "4"`
+"--imagem6=C5")
+IMAGEM="6"
;;
- "--imagem5=C5")
- IMAGEM=`echo "5"`
+"--imagem7=C5")
+IMAGEM="7"
;;
- "--imagem6=C5")
- IMAGEM=`echo "6"`
+"--imagem8=C5")
+IMAGEM="8"
;;
- "--imagem7=C5")
- IMAGEM=`echo "7"`
+"--imagem9=C5")
+IMAGEM="9"
;;
- "--imagem8=C5")
- IMAGEM=`echo "8"`
+"--imagem10=C5")
+IMAGEM="10"
;;
- "--imagem9=C5")
- IMAGEM=`echo "9"`
+"--imagem11=C5")
+IMAGEM="11"
;;
- "--imagem10=C5")
- IMAGEM=`echo "10"`
+"--imagem12=C5")
+IMAGEM="12"
+;;
+"--imagem"*=C5)
+echo "Tema de imagens não encontrado." && exit 1
;;
##C6
- "--imagem1=C6")
- IMAGEM=`echo "1"`
+"--imagem1=C6")
+IMAGEM="1"
+;;
+"--imagem2=C6")
+IMAGEM="2"
+;;
+"--imagem3=C6")
+IMAGEM="3"
+;;
+"--imagem4=C6")
+IMAGEM="4"
;;
- "--imagem2=C6")
- IMAGEM=`echo "2"`
+"--imagem5=C6")
+IMAGEM="5"
;;
- "--imagem3=C6")
- IMAGEM=`echo "3"`
+"--imagem6=C6")
+IMAGEM="6"
;;
- "--imagem4=C6")
- IMAGEM=`echo "4"`
+"--imagem7=C6")
+IMAGEM="7"
;;
- "--imagem5=C6")
- IMAGEM=`echo "5"`
+"--imagem8=C6")
+IMAGEM="8"
;;
- "--imagem6=C6")
- IMAGEM=`echo "6"`
+"--imagem9=C6")
+IMAGEM="9"
;;
- "--imagem7=C6")
- IMAGEM=`echo "7"`
+"--imagem10=C6")
+IMAGEM="10"
;;
- "--imagem8=C6")
- IMAGEM=`echo "8"`
+"--imagem11=C6")
+IMAGEM="11"
;;
- "--imagem9=C6")
- IMAGEM=`echo "9"`
+"--imagem12=C6")
+IMAGEM="12"
;;
- "--imagem10=C6")
- IMAGEM=`echo "10"`
+"--imagem"*=C6)
+echo "Tema de imagens não encontrado." && exit 1
;;
##C7
- "--imagem1=C7")
- IMAGEM=`echo "1"`
+"--imagem1=C7")
+IMAGEM="1"
;;
- "--imagem2=C7")
- IMAGEM=`echo "2"`
+"--imagem2=C7")
+IMAGEM="2"
;;
- "--imagem3=C7")
- IMAGEM=`echo "3"`
+"--imagem3=C7")
+IMAGEM="3"
;;
- "--imagem4=C7")
- IMAGEM=`echo "4"`
+"--imagem4=C7")
+IMAGEM="4"
;;
- "--imagem5=C7")
- IMAGEM=`echo "5"`
+"--imagem5=C7")
+IMAGEM="5"
;;
- "--imagem6=C7")
- IMAGEM=`echo "6"`
+"--imagem6=C7")
+IMAGEM="6"
;;
- "--imagem7=C7")
- IMAGEM=`echo "7"`
+"--imagem7=C7")
+IMAGEM="7"
;;
- "--imagem8=C7")
- IMAGEM=`echo "8"`
+"--imagem8=C7")
+IMAGEM="8"
;;
- "--imagem9=C7")
- IMAGEM=`echo "9"`
+"--imagem9=C7")
+IMAGEM="9"
;;
- "--imagem10=C7")
- IMAGEM=`echo "10"`
+"--imagem10=C7")
+IMAGEM="10"
+;;
+"--imagem11=C7")
+IMAGEM="11"
+;;
+"--imagem12=C7")
+IMAGEM="12"
+;;
+"--imagem"*=C7)
+echo "Tema de imagens não encontrado." && exit 1
;;
esac
-##Escolher entre modo Google ou INPE
-if [ $GOOGLE = "0" ] ; then
- source $DIRNAME/brweather/bin/inpe $*
else
- source $DIRNAME/brweather/bin/google $*
+case $1 in
+##CN
+"--imagem1=CN")
+IMAGEM="1"
+;;
+"--imagem2=CN")
+IMAGEM="2"
+;;
+"--imagem3=CN")
+IMAGEM="3"
+;;
+"--imagem4=CN")
+IMAGEM="4"
+;;
+"--imagem5=CN")
+IMAGEM="5"
+;;
+"--imagem6=CN")
+IMAGEM="6"
+;;
+"--imagem7=CN")
+IMAGEM="7"
+;;
+"--imagem"*=CN)
+echo "Tema de imagens não encontrado." && exit 1
+;;
+##C1
+"--imagem1=C1")
+IMAGEM="1"
+;;
+"--imagem2=C1")
+IMAGEM="2"
+;;
+"--imagem3=C1")
+IMAGEM="3"
+;;
+"--imagem4=C1")
+IMAGEM="4"
+;;
+"--imagem5=C1")
+IMAGEM="5"
+;;
+"--imagem6=C1")
+IMAGEM="6"
+;;
+"--imagem7=C1")
+IMAGEM="7"
+;;
+"--imagem"*=C1)
+echo "Tema de imagens não encontrado." && exit 1
+;;
+##C2
+"--imagem1=C2")
+IMAGEM="1"
+;;
+"--imagem2=C2")
+IMAGEM="2"
+;;
+"--imagem3=C2")
+IMAGEM="3"
+;;
+"--imagem4=C2")
+IMAGEM="4"
+;;
+"--imagem5=C2")
+IMAGEM="5"
+;;
+"--imagem6=C2")
+IMAGEM="6"
+;;
+"--imagem7=C2")
+IMAGEM="7"
+;;
+"--imagem"*=C2)
+echo "Tema de imagens não encontrado." && exit 1
+;;
+##C3
+"--imagem1=C3")
+IMAGEM="1"
+;;
+"--imagem2=C3")
+IMAGEM="2"
+;;
+"--imagem3=C3")
+IMAGEM="3"
+;;
+"--imagem4=C3")
+IMAGEM="4"
+;;
+"--imagem5=C3")
+IMAGEM="5"
+;;
+"--imagem6=C3")
+IMAGEM="6"
+;;
+"--imagem7=C3")
+IMAGEM="7"
+;;
+"--imagem"*=C3)
+echo "Tema de imagens não encontrado." && exit 1
+;;
+##C4
+"--imagem1=C4")
+IMAGEM="1"
+;;
+"--imagem2=C4")
+IMAGEM="2"
+;;
+"--imagem3=C4")
+IMAGEM="3"
+;;
+"--imagem4=C4")
+IMAGEM="4"
+;;
+"--imagem5=C4")
+IMAGEM="5"
+;;
+"--imagem6=C4")
+IMAGEM="6"
+;;
+"--imagem7=C4")
+IMAGEM="7"
+;;
+"--imagem"*=C4)
+echo "Tema de imagens não encontrado." && exit 1
+;;
+##C5
+"--imagem1=C5")
+IMAGEM="1"
+;;
+"--imagem2=C5")
+IMAGEM="2"
+;;
+"--imagem3=C5")
+IMAGEM="3"
+;;
+"--imagem4=C5")
+IMAGEM="4"
+;;
+"--imagem5=C5")
+IMAGEM="5"
+;;
+"--imagem6=C5")
+IMAGEM="6"
+;;
+"--imagem7=C5")
+IMAGEM="7"
+;;
+"--imagem"*=C5)
+echo "Tema de imagens não encontrado." && exit 1
+;;
+##C6
+"--imagem1=C6")
+IMAGEM="1"
+;;
+"--imagem2=C6")
+IMAGEM="2"
+;;
+"--imagem3=C6")
+IMAGEM="3"
+;;
+"--imagem4=C6")
+IMAGEM="4"
+;;
+"--imagem5=C6")
+IMAGEM="5"
+;;
+"--imagem6=C6")
+IMAGEM="6"
+;;
+"--imagem7=C6")
+IMAGEM="7"
+;;
+"--imagem"*=C6)
+echo "Tema de imagens não encontrado." && exit 1
+;;
+##C7
+"--imagem1=C7")
+IMAGEM="1"
+;;
+"--imagem2=C7")
+IMAGEM="2"
+;;
+"--imagem3=C7")
+IMAGEM="3"
+;;
+"--imagem4=C7")
+IMAGEM="4"
+;;
+"--imagem5=C7")
+IMAGEM="5"
+;;
+"--imagem6=C7")
+IMAGEM="6"
+;;
+"--imagem7=C7")
+IMAGEM="7"
+;;
+"--imagem"*=C7)
+echo "Tema de imagens não encontrado." && exit 1
+;;
+esac
+fi
+
+
+##Escolher entre modo Open ou INPE
+if [ $OPEN = "0" ] ; then
+ case $1 in
+ "--imagem"*=CN) source /opt/brweather/bin/inpe-4 $*
+ ;;
+ "--imagem"*=C1) source /opt/brweather/bin/inpe-4 $*
+ ;;
+ "--imagem"*=C2) source /opt/brweather/bin/inpe-5 $*
+ ;;
+ "--imagem"*=C3) source /opt/brweather/bin/inpe-5 $*
+ ;;
+ "--imagem"*=C4) source /opt/brweather/bin/inpe-5 $*
+ ;;
+ "--imagem"*=C5) source /opt/brweather/bin/inpe-6 $*
+ ;;
+ "--imagem"*=C6) source /opt/brweather/bin/inpe-6 $*
+ ;;
+ "--imagem"*=C7) source /opt/brweather/bin/inpe-6 $*
+ ;;
+ "--option=city") source /opt/brweather/bin/inpe-1 $*
+ ;;
+ "--option=date") source /opt/brweather/bin/inpe-1 $*
+ ;;
+ "--option=Day"*) source /opt/brweather/bin/inpe-1 $*
+ ;;
+ "--option=LU"*) source /opt/brweather/bin/inpe-1 $*
+ ;;
+ "--option=CN"*) source /opt/brweather/bin/inpe-4 $*
+ ;;
+ "--option=TN") source /opt/brweather/bin/inpe-1 $*
+ ;;
+ "--option=STE") source /opt/brweather/bin/inpe-1 $*
+ ;;
+ "--option=umid") source /opt/brweather/bin/inpe-1 $*
+ ;;
+ "--option=umid1") source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=umid2") source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=umid3") source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=umid4") source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=umid5") source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=umid6") source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=umid7") source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=PA") source /opt/brweather/bin/inpe-1 $*
+ ;;
+ "--option=wind"*) source /opt/brweather/bin/inpe-1 $*
+ ;;
+ "--option=UV"*) source /opt/brweather/bin/inpe-3 $*
+ ;;
+ "--option=SOL"*) source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=LT"*) source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=HT"*) source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=C1"*) source /opt/brweather/bin/inpe-4 $*
+ ;;
+ "--option=PC"*) source /opt/brweather/bin/inpe-2 $*
+ ;;
+ "--option=C2"*) source /opt/brweather/bin/inpe-5 $*
+ ;;
+ "--option=C3"*) source /opt/brweather/bin/inpe-5 $*
+ ;;
+ "--option=C4"*) source /opt/brweather/bin/inpe-5 $*
+ ;;
+ "--option=C5"*) source /opt/brweather/bin/inpe-6 $*
+ ;;
+ "--option=C6"*) source /opt/brweather/bin/inpe-6 $*
+ ;;
+ "--option=C7"*) source /opt/brweather/bin/inpe-6 $*
+ ;;
+ "–option"*) echo "Opção inválida.
+O correto é --option (com dois traços)."
+ ;;
+ "--imagem"* ) echo "Opção inválida.
+Experimente --help para mais informações."
+ ;;
+ "–imagem"*) echo "Opção inválida.
+O correto é --imagem (com dois traços)."
+ ;;
+ *) echo "Opção inválida.
+Experimente --help para mais informações."
+ ;;
+ esac
+
+else
+
+ case $1 in
+ "--imagem"*=CN) source /opt/brweather/bin/open-3 $*
+ ;;
+ "--imagem"*=C1) source /opt/brweather/bin/open-3 $*
+ ;;
+ "--imagem"*=C2) source /opt/brweather/bin/open-4 $*
+ ;;
+ "--imagem"*=C3) source /opt/brweather/bin/open-4 $*
+ ;;
+ "--imagem"*=C4) source /opt/brweather/bin/open-4 $*
+ ;;
+ "--imagem"*=C5) source /opt/brweather/bin/open-5 $*
+ ;;
+ "--imagem"*=C6) source /opt/brweather/bin/open-5 $*
+ ;;
+ "--imagem"*=C7) source /opt/brweather/bin/open-5 $*
+ ;;
+ "--option=city") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=date") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=Day"*"T") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=Day0") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=Day1") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=Day2") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=Day3") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=Day4") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=Day5") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=Day6") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=Day7") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=LU"*) source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=CN"*) source /opt/brweather/bin/open-3 $*
+ ;;
+ "--option=TN") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=CLD") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=CLD1") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=CLD2") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=CLD3") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=CLD4") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=CLD5") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=CLD6") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=CLD7") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=umid") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=umid1") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=umid2") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=umid3") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=umid4") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=umid5") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=umid6") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=umid7") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=PA") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=PA1") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=PA2") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=PA3") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=PA4") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=PA5") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=PA6") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=PA7") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=wind") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=winds") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=windd") source /opt/brweather/bin/open-1 --option=wind
+ ;;
+ "--option=wind1") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=wind2") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=wind3") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=wind4") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=wind5") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=wind6") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=wind7") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=LT1") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=LT2") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=LT3") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=LT4") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=LT5") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=LT6") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=LT7") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=HT1") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=HT2") source /opt/brweather/bin/open-1 $*
+ ;;
+ "--option=HT3") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=HT4") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=HT5") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=HT6") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=HT7") source /opt/brweather/bin/open-2 $*
+ ;;
+ "--option=C1"*) source /opt/brweather/bin/open-3 $*
+ ;;
+ "--option=C2"*) source /opt/brweather/bin/open-4 $*
+ ;;
+ "--option=C3"*) source /opt/brweather/bin/open-4 $*
+ ;;
+ "--option=C4"*) source /opt/brweather/bin/open-4 $*
+ ;;
+ "--option=C5"*) source /opt/brweather/bin/open-5 $*
+ ;;
+ "--option=C6"*) source /opt/brweather/bin/open-5 $*
+ ;;
+ "--option=C7"*) source /opt/brweather/bin/open-5 $*
+ ;;
+ "–option"*) echo "Opção inválida.
+O correto é --option (com dois traços)."
+ ;;
+ "--imagem"* ) echo "Opção inválida.
+Experimente --help para mais informações."
+ ;;
+ "–imagem"*) echo "Opção inválida.
+O correto é --imagem (com dois traços)."
+ ;;
+ *) echo "Opção inválida.
+Experimente --help para mais informações."
+ ;;
+ esac
+
fi
##Exterminador de logs ;)