یه اسکریپت کوچک برای زنده نگه داشتن کانکشن اینترنت
با سلام
دانلود شبانه به خصوص برای کسایی که اکانت پرسرعت دارند یه اعتیاد بدون درمانه.
مسلما اسکریپتهای مدیریتی در سرورهای ISP وجود دارند که سیستمهایی رو که کاربر پشتشون نیست تشخیص بدند و سیاستهای اون ISP رو اعمال کنن.
در مورد دایال آپ که معمولا کاربر دیسکانکت میشه و خلاص(در کل 24 ساعت).در اینترنت پر سرعت هم اگر دیسکانکت نشه یا کانکشن عملا غیر فعال میشه یا
لااقل کاربر کاندید محدودیت پهنای باند میشه و با کاربرای مثل خودش share میشه.چه باید کرد؟
تو ویندوز که نرم افزار connectionkeeper راه حل خوبیه.تو لینوکس هم مکانیزم درونی وجود داره که کانکشن رو حفظ کنه ولی یه سیستم حداقلیه که پاسخگو نیست.
پس من در هنگام یادگیری bash لینوکس دست بکار شدم و یه اسکریپ به نام keepmyalive.cron نوشتم تا این نیاز رو برطرف کنم.این اسکریپت پهنای باندی رو مصرف نمیکنه و
در طول اجرا بار پردازشی روی سیستم نداره.(صرفا ping میکنه)
تنها پیش نیاز این اسکریپت پکیج network manager هست که به صورت پیشفرض روی لینوکسهای با پیکربندی Desktop نصبه.البته باید واسط خط فرمانی اون هم نصب باشه.در هر حال اسکریپت خودش چک میکنه
و در صورت نبود پیشنیازها اونو اعلام میکنه.
اون رو با همین نام keepmyalive.cron در مسیری که ترمینال بتونه اون رو پیدا کنه قراربدید و با دستور زیر اون رو به فایل اجرایی تبدیل کنید :
کد:
$ chmod +x keepmyalive.cron
سپس اون رو فقط به یکی از ۲ صورت زیر فراخوانی کنید :
کد:
$ keepmyalive.cron skip
$ keepmyalive.cron skipdebug
توجه کنید که حتما آرگومان skip مثل بالا وارد بشه وگرنه سیستم رو خاموش میکنه.علت پسوند cron در نام فایل اینه که من صرفا از اون به عنوان CronJob استفاده میکنم.اگر روی سیستم شما درست عمل کرد به شما هم توصیه میکنم همین کار رو بکنید.در صورت وجود باگ خاص هیچ ضرری متوجه سیستم عامل نیست. در هر صورت اونو با مجوز کاربر معمولی اجرا کنید.
کد:
#!/bin/bash
function func_traping()
{
echo -e "`date +"%A %d %B %Y %R"`\tscript stoped" | tee -a "$logfile" 2> /dev/null
echo | tee -a "$logfile" 2> /dev/null
return
}
trap func_traping EXIT
main_sleep_time=110
updated=0
current_logged_user="`who | grep -v root | head -n 1 | cut -d " " -f1`" #${MAIL##*/}
temp=`cat /etc/passwd 2>/dev/null | grep "$current_logged_user" | head -n 1 2>/dev/null | cut -d ':' -f 6 2>/dev/null | tr -d '\n'`
[ ! -d "$temp" -o ! -w "$temp" ] && { temp=~ ; current_logged_user="$USER"; }
if [ -d "${temp}/Desktop" ];then
work_folder="${temp}/Desktop"
elif [ -d "${temp}/desktop" ];then
work_folder="${temp}/desktop"
else
work_folder="${temp}"
fi
#mydir="$(cd `dirname $0` && pwd)"
#[ ! -d "$mydir" -o ! -w "$mydir" ] && mydir="$work_folder"
SCRIPT_NAME=$(basename $0)
logfile="${work_folder}/${SCRIPT_NAME%%.*}.log"
touch "$logfile" &>/dev/null
if [ ! -w "$logfile" ];then
logfile="${work_folder}/${SCRIPT_NAME%%.*}_$$.log"
touch "$logfile" &>/dev/null
echo | tee -a "$logfile" 2>/dev/null
echo -e "`date +"%A %d %B %Y %R"`\tscript started" | tee -a "$logfile" 2> /dev/null
echo -e "`date +"%A %d %B %Y %R"`\tError : ${work_folder}/${SCRIPT_NAME%%.*}.log No Writable !!!" | tee -a "$logfile" 2> /dev/null
echo -e "`date +"%A %d %B %Y %R"`\tchanging log file to '${logfile}' " | tee -a "$logfile" 2> /dev/null
else
echo | tee -a "$logfile" 2> /dev/null
echo -e "`date +"%A %d %B %Y %R"`\tscript started" | tee -a "$logfile" 2> /dev/null
fi
chown $current_logged_user "$logfile" &> /dev/null
debug=false
checkaria2=true
case "$1" in
"")
:;;
"skip")
checkaria2=false;;
"debug")
debug=true;;
"debug_skip" |"debugskip" | "skip_debug" | "skipdebug")
checkaria2=false
debug=true;;
*)
echo -e "`date +"%A %d %B %Y %R"`\tERROR. Unknown arguments $@" | tee -a "$logfile" 2> /dev/null
echo -e "`date +"%A %d %B %Y %R"`\t\tMust be 'skip' 'debug' 'skipdebug' or leave empty" | tee -a "$logfile" 2> /dev/null
exit 1;;
esac
let bash_ver=${BASH_VERSINFO[0]} &>/dev/null
if [ "${bash_ver}" -lt 4 ];then
echo -e "`date +"%A %d %B %Y %R"`\tFATAL ERROR. Bash Shell Is Old Version And Not Compatible" | tee -a "$logfile" 2> /dev/null
exit 1
fi
if [[ -z "which nmcli 2> /dev/null" ]];then
echo -e "`date +"%A %d %B %Y %R"`\tFATAL ERROR. Network manager Command Line Interface Not Found In `uname -n`" | tee -a "$logfile" 2> /dev/null
exit 4
fi
#my_real_connection_type=pppoe #s کانکشن adsl
my_real_connection_type=`nmcli -t -f TYPE con 2>/dev/null | grep -Ei "ppp[a-z]*" | head -n 1 | tr -d '\n'`
if [ -z "${my_real_connection_type}" ];then
my_real_connection_type=`nmcli -t -f TYPE con 2>/dev/null | grep -Ei "ppp*" | head -n 1 | tr -d '\n'`
fi
my_con_str=`nmcli -t -f TYPE dev | head -n 1 | tr -d '\n'`
if [ -z "$my_con_str" ];then
echo -e "`date +"%A %d %B %Y %R"`\tFATAL ERROR. variable 'my_con_str' not set correctly" | tee -a "$logfile" 2> /dev/null
exit 3
fi
con_uuid=`nmcli -t -f TYPE,UUID con | grep "${my_real_connection_type:-${my_con_str}}" | head -n 1 | cut -d ':' -f 2 | tr -d '\n'`
if [ -z "$con_uuid" ];then
echo -e "`date +"%A %d %B %Y %R"`\tFATAL ERROR. variable 'con_uuid' not set correctly" | tee -a "$logfile" 2> /dev/null
exit 3
fi
if [[ "$debug" == "true" ]];then
temp="`date +"%A %d %B %Y %R"`"
echo -e "${temp}\tmain_sleep_time = '${main_sleep_time}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\tmy_con_str = '${my_con_str}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\tcon_uuid = '${con_uuid}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\tmy_real_connection_type = '${my_real_connection_type}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\tupdated = '${updated}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\tcurrent_logged_user = '${current_logged_user}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\twork_folder = '${work_folder}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\tSCRIPT_NAME = '${SCRIPT_NAME}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\tlogfile = '${logfile}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\tcheckaria2 = '${checkaria2}'" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\tdebug = '${debug}'" | tee -a "$logfile" 2> /dev/null
fi
declare -a domains
for site in cocolog-nifty.com myfc.ir oracle.com youjizz.com exblog.jp dmm.co.jp webeden.co.uk blogspot.in google.co.kr torrentz.in tinypic.com jahannews.com dyndns.org nic.ir pch.com mediafire.com mashable.com apache.org gnu.org shatel.ir fatakat.com web.de zillow.com media.tumblr.com printfriendly.com niksalehi.com rediff.com photobucket.com is.gd intuit.com twitpic.com google.ca sun.com xtendmedia.com filestube.com purdue.edu home.pl ero-advertising.com google.co.uk mozilla.org rakuten.co.jp hexun.com chronoengine.com stackoverflow.com google.de renren.com kooora.com sina.com.cn google.com.br businessweek.com google.gr ocn.ne.jp ning.com forbes.com webmd.com googleusercontent.com youtu.be majidonline.com etao.com twoo.com google.cz google.nl jamejamonline.ir jdownloader.org peyvandha.ir allegro.pl goo.gl freecsstemplates.org globo.com parsiblog.com telegraph.co.uk extratorrent.com 123rf.com icq.com webhostingtalk.irtagged.com blogspot.ru phpnuke.ir metacafe.com autohome.com.cn 56.com google.ie nypost.com goodgamestudios.com bravotube.net sitemeter.com posterous.com auda.org.au squarespace.com terra.com.br vk.com umn.edu topsy.com google.co.th zol.com.cn hilton.com depositfiles.com techcrunch.com php.net xgo.com.cn independent.co.uk p30vel.ir vistaprint.com gmx.net google.com.hk mercadolivre.com.br google.com.ph seattletimes.com soundcloud.com fda.gov google.dz google.se ku6.com tabnak.ir addtoany.com cmu.edu amazon.de fardanews.com lycos.com linkedin.com wix.com dot.gov domainmarket.com secureserver.net dianping.com google.com.mx google.it hostgator.com hulu.com etsy.com npr.org rapidbaz.com blogger.com iran20.com jimdo.com latimes.com github.com detik.com chron.com suntimes.com reddit.com bandcamp.com cj.com mixx.com virustotal.com reference.com google.cl squidoo.com blogs.com google.com.pk weebly.com hhs.gov geocities.com cbslocal.com automattic.com google.com.ng e-recht24.de freedownload.ir -----------.com google.at umd.edu insanejournal.com stanford.edu ign.com torrentz.eu domaintools.com espncricinfo.com hubpages.com drupal.org tudou.com blogspot.jp alef.ir washingtonpost.com webs.com it168.com bp.blogspot.com behance.net goo.ne.jp zippyshare.com deliciousdays.com dion.ne.jp theatlantic.com pengyou.com dagondesign.com search-results.com asriran.com webstarts.com netvibes.com putlocker.com google.com.ua sweetim.com geocities.jp parsfa.com liveinternet.ru cnzz.com aliexpress.comfeedburner.com bankmellat.ir privacy.gov.au 100ye.com.cn imageshack.us google.es elpais.com webnode.fr softonic.com mixi.jp wigetmedia.com wordpress.com google.cn shinystat.com jalbum.net pandora.com baiducontent.com openoffice.org elegantthemes.com google.com.pe mgid.com over-blog.com yahoo.com ycombinator.com pclady.com.cn biglobe.ne.jp naukri.com google.co.ve pcauto.com.cn moonfruit.com akamaihd.net weather.com avito.ru xcar.com.cn businessinsider.com payamsara.com columbia.edu google.com.vn ir-tci.org china.com popads.net soup.io taringa.net wired.com cloob.com letv.com rambler.ru iqiyi.com hardsextube.com zimbio.com vcp.ir aweber.com cafepress.com isna.ir in.com youporn.com cdbaby.com csdn.net wunderground.com godaddy.com go.com usa.gov google.ro clickbank.net yourlust.com odesk.com state.tx.us networkadvertising.org dailymotion.com ---------.com utexas.edu ucsd.edu msu.edu cloudflare.com phoca.cz yale.edu cba.pl 2ch.net mailchimp.com persianv.com persianblog.ir kat.ph zedo.com ---------- hurriyet.com.tr clicksor.com speedtest.net youm7.com espn.go.com mobilestan.net blogspot.com.br kaspersky.com twitter.com freewebs.com uploaded.net people.com.cn pconline.com.cn blogspot.co.uk istgah.com fbcdn.net usnews.com salesforce.com constantcontact.com doubleclick.net libero.it 51.la tripod.com 12306.cn linkbucks.com army.mil sourceforge.net spiegel.de google.com.au iran-eng.com tmall.com ameblo.jp google.com.tr tinyurl.com google.be netlog.com kaskus.co.id google.co.in rozblog.com ustream.tv list-manage.com nuvid.com atwiki.jp doubleclick.com rapidshare.com chinaz.com zoomit.ir ehow.com java.com t.co nasa.gov yandex.ua google.co.za google.co.jp leboncoin.fr 360.cn seznam.cz istockphoto.com webgozar.com discuz.net clamav.net sedo.com aboutads.info google.fi wsj.com xnxx.com abcnews.go.com csmonitor.com claro-search.com eforosh.com fc2.com wikispaces.com 4shared.com travian.ir conduit.com technorati.com clickbank.com alipay.com disqus.com prweb.com bbc.co.uk uol.com.br doorblog.jp miitbeian.gov.cn cnet.com meetup.com surveymonkey.com example.com qunar.com download.com unc.edu netflix.com bild.de skype.com gizmodo.com thetimes.co.uk cargocollective.com typepad.com jigsy.com tripadvisor.com princeton.edu blinkweb.com blogspot.com.es quikr.com ndtv.com flickr.com hao123.com ------------ berkeley.edu blogspot.ca nationalgeographic.com rajanews.com google.com.my google.com.sg joomla.org hotfile.com quantcast.com mo.tl delta-search.com archive.org goodreads.com nytimes.com 100ye.com odnoklassniki.ru real.com yandex.ru alibaba.com parallels.com canalblog.com purevolume.com agahibank.com reverbnation.com adnxs.com howstuffworks.com iran-forum.ir pornhub.com alisoft.com 4dsply.com bannersbroker.com ask.com statcounter.com searchnu.com empowernetwork.com google.ch opensource.org eepurl.com myspace.com i2i.jp livejasmin.com wordreference.com locopoc.com scribd.com vinaora.com google.com.eg gravatar.com intoidc.net seemorgh.com slashdot.org upenn.edu infusionsoft.com movie2k.to foxnews.com furl.net smugmug.com douban.com icbc.com.cn sphinn.com google.com.sa badoo.com timesonline.co.uk ------------- google.com.ar persianstat.com bloomberg.com nwsource.com -------------.com google.com.tw mozilla.com niazerooz.com iminent.com stackexchange.com hatena.ne.jp ------------.com certified-toolbar.com xda-developers.com artisteer.com cisco.com 4399.com xrea.com weibo.com informer.com gazeta.pl gmpg.org taobao.com marketwatch.com wikia.com blogimg.jp tumblr.com ilivid.com indeed.com google.pl usgs.gov blogspot.com bestbuy.com kaixin001.com xing.com tube8.com google.com.bd exoclick.com friendfeed.com sogou.com --------.com ig.com.br blogspot.de creativecommons.org wikimedia.org mail.ru chicagotribune.com infoseek.co.jp maktoob.com xonotic.org siteadvisor.com orange.fr sfgate.com google.ae 1channel.ch washington.edu google.dk xhamster.com getgnash.org adcash.com skyrock.com onet.pl webnode.com tianya.cn 39.net vargas.co.cr adultfriendfinder.com activestate.com snippetfire.com torrentr.eu marriott.com softpedia.com opera.com yelp.com drtuber.com pagesperso-orange.fr repubblica.it mihanblog.com cam4.com google.co.hu google.com 466.ir bet365.com aftabir.com google.com.co groupon.com google.ru last.fm linkwithin.com free.fr wp.pl persiantools.com wordpress.org cpanel.net wp-persian.com shutterfly.com histats.com senate.gov mehrnews.com xvideos.com incredibar.com blackhatworld.com mycalendarbook.com google.co.id craigslist.org google.no narod.ru prnewswire.com dropbox.com vnexpress.net livedoor.biz flavors.me livedoor.com so-net.ne.jp themeforest.net letitbit.net t-online.de google.pt ucla.edu beeg.com google.fr com.com ameba.jp 58.com turbobit.net pixiv.net files.wordpress.com phpbb.com answers.com diigo.com wikipedia.org qq.com pof.com largeporntube.com altavista.com wikihow.com gsmarena.com sakura.ne.jp mit.edu ow.ly time.com ucoz.com varzesh3.com warriorforum.com ted.com articlesbase.com yahoo.co.jp uimserv.net homestead.com angelfire.com ikea.com;
do
domains+=("$site")
done
let COUNTS=${#domains[@]}
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tdomains array declared with '${COUNTS}' sites" | tee -a "$logfile" 2> /dev/null
function HOST_STRING ()
{
let hostline=$[$RANDOM % $COUNTS]
export HOST=${domains[$hostline]}
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tdomains[${hostline}] = '${HOST}' selected" | tee -a "$logfile" 2> /dev/null
return
}
while true;
do
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tMain loop started" | tee -a "$logfile" 2> /dev/null
#s بعد از 12 شب باید اجرا شود
if [[ "${checkaria2}" == "true" ]];then
if [ -z "$(pgrep aria2c)" ] && [ $(date +%H) -gt 1 ];then
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\taria2c Process Not running" | tee -a "$logfile" 2> /dev/null
if [ -n "$(pgrep yum)" ]; then #s yum در حال اجراست
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tyum Process is running" | tee -a "$logfile" 2> /dev/null
updated=1
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tupdated = '${updated}'" | tee -a "$logfile" 2> /dev/null
while [ -n "$(pgrep yum)" ];
do
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\twait 1 minute to yum process stop" | tee -a "$logfile" 2> /dev/null
sleep 60;
done
fi
if [ "$updated" -ne 1 ] && [ $(date +%H) -lt 5 ]; then
#s آپدیت سیستم
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tstarting yum.cron in background and wait for it" | tee -a "$logfile" 2> /dev/null
/usr/local/yum.cron &
wait $!
fi
{ echo -e "`date +"%A %d %B %Y %R"`\tShutting down..." | tee -a "$logfile" 2> /dev/null; } && { /usr/sbin/shutdown -h now; }
exit 0
fi
#s 'if' زیر هرگز اجرا نمی شود
if [ $(date +%H) -ge 8 ];then
nmcli -t con down uuid $con_uuid &> /dev/null
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tclosing connection..." | tee -a "$logfile" 2> /dev/null
nmcli -t nm wwan off &> /dev/null
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tpower off connection..." | tee -a "$logfile" 2> /dev/null
echo -e "`date +"%A %d %B %Y %R"`\tExiting $(basename $0) without power off" | tee -a "$logfile" 2> /dev/null
exit 1
fi
fi
export MyVAR=`nmcli -t -f TYPE,STATE dev`
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tMyVAR = '${MyVAR}'" | tee -a "$logfile" 2> /dev/null
if [[ "$MyVAR" == "${my_con_str}:connected" ]]; then
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tConnection is open" | tee -a "$logfile" 2> /dev/null
#Connection is ok
#conalive=false
let PING_COUNT=0;
#while [[ ! $conalive ]];
while true;
do
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tfunction HOST_STRING called" | tee -a "$logfile" 2> /dev/null
HOST_STRING
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tfunction HOST_STRING returned" | tee -a "$logfile" 2> /dev/null
let PING_COUNT++
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tpinging '${HOST}' PING_COUNT = ${PING_COUNT}" | tee -a "$logfile" 2> /dev/null
ping -c 1 -W 10 $HOST &> /dev/null
if [ $? -eq 0 ]; then
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tConnection is Alive" | tee -a "$logfile" 2> /dev/null
#Connection is alive
#conalive=true
break
fi
if [ $PING_COUNT -eq 4 ];then
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tclosing connection..." | tee -a "$logfile" 2> /dev/null
nmcli -t con down uuid "$con_uuid" &> /dev/null
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tSleeping 2 seconds" | tee -a "$logfile" 2> /dev/null
sleep 2
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\topening connection..." | tee -a "$logfile" 2> /dev/null
nmcli -t con up uuid "$con_uuid" &> /dev/null
if [ $? -ne 0 ];then
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tProblem In opening connection" | tee -a "$logfile" 2> /dev/null
flag=ERROR
break
fi
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tSleeping 2 seconds" | tee -a "$logfile" 2> /dev/null
sleep 2
let PING_COUNT=0;
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tPING_COUNT reset" | tee -a "$logfile" 2> /dev/null
fi
done
[[ "$flag" == "ERROR" ]] && { unset flag &>/dev/null; continue; }
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tSleeping ${main_sleep_time} seconds for another loop'" | tee -a "$logfile" 2> /dev/null
sleep $main_sleep_time
else
let COUNT=0;
#nmcli -t nm wwan off
#sleep 2
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tpower on connection..." | tee -a "$logfile" 2> /dev/null
nmcli -t nm wwan on
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tEnabling connection manager..." | tee -a "$logfile" 2> /dev/null
nmcli nm enable true &> /dev/null #s فعال کردن مدیر شبکه در صورت غیر فعال بودن
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tSleeping 2 seconds" | tee -a "$logfile" 2> /dev/null
sleep 2
while [[ "$MyVAR" != "${my_con_str}:connected" ]];
do
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tlopping for connection to established" | tee -a "$logfile" 2> /dev/null
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\topening connection..." | tee -a "$logfile" 2> /dev/null
nmcli -t con up uuid "$con_uuid" &> /dev/null
let Errorcode=$?
if [ $Errorcode -eq 0 ];then
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tconnection is opened" | tee -a "$logfile" 2> /dev/null
break
elif [ $Errorcode -eq 2 ];then
temp=`date +"%A %d %B %Y %R"`
echo -e "${temp}\tFATAL ERROR. Invalid user input, wrong nmcli invocation" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\t\tcon_uuid=${con_uuid} my_con_str=${my_con_str}" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\t\tPlease edit 'con_uuid' and 'my_con_str' variables.Exiting ..." | tee -a "$logfile" 2> /dev/null
exit 2
fi
export MyVAR=`nmcli -t -f TYPE,STATE dev`
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tMyVAR = '${MyVAR}'" | tee -a "$logfile" 2> /dev/null
let COUNT++
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tRetry counter = '${COUNT}'" | tee -a "$logfile" 2> /dev/null
if [ $COUNT -eq 10 ]; then
if [[ "$MyVAR" == "${my_con_str}:unavailable" ]];then
temp=`date +"%A %d %B %Y %R"`
echo -e "${temp}\tFATAL ERROR. Your internet connection not available, may be Cable Unplugged" | tee -a "$logfile" 2> /dev/null
echo -e "${temp}\t\tPlease Check Your Network Device.Exiting ..." | tee -a "$logfile" 2> /dev/null
exit 1
fi
let COUNT=0
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tReseting Retry counter" | tee -a "$logfile" 2> /dev/null
[[ "$debug" == "true" ]] && echo -e "`date +"%A %d %B %Y %R"`\tSleeping ${main_sleep_time} seconds for another Sub-loop'" | tee -a "$logfile" 2> /dev/null
sleep $main_sleep_time
fi
done
fi
done