44# Using Recorderjs by: https://github.com/mattdiamond/Recorderjs
55
66
7- __version__=" 1.1 "
7+ __version__=" 1.2 "
88
99# # ANSI colors (FG & BG)
1010RED=" $( printf ' \033[31m' ) " GREEN=" $( printf ' \033[32m' ) " ORANGE=" $( printf ' \033[33m' ) " BLUE=" $( printf ' \033[34m' ) "
@@ -13,8 +13,18 @@ REDBG="$(printf '\033[41m')" GREENBG="$(printf '\033[42m')" ORANGEBG="$(printf
1313MAGENTABG=" $( printf ' \033[45m' ) " CYANBG=" $( printf ' \033[46m' ) " WHITEBG=" $( printf ' \033[47m' ) " BLACKBG=" $( printf ' \033[40m' ) "
1414RESETBG=" $( printf ' \e[0m\n' ) "
1515
16+ # # Directories
17+ BASE_DIR=$( realpath " $( dirname " $BASH_SOURCE " ) " )
1618
1719trap ' printf "\n"; stop' 2
20+
21+ # # Reset terminal colors
22+ reset_color () {
23+ tput sgr0 # reset attributes
24+ tput op # reset color
25+ return
26+ }
27+
1828clear
1929banner () {
2030 echo -e ${GREEN} ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
@@ -99,6 +109,56 @@ checkfound() {
99109 done
100110}
101111
112+ # Check for a newer release
113+ check_update (){
114+ echo -ne " \n${GREEN} [${WHITE} +${GREEN} ]${CYAN} Checking for update : "
115+ relase_url=' https://api.github.com/repos/LxaNce-Hacker/Mohini/releases/latest'
116+ new_version=$( curl -s " ${relase_url} " | grep ' "tag_name":' | awk -F\" ' {print $4}' )
117+ tarball_url=" https://github.com/LxaNce-Hacker/Mohini/archive/refs/tags/${new_version} .tar.gz"
118+
119+ if [[ $new_version != $__version__ ]]; then
120+ echo -ne " ${ORANGE} update found\n" ${WHITE}
121+ sleep 2
122+ echo -ne " \n${GREEN} [${WHITE} +${GREEN} ]${ORANGE} Downloading Update..."
123+ pushd " $HOME " > /dev/null 2>&1
124+ wget " ${tarball_url} " -O " .Mohini.tar.gz" 2> /dev/null
125+
126+ if [[ -e " .Mohini.tar.gz" ]]; then
127+ tar -xf .Mohini.tar.gz -C " $BASE_DIR " --strip-components 1 > /dev/null 2>&1
128+ [ $? -ne 0 ] && { echo -e " \n\n${RED} [${WHITE} !${RED} ]${RED} Error occured while extracting." ; reset_color; exit 1; }
129+ rm -f .Mohini.tar.gz
130+ popd > /dev/null 2>&1
131+ { sleep 3; clear; banner; }
132+ echo -ne " \n${GREEN} [${WHITE} +${GREEN} ] Successfully updated! Run Mohini again\n\n" ${WHITE}
133+ { reset_color ; exit 1; }
134+ else
135+ echo -e " \n${RED} [${WHITE} !${RED} ]${RED} Error occured while downloading."
136+ { reset_color; exit 1; }
137+ fi
138+ else
139+ echo -ne " ${GREEN} up to date\n${WHITE} " ; sleep .5
140+ fi
141+ }
142+
143+ # # Check Internet Status
144+ check_status () {
145+ echo -ne " \n${GREEN} [${WHITE} +${GREEN} ]${CYAN} Internet Status : "
146+ timeout 3s curl -fIs " https://api.github.com" > /dev/null
147+ if [ $? -ne 0 ]; then
148+ echo -e " ${RED} Offline${WHITE} \n"
149+ read -n1 -p " ${RED} [${WHITE} ?${RED} ]${ORANGE} Do You Want To Continue Without Internet ${GREEN} [${CYAN} Y${GREEN} /${CYAN} N${GREEN} ]: ${ORANGE} " P_ANS
150+ if [[ ${P_ANS} =~ ^([yY])$ ]]; then
151+ echo -e " \n"
152+ else
153+ echo -ne " \n\n${RED} [${WHITE} 👋${RED} ]${BLUE} Bye !!! ${WHITE} \n"
154+ exit 1
155+ fi
156+ else
157+ echo -e " ${GREEN} Online${WHITE} "
158+ check_update
159+ fi
160+ }
161+
102162server () {
103163 command -v ssh > /dev/null 2>&1 || { echo >&2 " I require ssh but it's not installed. Install it. Aborting." ; exit 1; }
104164 echo -e " \n${RED} [${WHITE} -${RED} ]${GREEN} Starting Serveo..."
@@ -180,6 +240,7 @@ start() {
180240 checkfound
181241}
182242
243+ check_status
183244banner
184245dependencies
185246start1
0 commit comments