bash check

Bash check improved again!!!!
This commit is contained in:
Cristhian Martínez Ochoa 2022-02-23 15:49:23 -07:00
parent a4c9a477a8
commit e10b5105a2
3 changed files with 34 additions and 25 deletions

View file

@ -26,13 +26,16 @@ readonly dim=`tput dim`
# Check for BASH Shell
# 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
shell_tty=$(echo $(tty) | grep -Eo "pts/[0-9]+")
if [[ -n $shell_tty ]]; then
shell_pid=$(ps -au | grep -E "${shell_tty}[ ]+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)
[[ -n $shell_pid && -f /proc/$shell_pid/status ]] && shell_status=$(grep -Eo '^Name:.*bash.*' /proc/$shell_pid/status) # Double check!!!
if [[ -n $shell_current && $shell_current != *"bash"* && -z $shell_status ]]; then
echo "${red}BASH Shell is required! ${dim}(${shell_current}) ${end}"
exit 1
fi
fi
# STOP and exit if not root or sudo.

View file

@ -753,16 +753,19 @@ if [[ -z $critical_mode ]]; then
# Check for BASH Shell
# 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
local 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 ]] && local 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 ]] && local 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}"
local ver_shell_tty=$(echo $(tty) | grep -Eo "pts/[0-9]+")
if [[ -n $ver_shell_tty ]]; then
local ver_shell_pid=$(ps -au | grep -E "${ver_shell_tty}+[ ]+S[s]?[ ]+" | tail -n 1 | awk '{print $2}')
[[ -n $ver_shell_pid && -f /proc/$ver_shell_pid/cmdline ]] && local ver_shell_current=$(tr -d '\000' < /proc/$ver_shell_pid/cmdline)
[[ -n $ver_shell_pid && -f /proc/$ver_shell_pid/status ]] && ver_shell_status=$(grep -Eo '^Name:.*bash.*' /proc/$ver_shell_pid/status) # Double check!!!
if [[ -n $ver_shell_current && $ver_shell_current != *"bash"* && -z $ver_shell_status ]]; 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
fi
# Check for updates

19
weby
View file

@ -16,14 +16,17 @@ fi
# Check for BASH Shell
# 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
exit 1
ins_shell_tty=$(echo $(tty) | grep -Eo "pts/[0-9]+")
if [[ -n $ins_shell_tty ]]; then
ins_shell_pid=$(ps -au | grep -E "${ins_shell_tty}[ ]+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)
[[ -n $ins_shell_pid && -f /proc/$ins_shell_pid/status ]] && ins_shell_status=$(grep -Eo '^Name:.*bash.*' /proc/$ins_shell_pid/status) # Double check!!!
if [[ -n $ins_shell_current && $ins_shell_current != *"bash"* && -z $ins_shell_status ]]; then
echo "$(tput setaf 1)BASH Shell is required! $(tput dim)(${ins_shell_current}) $(tput sgr0)"
sudo rm weby
exit 1
fi
fi
# Check for sudo/root privileges