Skip to content

Commit

Permalink
2.1.6
Browse files Browse the repository at this point in the history
* first enter of login and password for keenetic router was always wrong.Fixed.
* added php version for statistics
  • Loading branch information
progreccor committed Dec 21, 2024
1 parent 9a187a9 commit 51ae0ec
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 38 deletions.
100 changes: 66 additions & 34 deletions checkip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ unicode_printf() {
echo -n "$unicode_string"
}

get_php_version() {
local DOMAIN=$1
local CONF_FILE="/etc/httpd/conf.d/${DOMAIN}.conf"

if [ -f "$CONF_FILE" ]; then
local PHP_VERSION
PHP_VERSION=$(grep -oP 'SetHandler\s+"proxy:unix:/var/opt/remi/php\K[0-9]+' "$CONF_FILE")
if [ -n "$PHP_VERSION" ]; then
echo "php ${PHP_VERSION}"
else
echo "-"
fi
else
echo "-"
fi
}

CheckIP() {
clear
echo "Что значат цвета IP:"
Expand All @@ -83,7 +100,7 @@ CheckIP() {
echo -e "Белый цвет – сайт доступен по другому IP адресу"
echo

myip="("$(ip route get 1 | grep -Eo 'src [0-9\.]{1,20}' | awk '{print $NF;exit}')")"
local myip=$(ip route get 1 | grep -Eo 'src [0-9\.]{1,20}' | awk '{print $NF;exit}')
echo -e "Адрес этого сервера: ${GREEN}${myip}${WHITE}"

echo "───────────────────────────────────────────"
Expand All @@ -100,47 +117,62 @@ CheckIP() {
for PathToSiteName in ${file}/www/*; do
if [ -d "$PathToSiteName" ]; then
local SiteName="${PathToSiteName##*/}"
if curl -I http://"$SiteName" &>/dev/null; then
local ip
ip=$(ping -c 1 $SiteName | grep PING | awk '{ print $3 }')
if [[ "$myip" == "$ip" ]]; then
printf " ${GREEN}%-19s${WHITE}" "$ip"
local CONF_FILE="/etc/httpd/conf.d/${SiteName}.conf"

if [ -f "$CONF_FILE" ]; then
if curl -I http://"$SiteName" &>/dev/null; then
local ip
ip=$(ping -c 1 $SiteName | grep PING | awk '{ print $3 }')
if [[ "$myip" == "$ip" ]]; then
printf " ${GREEN}%-19s${WHITE}" "$ip"
else
printf " %-19s" "$ip"
fi
check_certificate "$SiteName"
if [[ "$SiteName" =~ (xn\-\-) ]]
then
unicode_domain=$(idn2 -d "$SiteName")
else
unicode_domain=$SiteName
fi
echo -e -n " ${LGREEN}"
unicode_printf 32 "$unicode_domain"
echo -e -n " ${WHITE}"
check_certificate_expiration "$SiteName"
else
printf " %-19s" "$ip"
printf " %-27s" " "
if [[ "$SiteName" =~ (xn\-\-) ]]
then
unicode_domain=$(idn2 -d "$SiteName")
else
unicode_domain=$SiteName
fi
echo -e -n " ${RED}"
unicode_printf 32 "$unicode_domain"
echo -e -n " ${WHITE}"
printf " "
fi
check_certificate "$SiteName"
if [[ "$SiteName" =~ (xn\-\-) ]]
then
unicode_domain=$(idn2 -d "$SiteName")
if [ -f "${PathToSiteName}"/administrator/manifests/files/joomla.xml ]; then
JoomlaVersion=$(cat "${PathToSiteName}"/administrator/manifests/files/joomla.xml | grep "<version>.*</version>" | sed -rn 's/.*>([0-9.]+)<.*/\1/p')
printf " Joomla %8s" "${JoomlaVersion}"
else
unicode_domain=$SiteName
printf " %8s" "-"
fi
echo -e -n " ${LGREEN}"
unicode_printf 32 "$unicode_domain"
echo -e -n " ${WHITE}"
check_certificate_expiration "$SiteName"
PHP_VERSION=$(get_php_version "$SiteName")
printf ", ${PHP_VERSION}"
FOLDER_SIZE_MB=$(du -sm "${PathToSiteName}" | awk '{print $1}' | sed ':a;s/\([^0-9.][0-9]\+\|^[0-9]\+\)\([0-9]\{3\}\)/\1\ \2/g;ta')
printf " ${LWHITE}%9s ${WHITE}Mb" "${FOLDER_SIZE_MB} "
echo
else
printf " %-19s" " "
echo -e -n "папка ${RED}${SiteName}${WHITE} не сайт"
printf " %-27s" " "
if [[ "$SiteName" =~ (xn\-\-) ]]
then
unicode_domain=$(idn2 -d "$SiteName")
else
unicode_domain=$SiteName
fi
echo -e -n " ${RED}"
unicode_printf 32 "$unicode_domain"
echo -e -n " ${WHITE}"
printf " "
fi
if [ -f "${PathToSiteName}"/administrator/manifests/files/joomla.xml ]; then
JoomlaVersion=$(cat "${PathToSiteName}"/administrator/manifests/files/joomla.xml | grep "<version>.*</version>" | sed -rn 's/.*>([0-9.]+)<.*/\1/p')
printf " Joomla %8s" "${JoomlaVersion}"
else
printf " %4s " " "
printf " %8s" "-"
FOLDER_SIZE_MB=$(du -sm "${PathToSiteName}" | awk '{print $1}' | sed ':a;s/\([^0-9.][0-9]\+\|^[0-9]\+\)\([0-9]\{3\}\)/\1\ \2/g;ta')
printf " ${LWHITE}%9s ${WHITE}Mb" "${FOLDER_SIZE_MB} "
echo
fi
FOLDER_SIZE_MB=$(du -sm "${PathToSiteName}" | awk '{print $1}' | sed ':a;s/\([^0-9.][0-9]\+\|^[0-9]\+\)\([0-9]\{3\}\)/\1\ \2/g;ta')
printf " ${LWHITE}%9s ${WHITE}Mb" "${FOLDER_SIZE_MB} "
echo
fi
done
fi
Expand Down
4 changes: 2 additions & 2 deletions clonesite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ CloneSite() {
#local sites=( $( ssh $choosenserver ls -l $directory | grep 'drwx'| awk '{print $9}' ) )
mapfile -t sites < <(ssh $choosenserver 'ls -l /var/www/*/www/ 2>/dev/null' | grep drwx | grep -v 000-default | awk '{print $9" ("$3")"}' | sort)

vertical_menu "current" 2 10 30 "${sites[@]}"
vertical_menu "current" 2 20 30 "${sites[@]}"
choice=$?
if ((choice == 255)); then
return
Expand Down Expand Up @@ -220,7 +220,7 @@ CloneSite() {
echo "Выберите пользователя на текущем сервере, куда надо копировать сайт"
mapfile -t siteusers < <(ls -l /var/www 2>/dev/null | grep drwx | grep -v cgi-bin | grep -v html | awk '{print $9}' | sort)

vertical_menu "current" 2 10 30 "${siteusers[@]}"
vertical_menu "current" 2 20 30 "${siteusers[@]}"
choice=$?
if ((choice == 255)); then
return
Expand Down
4 changes: 2 additions & 2 deletions local_router.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ source "$CONFIG_FILE"
# Функция для запроса логина и пароля у пользователя и вычисления MD5_HASH
request_credentials() {
echo "Введите логин для роутера (или нажмите Enter для выхода):"
read -e ROUTER_LOGIN
read -r -e ROUTER_LOGIN
# Проверяем, введен ли логин
if [ -z "$ROUTER_LOGIN" ]; then
echo "Логин не введен. Выход из скрипта."
exit 1
fi
echo "Введите пароль для роутера:"
read -e ROUTER_PASSWORD
read -r -e ROUTER_PASSWORD
echo
# Вычисление MD5_HASH
MD5_HASH=$(echo -n "$ROUTER_LOGIN:$REALM:$ROUTER_PASSWORD" | openssl md5 | awk '{print $2}')
Expand Down

0 comments on commit 51ae0ec

Please sign in to comment.