فهرست منبع

Bash check

Bash check improved
Cristhian Martínez Ochoa 3 سال پیش
والد
کامیت
c5679ac472
3فایلهای تغییر یافته به همراه20 افزوده شده و 26 حذف شده
  1. 6 8
      lib/general
  2. 8 10
      lib/verify
  3. 6 8
      weby

+ 6 - 8
lib/general

@@ -24,14 +24,12 @@ readonly dim=`tput dim`
 
 
 # Check for BASH Shell
-if [[ -f /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
-	# This is a very "shity" method, but checking if file exists is very reliable
-	# If modified: this same script is in installer, general lib and verify
-	shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline)
-elif [[ -f /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
-	# This second check is useful when logedin as root
-	shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline)
-fi
+# This is a very "shity" method, but checking if file exists is very reliable
+# If modified: this same script is in installer, general lib and verify
+# The second check is useful when logedin as root
+shell_pid=$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')
+[[ -z $shell_pid || ! -f /proc/$shell_pid/cmdline ]] && shell_pid=$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')
+[[ -n $shell_pid && -f /proc/$shell_pid/cmdline ]] && shell_current=$(tr -d '\000' < /proc/$shell_pid/cmdline)
 if [[ -n $shell_current && $shell_current != *"bash"* ]]; then
 	echo "${red}BASH Shell is required! ${dim}(${shell_current}) ${end}"
 	exit 1

+ 8 - 10
lib/verify

@@ -751,20 +751,18 @@ fi
 
 if [[ -z $critical_mode ]]; then
 	# Check for BASH Shell
-	if [[ -f /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
-		# This is a very "shity" method, but checking if file exists is very reliable
-		# If modified: this same script is in installer, general lib and verify
-		local ver_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline)
-	elif [[ -f /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
-		# This second check is useful when logedin as root
-		local ver_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline)
-	else
-		echo "${blu}${dim}- [INFO] Shell check fails to retrieve data! ${end}${red}"
-	fi
+	# This is a very "shity" method, but checking if file exists is very reliable
+	# If modified: this same script is in installer, general lib and verify
+	# The second check is useful when logedin as root
+	ver_shell_pid=$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')
+	[[ -z $ver_shell_pid || ! -f /proc/$ver_shell_pid/cmdline ]] && ver_shell_pid=$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')
+	[[ -n $ver_shell_pid && -f /proc/$ver_shell_pid/cmdline ]] && ver_shell_current=$(tr -d '\000' < /proc/$ver_shell_pid/cmdline)
 	if [[ -n $ver_shell_current && $ver_shell_current != *"bash"* ]]; then
 		# Should never be displayed because is blocked in general lib, but who knows!
 		echo "${dim}- [WARNING] BASH Shell is required! ${dim}(${ver_shell_current}) ${end}${red}"
 		local ver_six_war="1"
+	elif [[ -z $ver_shell_current ]]; then
+		echo "${blu}${dim}- [INFO] Shell check fails to retrieve data! ${end}${red}"
 	fi
 	
 	# Check for updates

+ 6 - 8
weby

@@ -14,14 +14,12 @@ if ! [[ $distr == "Ubuntu" && $osver =~ ^(bionic|focal)$ ]]; then
 fi
 
 # Check for BASH Shell
-if [[ -f /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
-	# This is a very "shity" method, but checking if file exists is very reliable
-	# If modified: this same script is in installer, general lib and verify
-	ins_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')/cmdline)
-elif [[ -f /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline ]]; then
-	# This second check is useful when logedin as root
-	ins_shell_current=$(tr -d '\000' < /proc/$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')/cmdline)
-fi
+# This is a very "shity" method, but checking if file exists is very reliable
+# If modified: this same script is in installer, general lib and verify
+# The second check is useful when logedin as root
+ins_shell_pid=$(ps -aux | grep -E "${SUDO_USER:-${USER}}.*pts/0[ ]+S[s]?[ ]+" | grep -v "grep" | tail -n 1 | awk '{print $2}')
+[[ -z $ins_shell_pid || ! -f /proc/$ins_shell_pid/cmdline ]] && ins_shell_pid=$(ps -aux | grep -E "$USER.*pts/0[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')
+[[ -n $ins_shell_pid && -f /proc/$ins_shell_pid/cmdline ]] && ins_shell_current=$(tr -d '\000' < /proc/$ins_shell_pid/cmdline)
 if [[ -n $ins_shell_current && $ins_shell_current != *"bash"* ]]; then
 	echo "$(tput setaf 1)BASH Shell is required! $(tput dim)(${ins_shell_current}) $(tput sgr0)"
 	sudo rm weby