Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Bhaviktutorials
GitHub Repository: Bhaviktutorials/shark
Path: blob/master/setup
321 views
#!/bin/bash
clear
cd $HOME 
#########
# COLORS
#########

#colors
#colors
white="\033[1;37m"                                          ##
grey="\033[0;37m"                                           ##
purple="\033[1;35m"                                         ##
red="\033[1;31m"                                            ##
green="\033[1;32m"                                          ##
yellow="\033[1;33m"                                         ##
purple="\033[0;35m"                                         ##
cyan="\033[0;36m"                                           ##
cyan1="\033[1;36m"                                          ##
cafe="\033[0;33m"                                           ##
fiuscha="\033[0;35m"                                        ##
blue="\033[1;34m"                                           ##
l_red="\033[1;37;41m"                                       ##
nc="\033[0m"                                                ## 

arch=`uname -m`
ArNam=$(dpkg --print-architecture)
#spinner
spinner() {
        pid=$!
        spin='\|/-'
        i=0
        tput civis
        while kill -0 $pid 2>/dev/null
	do
                i=$(( (i+1) %4 ))
                printf "\r${cyan1}[${spin:$i:1}]${nc} ${cyan1} ${launch}"
                sleep .1
	done
        clear
        printf "\r\n${green}[✔]${nc} ${green} ${splashdown}";echo
        tput cnorm
}
function os () {
	cat /etc/os-release > /dev/null 2>&1
	if [ "$?" -eq "0" ]; then
		OS=DEBIAN 
		BIN="/usr/bin"
		main="/usr/share/shark"
                sudo apt install iputils-ping -y &>/dev/null
		sudo apt install p7zip-full -y &>/dev/null
	else
		OS=TERMUX
		BIN="${PREFIX}/bin"
		main="${PREFIX}/share/shark"
                pkg install ncurses-utils -y &>/dev/null
                pkg install p7zip -y &>/dev/null
	fi
}

function git_clone() {
	launch="cloning shark";splashdown="shark cloned";echo
	[ -d "${main}" ] && rm -rf ${main} > /dev/null 2>&1
	(git clone https://github.com/E343IO/shark --quiet ${main} --depth=1) & spinner
}


function dependencies() {
killall -q dpkg apt pkg &>/dev/null
clear
sleep 1
     launch="installing lib";splashdown="installed lib"; echo 
	for i in apache2 php jq curl git unzip dialog proot sox ffmpeg; do					
    		if [ ${OS} != "DEBIAN" ]; then	
    			(pkg update -y &> /dev/null && pkg install ${i} -y &> /dev/null && pkg install proot resolv-conf &> /dev/null)& spinner
		else
			(sudo apt-get install ${i} -y &> /dev/null && sudo dnf -y install &> /dev/null)& spinner
		fi
	done
}

function setup_cloudflare() {
	if [ ! -f ${BIN}/cloudflared ]; then
             if [[ ("$arch" == *'arm'*) || ("$arch" == *'Android'*) ]]; then
		     cloudd="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm"
             elif [[ "$arch" == *'aarch64'* ]]; then
                     cloudd="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64"
             elif [[ "$arch" == *'x86_64'* ]]; then
                    if [[ "$ArNam" == *'amd64'* ]]; then
                                cloudd="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64"
                    else
                                cloudd="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64"
                    fi
             else
                                cloudd="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-386"
             fi
	          launch="Installing server-1, size@25mb";splashdown="installed.";echo
	          (wget --quiet ${cloudd} -O cloudflared)& spinner
	          chmod +x cloudflared && mv cloudflared $BIN
        else 
	    echo ""
	fi
}

function setup_ngrok() {
	if [ ! -f  "${BIN}/ngrok" ]; then
		if [[ ("$arch" == *'arm'*) || ("$arch" == *'Android'*) ]]; then
			ngrok_url="https://github.com/E343IO/stuff/raw/main/ngrok-2in1.zip"
		elif [[ "$arch" == *'aarch64'* ]]; then
                         if [[ "$ArNam" == *'amd64'* ]]; then
                              ngrok_url="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip"
                        else
                              ngrok_url="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm64.zip"
                         fi
		elif [[ "$arch" == *'x86_64'* ]]; then
		        if [[ "$ArNam" == *'amd64'* ]]; then 
                         ngrok_url="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip"
                        else
                         ngrok_url="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm64.zip"
                        fi
                else
                        ngrok_url="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-386.zip"
	        fi
		launch="installing server-2, size@4mb";splashdown="Installed.";echo
		(wget --quiet $ngrok_url -O ngrok.zip)& spinner
		unzip -q ngrok.zip && rm -rf ngrok.zip && chmod +x ngrok && mv ngrok $BIN
        else
              echo ""
        fi
}
function final_touchup() {
	for i in shark; do
		chmod +x ${main}/${i}
		mv ${main}/${i} ${BIN}
		launch="setting up files"; splashdown="done";echo
		(cd ${main} && 7z x file &>/dev/null)& spinner

	done
if [ ${OS} != "DEBIAN" ]; then
	clear
	dialog --title "© SHARK 2022-2023" --inputbox  "*Ngrok Authtoken verification \nEnter your authtoken without './' :" 0 0 2> authtk
        mv authtk ${BIN}
        chmod +x ${BIN}/authtk
        sleep 2
        clear
        sleep 2
        authtk &>/dev/null
        export user=$HOME
        mv ${BIN}/authtk ${BIN}/authtoken
        chmod +x ${BIN}/authtoken                                                                        
        #printf ${yellow}"Full exiting....\nJust Reopen your termux after exit. \n"
        sleep 1       
        printf "\n${green}>>${white} simply run : shark \n\n ${nc}"
else 
        clear
        dialog --title "© SHARK 2022-2023" --inputbox  "*Ngrok Authtoken verification \nEnter your authtoken without './' :" 0 0 2> authtk
        mv authtk ${BIN}
        chmod +x ${BIN}/authtk
        sleep 2
        clear
        authtk &>/dev/null
        printf "\n${green}>>${white} simply run : shark \n\n ${nc}"
fi
}
printf "${yellow}Please Wait.\n\n[!] Don't terminate this task.\n"
os
clear
printf "${green}Setting up libs...\n"
sleep 2
clear
dependencies
git_clone
setup_cloudflare
setup_ngrok
final_touchup

#########################################
#       DON'T TRY TO COPY 😂😂          #
#   JUST LEARNING KEEP SUPPORTING       #
#             THANKYOU                  #
#        M r. D e r e K   (Contributor) #
#     B h a v i k   O z a (Publisher)   #  
#    A s h i s h  S i n g h (Author)    #
#########################################