Compare commits
41 Commits
30bdf7ba5c
...
master
Author | SHA1 | Date | |
---|---|---|---|
093d0fa56a | |||
eca352baab | |||
32f03ed5dc | |||
d688810304 | |||
0e8662c390 | |||
501f2be89e | |||
9d6b6a7afc | |||
555358a851 | |||
3c81d6c07f | |||
14a03d53b8 | |||
696a047e32 | |||
3290c04f6b | |||
8da6e9dbdf | |||
e7513a4060 | |||
2be9029fb7 | |||
efc081b0f0 | |||
0047a536e9 | |||
b4b4ecbfd0 | |||
3829104b72 | |||
9018dcb213 | |||
4c9150ea79 | |||
cb74515424 | |||
51e8245a4e | |||
2db3f6afbe | |||
36df562007 | |||
334c4b083c | |||
bcbc0924bb | |||
78acedc2d9 | |||
d9a58f5455 | |||
eed6cc73a6 | |||
da6419167a | |||
6b411698f2 | |||
bc0cd0450c | |||
89f527a06c | |||
436c38d8bc | |||
f72185ba59 | |||
6147b44d34 | |||
18e8163a7a | |||
25c2af3139 | |||
c499eb8bdb | |||
370aa5ff4b |
@ -1,7 +1,7 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: default
|
||||
name: deploy to prod
|
||||
|
||||
steps:
|
||||
- name: Check playbook
|
||||
@ -11,3 +11,6 @@ steps:
|
||||
- name: Run playbook
|
||||
commands:
|
||||
- ansible-playbook playbook.yml
|
||||
|
||||
node:
|
||||
target: shell-scripts
|
||||
|
@ -4,53 +4,27 @@ pid /run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
12
playbook.yml
12
playbook.yml
@ -6,8 +6,7 @@
|
||||
become: yes
|
||||
apt:
|
||||
name: nginx-light
|
||||
update_cache: yes
|
||||
state: latest
|
||||
state: present
|
||||
- name: Create dir
|
||||
file:
|
||||
path: /var/www
|
||||
@ -21,6 +20,14 @@
|
||||
group: www-data
|
||||
with_fileglob:
|
||||
- src/*
|
||||
- name: Copy index file
|
||||
become: yes
|
||||
template:
|
||||
src: template/index.jinja2
|
||||
dest: /var/www/index.html
|
||||
owner: www-data
|
||||
group: www-data
|
||||
mode: 0644
|
||||
- name: Copy config file
|
||||
become: yes
|
||||
copy:
|
||||
@ -32,6 +39,7 @@
|
||||
handlers:
|
||||
- name: Reload nginx
|
||||
become: yes
|
||||
ignore_errors: yes
|
||||
service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
|
97
src/basic.sh
97
src/basic.sh
@ -1,16 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "- Load:"
|
||||
trap 'echo " Vyhody cherez menu"' INT
|
||||
|
||||
TEXT_COLOR_GOOD="\033[92m"
|
||||
TEXT_COLOR_BAD="\033[91m"
|
||||
TEXT_COLOR_OFF="\033[0m"
|
||||
|
||||
echo -e "
|
||||
${TEXT_COLOR_GOOD}
|
||||
__ __ __
|
||||
/ /__ __ / /_ ___ / /___ ___ _____
|
||||
/ __/ | /| / / ______ / __ \/ _ \/ / __ \/ _ \/ ___/
|
||||
/ /_ | |/ |/ / /_____/ / / / / __/ / /_/ / __/ /
|
||||
\__/ |__/|__/ /_/ /_/\___/_/ .___/\___/_/
|
||||
/_/
|
||||
${TEXT_COLOR_OFF}
|
||||
"
|
||||
|
||||
harakiri() {
|
||||
printf "${TEXT_COLOR_BAD}Committing *roskomnadzor*...${TEXT_COLOR_OFF}\n"
|
||||
if [[ "$HOSTNAME" != "pve-ansible" ]]; then
|
||||
rm -f "$BASH_SOURCE" &> /dev/null
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
lsb_release -a 2> /dev/null
|
||||
echo -e "\n${TEXT_COLOR_GOOD} - Load:${TEXT_COLOR_OFF}\n"
|
||||
|
||||
nproc=`nproc`
|
||||
la=`cat /proc/loadavg | awk '{print $1, $2, $3}'`
|
||||
la=`cat /proc/loadavg | awk '{print $1", " $2", " $3}'`
|
||||
usedmem=`free -m | head -2 | tail -1 | awk '{print $3}'`
|
||||
totalmem=`free -m | head -2 | tail -1 | awk '{print $2}'`
|
||||
|
||||
echo 'LA: ' $la ' of ' $nproc
|
||||
echo 'RAM: ' $usedmem ' of ' $totalmem
|
||||
echo 'RAM: ' $usedmem 'Mb of ' $totalmem Mb
|
||||
|
||||
echo "- Disk:"
|
||||
echo -e "\n${TEXT_COLOR_GOOD} - Disk: ${TEXT_COLOR_OFF}\n"
|
||||
|
||||
df -h | head -n 1
|
||||
df -h | grep '/dev/vd'
|
||||
@ -19,10 +45,7 @@ echo "- Inodes:"
|
||||
|
||||
df -hi | grep '/dev/vd'
|
||||
|
||||
echo "- OOMS:"
|
||||
dmesg -T | grep "Out of memory"
|
||||
|
||||
echo "- Installed panel:"
|
||||
echo -e "\n${TEXT_COLOR_GOOD} - Installed panel: ${TEXT_COLOR_OFF}\n"
|
||||
|
||||
#if zero - false
|
||||
[[ -d /opt/webdir/bin/ ]] && echo "Bitrix!"
|
||||
@ -30,8 +53,60 @@ echo "- Installed panel:"
|
||||
[[ -d /usr/local/mgr5/ ]] && echo "ISPManager!"
|
||||
[[ -d /usr/local/fastpanel2 ]] && echo "Fastpanel 2"
|
||||
|
||||
echo "- Installed packages"
|
||||
echo -e "${TEXT_COLOR_GOOD} - OOMS: ${TEXT_COLOR_OFF}\n"
|
||||
dmesg -T | grep "Out of memory" | tail -20
|
||||
|
||||
|
||||
# Top RAM
|
||||
echo -e "${TEXT_COLOR_GOOD} - Top RAM usage:${TEXT_COLOR_OFF}"
|
||||
ps axk-%mem ouser,%cpu,%mem,command | head
|
||||
echo
|
||||
|
||||
# Top CPU
|
||||
echo -e "${TEXT_COLOR_GOOD} - Top CPU usage:${TEXT_COLOR_OFF}"
|
||||
ps axk-%cpu ouser,%cpu,%mem,command | head
|
||||
echo
|
||||
|
||||
# Какое ПО стоит? Docker/atop
|
||||
echo -e "\n${TEXT_COLOR_GOOD} - Installed software: ${TEXT_COLOR_OFF}\n"
|
||||
|
||||
for i in "docker" "atop" "qemu-ga"
|
||||
do
|
||||
if which $i
|
||||
then
|
||||
echo "$i is installed"
|
||||
else
|
||||
echo "$i is NOT installed"
|
||||
fi
|
||||
echo
|
||||
done
|
||||
|
||||
while true
|
||||
do
|
||||
echo -e "
|
||||
---
|
||||
2. nginx: Посмотреть конфиги и домены в них
|
||||
3. Запустить logs
|
||||
|
||||
0. Выход
|
||||
"
|
||||
|
||||
read -r -p "Выбери: " action
|
||||
case $action in
|
||||
0)
|
||||
harakiri
|
||||
;;
|
||||
2)
|
||||
nginx -T 2> /dev/null | egrep "configuration file|server_name"
|
||||
;;
|
||||
3)
|
||||
wget -O /tmp/nginx.sh 94.228.126.204/nginx.sh
|
||||
bash /tmp/nginx.sh
|
||||
rm /tmp/nginx.sh
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
|
||||
list=$(apt list --installed 2>&1 |egrep 'atop')
|
||||
|
||||
echo $list
|
||||
|
125
src/nginx.sh
Normal file
125
src/nginx.sh
Normal file
@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
|
||||
# trap 'echo " Vyhody cherez menu"' INT
|
||||
|
||||
TEXT_COLOR_GOOD="\033[92m"
|
||||
TEXT_COLOR_BAD="\033[91m"
|
||||
TEXT_COLOR_OFF="\033[0m"
|
||||
|
||||
echo -e "
|
||||
${TEXT_COLOR_GOOD}
|
||||
__
|
||||
/ /___ ____ ______
|
||||
/ / __ \/ __ / ___/
|
||||
/ / /_/ / /_/ (__ )
|
||||
/_/\____/\__, /____/
|
||||
/____/
|
||||
${TEXT_COLOR_OFF}
|
||||
"
|
||||
|
||||
menu() {
|
||||
[[ -d /opt/webdir/bin/ ]] && menu_bx
|
||||
[[ -d /usr/local/vesta/ ]] && menu_vesta
|
||||
[[ -d /usr/local/mgr5/ ]] && menu_isp
|
||||
[[ -d /usr/local/fastpanel2 ]] && menu_fastpanel
|
||||
}
|
||||
|
||||
menu_fastpanel() {
|
||||
|
||||
clear
|
||||
readarray -t lines < <(ls /var/www/fastuser/data/logs/ | awk -F"-" '{print $1}' | uniq )
|
||||
echo "Выбери сайт:"
|
||||
select c in "${lines[@]}"; do
|
||||
[[ -n $c ]] || { echo "Некорректный выбор." >&2; continue; }
|
||||
break
|
||||
done
|
||||
|
||||
read -r a <<<"$c"
|
||||
clear
|
||||
echo -n "Для $c:
|
||||
1. Access Log
|
||||
2. Error Log
|
||||
3. (DDoS) Количество запросов в минуту
|
||||
4. DDoS Топ запросов
|
||||
5. DDoS Топ IP-адресов
|
||||
6. Топ user-агентов
|
||||
7. Спам через форму
|
||||
8. Количество запроосов по часам
|
||||
9. Проверка кодов ответа
|
||||
|
||||
0. Выход
|
||||
"
|
||||
read -r b
|
||||
case $b in
|
||||
0)
|
||||
exit ;;
|
||||
1)
|
||||
clear
|
||||
cat /var/www/fastuser/data/logs/$c-frontend.access.log
|
||||
read -p 'Для выхода в меню нажми Enter'
|
||||
;;
|
||||
2)
|
||||
clear
|
||||
cat /var/www/fastuser/data/logs/$c-frontend.error.log
|
||||
read -p 'Для выхода в меню нажми Enter'
|
||||
;;
|
||||
3)
|
||||
clear
|
||||
wc -l "/var/www/fastuser/data/logs/$c-frontend.access.log"
|
||||
echo "Подождем минуту..."
|
||||
sleep 1m
|
||||
wc -l "/var/www/fastuser/data/logs/$c-frontend.access.log"
|
||||
read -p 'Для выхода в меню нажми Enter'
|
||||
;;
|
||||
4)
|
||||
clear
|
||||
cat /var/www/fastuser/data/logs/$c-frontend.access.log | awk '{print $7}' | sort | uniq -c | sort -rn | head
|
||||
read -p 'Для выхода в меню нажми Enter'
|
||||
;;
|
||||
5)
|
||||
clear
|
||||
cat /var/www/fastuser/data/logs/$c-frontend.access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head
|
||||
read -p 'Для выхода в меню нажми Enter'
|
||||
;;
|
||||
6)
|
||||
cat /var/www/fastuser/data/logs/$c-frontend.access.log | awk ' {for (i = 12; i <= (NF-1); i++) printf("%s%s",$i,(i==(NF-1))?"\n":OFS)}' | sort | uniq -c |sort -rn |head
|
||||
read -p 'Для выхода в меню нажми Enter'
|
||||
;;
|
||||
7)
|
||||
clear
|
||||
cat /var/www/fastuser/data/logs/$c-frontend.access.log | grep POST |awk '{print $6,$7}' | sort | uniq -c | sort -rn | head
|
||||
read -p 'Для выхода в меню нажми Enter'
|
||||
;;
|
||||
8)
|
||||
clear
|
||||
cat /var/www/fastuser/data/logs/$c-frontend.access.log | awk '{print $4}' | sed 's/:[0-9][0-9]:[0-9][0-9]$//g' | uniq -c
|
||||
read -p 'Для выхода в меню нажми Enter'
|
||||
;;
|
||||
9)
|
||||
clear
|
||||
cat /var/www/fastuser/data/logs/$c-frontend.access.log | awk '{print $9}' | sort | uniq -c | sort -rn | head
|
||||
read -p 'Для выхода в меню нажми Enter'
|
||||
;;
|
||||
esac
|
||||
menu_fastpanel
|
||||
}
|
||||
|
||||
menu_bx() {
|
||||
clear
|
||||
echo "В процессе запила"
|
||||
menu_exit
|
||||
}
|
||||
|
||||
menu_vesta() {
|
||||
clear
|
||||
echo "В процессе запила"
|
||||
menu_exit
|
||||
}
|
||||
|
||||
menu_isp() {
|
||||
clear
|
||||
echo "В процессе запила"
|
||||
menu_exit
|
||||
}
|
||||
|
||||
menu
|
6
template/index.jinja2
Normal file
6
template/index.jinja2
Normal file
@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<a href="basic.sh">wget -q -O - {{ansible_default_ipv4.address}}/basic.sh | bash</a> <br>
|
||||
<a href="nginx.sh">wget -q -O - {{ansible_default_ipv4.address}}/nginx.sh | bash</a> <br>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user