forked from aqzt/kjyw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
587 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
## gitlab_rpm 2016-05-16 | ||
## http://www.aqzt.com | ||
##email: [email protected] | ||
##robert yu | ||
##centos 6和centos 7 | ||
|
||
##提取两个文件第一列相同的行 | ||
awk -F',' 'NR==FNR{a[$1]=$0;next}NR>FNR{if($1 in a)print $0"\n"a[$1]}' 1.log 2.log | ||
|
||
awk 'NR==FNR{a[$1]++}NR>FNR&&a[$1]>1' 111.txt 111.txt | ||
|
||
awk 'a[$1]++==1' | ||
|
||
cat 111.txt | awk -F '[:|]' '{print $2}' > 111.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
#/bin/bash | ||
######################################### | ||
#Function: auto fdisk | ||
#Usage: bash auto_fdisk.sh | ||
#Author: Customer service department | ||
#Company: Alibaba Cloud Computing | ||
#Version: 4.0 | ||
######################################### | ||
|
||
count=0 | ||
tmp1=/tmp/.tmp1 | ||
tmp2=/tmp/.tmp2 | ||
>$tmp1 | ||
>$tmp2 | ||
fstab_file=/etc/fstab | ||
|
||
#check lock file ,one time only let the script run one time | ||
LOCKfile=/tmp/.$(basename $0) | ||
if [ -f "$LOCKfile" ] | ||
then | ||
echo -e "\033[1;40;31mThe script is already exist,please next time to run this script.\033[0m" | ||
exit | ||
else | ||
echo -e "\033[40;32mStep 1.No lock file,begin to create lock file and continue.\033[40;37m" | ||
touch $LOCKfile | ||
fi | ||
|
||
#check user | ||
if [ $(id -u) != "0" ] | ||
then | ||
echo -e "\033[1;40;31mError: You must be root to run this script, please use root to install this script.\033[0m" | ||
rm -rf $LOCKfile | ||
exit 1 | ||
fi | ||
|
||
#check disk partition | ||
check_disk() | ||
{ | ||
>$LOCKfile | ||
device_list=$(fdisk -l|grep "Disk"|grep "/dev"|awk '{print $2}'|awk -F: '{print $1}'|grep "vd") | ||
for i in `echo $device_list` | ||
do | ||
device_count=$(fdisk -l $i|grep "$i"|awk '{print $2}'|awk -F: '{print $1}'|wc -l) | ||
echo | ||
if [ $device_count -lt 2 ] | ||
then | ||
now_mount=$(df -h) | ||
if echo $now_mount|grep -w "$i" >/dev/null 2>&1 | ||
then | ||
echo -e "\033[40;32mThe $i disk is mounted.\033[40;37m" | ||
else | ||
echo $i >>$LOCKfile | ||
echo "You have a free disk,Now will fdisk it and mount it." | ||
fi | ||
fi | ||
done | ||
disk_list=$(cat $LOCKfile) | ||
if [ "X$disk_list" == "X" ] | ||
then | ||
echo -e "\033[1;40;31mNo free disk need to be fdisk.Exit script.\033[0m" | ||
rm -rf $LOCKfile | ||
exit 0 | ||
else | ||
echo -e "\033[40;32mThis system have free disk :\033[40;37m" | ||
for i in `echo $disk_list` | ||
do | ||
echo "$i" | ||
count=$((count+1)) | ||
done | ||
fi | ||
} | ||
|
||
#check os | ||
check_os() | ||
{ | ||
os_release=$(grep "Aliyun Linux release" /etc/issue 2>/dev/null) | ||
os_release_2=$(grep "Aliyun Linux release" /etc/aliyun-release 2>/dev/null) | ||
if [ "$os_release" ] && [ "$os_release_2" ] | ||
then | ||
if echo "$os_release"|grep "release 5" >/dev/null 2>&1 | ||
then | ||
os_release=aliyun5 | ||
modify_env | ||
fi | ||
fi | ||
} | ||
|
||
#install ext4 | ||
modify_env() | ||
{ | ||
modprobe ext4 | ||
yum install e4fsprogs -y | ||
} | ||
|
||
#fdisk ,formating and create the file system | ||
fdisk_fun() | ||
{ | ||
fdisk -S 56 $1 << EOF | ||
n | ||
p | ||
1 | ||
wq | ||
EOF | ||
|
||
sleep 5 | ||
mkfs.ext4 ${1}1 | ||
} | ||
|
||
#make directory | ||
make_dir() | ||
{ | ||
echo -e "\033[40;32mStep 4.Begin to make directory\033[40;37m" | ||
now_dir_count=$(ls /|grep "alidata*"|awk -F "data" '{print $2}'|sort -n|tail -1) | ||
if [ "X$now_dir_count" == "X" ] | ||
then | ||
for j in `seq $count` | ||
do | ||
echo "/data$j" >>$tmp1 | ||
mkdir /data$j | ||
done | ||
else | ||
for j in `seq $count` | ||
do | ||
k=$((now_dir_count+j)) | ||
echo "/data$k" >>$tmp1 | ||
mkdir /data$k | ||
done | ||
fi | ||
} | ||
|
||
#config /etc/fstab and mount device | ||
main() | ||
{ | ||
for i in `echo $disk_list` | ||
do | ||
echo -e "\033[40;32mStep 3.Begin to fdisk free disk.\033[40;37m" | ||
fdisk_fun $i | ||
echo "${i}1" >>$tmp2 | ||
done | ||
make_dir | ||
>$LOCKfile | ||
paste $tmp2 $tmp1 >$LOCKfile | ||
echo -e "\033[40;32mStep 5.Begin to write configuration to /etc/fstab and mount device.\033[40;37m" | ||
while read a b | ||
do | ||
if grep -v ^# $fstab_file|grep ${a} >/dev/null | ||
then | ||
sed -i "s=${a}*=#&=" $fstab_file | ||
fi | ||
echo "${a} $b ext4 defaults 0 0" >>$fstab_file | ||
done <$LOCKfile | ||
mount -a | ||
} | ||
|
||
#=========start script=========== | ||
echo -e "\033[40;32mStep 2.Begin to check free disk.\033[40;37m" | ||
check_os | ||
check_disk | ||
main | ||
df -h | ||
rm -rf $LOCKfile $tmp1 $tmp2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
## gitlab_rpm 2016-05-16 | ||
## http://www.aqzt.com | ||
##email: [email protected] | ||
##robert yu | ||
##centos 6和centos 7 | ||
##运维就是踩坑,踩坑的最高境界就是:踩遍所有的坑,让别人无坑可踩! | ||
|
||
##cd /var/cache/yum找*.rpm移动到一个文件夹 | ||
find . -name "*.rpm" -exec cp {} /root/111 \; | ||
|
||
|
||
##找到*.log日志全部删除 | ||
find . -name *.log | xargs rm | ||
find . -name *.rpm | xargs rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
# Author: ppabc <ppabc AT qq.com> | ||
# Blog: http://ppabc.cn | ||
# | ||
# Version: 0.1 1-October-2014 ppabc AT qq.com | ||
# Notes: init script for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ | ||
# | ||
# This script's project home is: | ||
# https://github.com/ppabc/linux-init-script | ||
# | ||
|
||
|
||
num=200 | ||
cd /data/nginxlogs/ | ||
tail nginxlogs.access.log -n 9999 |awk '{print $1}'|sort |uniq -c|sort -nr|head -n 200 > /data/nginxlogs/iptables.log | ||
tail nginxlogs.access.log -n 9999 |awk '{print $1}'|sort |uniq -c|sort -nr|head -n 200 | ||
|
||
cd /data/nginxlogs/ | ||
for i in `cat iptables.log|awk '{print $2}'` | ||
do | ||
#k=`awk -F" " '{print $1}' $i` | ||
#echo $k | ||
/sbin/iptables -I INPUT -p tcp -s $i --dport 80 -j DROP | ||
echo $i | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
# Author: ppabc <ppabc AT qq.com> | ||
# Blog: http://ppabc.cn | ||
# | ||
# Version: 0.1 1-October-2014 ppabc AT qq.com | ||
# Notes: init script for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ | ||
# | ||
# This script's project home is: | ||
# https://github.com/ppabc/linux-init-script | ||
# | ||
|
||
if [ -f /etc/redhat-release ];then | ||
OS=CentOS | ||
elif [ ! -z "`cat /etc/issue | grep bian`" ];then | ||
OS=Debian | ||
elif [ ! -z "`cat /etc/issue | grep Ubuntu`" ];then | ||
OS=Ubuntu | ||
else | ||
echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m" | ||
kill -9 $$ | ||
fi | ||
|
||
OS_command() | ||
{ | ||
if [ $OS == 'CentOS' ];then | ||
echo -e $OS_CentOS | bash | ||
elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then | ||
echo -e $OS_Debian_Ubuntu | bash | ||
else | ||
echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m" | ||
kill -9 $$ | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# Author: ppabc <ppabc AT qq.com> | ||
# Blog: http://ppabc.cn | ||
# | ||
# Version: 0.1 1-October-2014 ppabc AT qq.com | ||
# Notes: init script for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ | ||
# | ||
# This script's project home is: | ||
# https://github.com/ppabc/linux-init-script | ||
# | ||
|
||
. check_os.sh | ||
# init | ||
if [ "$OS" == 'CentOS' ];then | ||
echo CentOS | ||
elif [ "$OS" == 'Debian' ];then | ||
echo Debian | ||
elif [ "$OS" == 'Ubuntu' ];then | ||
echo Ubuntu | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# welcome | ||
cat << EOF | ||
+--------------------------------------------------------------+ | ||
| === Welcome to Centos System init === | | ||
+--------------------------------------------------------------+ | ||
EOF | ||
|
||
# disable ipv6 | ||
cat << EOF | ||
+--------------------------------------------------------------+ | ||
| === Welcome to Disable IPV6 === | | ||
+--------------------------------------------------------------+ | ||
EOF | ||
echo "alias net-pf-10 off" >> /etc/modprobe.conf | ||
echo "alias ipv6 off" >> /etc/modprobe.conf | ||
/sbin/chkconfig --level 35 ip6tables off | ||
echo "ipv6 is disabled!" | ||
|
||
# disable selinux | ||
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config | ||
echo "selinux is disabled,you must reboot!" | ||
|
||
# vim | ||
sed -i "8 s/^/alias vi='vim'/" /root/.bashrc | ||
cat >/root/.vimrc<<EOF | ||
syntax on | ||
set expandtab | ||
set shiftwidth=4 | ||
set softtabstop=4 | ||
set tabstop=4 | ||
EOF | ||
|
||
|
||
# init_ssh | ||
sed -i '/GSSAPI/ {s/yes/no/g};/UseDNS/ {s/.*/UseDNS no/};/^SyslogFacility/ {s/AUTHPRIV/local5/g}' /etc/ssh/sshd_config | ||
sed -i '/StrictHostKeyChecking/ {s/.*/StrictHostKeyChecking no/}' /etc/ssh/ssh_config | ||
sed -i '$ a\# save sshd messages also to sshd.log \nlocal5.* \t\t\t\t\t\t /var/log/sshd.log' /etc/syslog.conf | ||
echo "Configured SSH initialization!" | ||
|
||
# chkser | ||
# tunoff services | ||
#-------------------------------------------------------------------------------- | ||
cat << EOF | ||
+--------------------------------------------------------------+ | ||
| === Welcome to Tunoff services === | | ||
+--------------------------------------------------------------+ | ||
EOF | ||
#--------------------------------------------------------------------------------- | ||
for i in `ls /etc/rc3.d/S*` | ||
do | ||
CURSRV=`echo $i|cut -c 15-` | ||
|
||
echo $CURSRV | ||
case $CURSRV in | ||
crond | irqbalance | microcode_ctl | network | random | sendmail | sshd | syslog | local | mysqld | nginx | fastcgi ) | ||
echo "Base services, Skip!" | ||
;; | ||
*) | ||
echo "change $CURSRV to off" | ||
chkconfig --level 235 $CURSRV off | ||
service $CURSRV stop | ||
;; | ||
esac | ||
done | ||
|
||
# set ntpdate | ||
# crontab | ||
crontab -l >> /tmp/crontab2.tmp | ||
echo '15 1 * * * /usr/sbin/ntpdate ntp.api.bz;/usr/sbin/hwclock -w > /dev/null 2>&1' >> /tmp/crontab2.tmp | ||
crontab /tmp/crontab2.tmp | ||
rm /tmp/crontab2.tmp | ||
|
||
echo -e "\033[32;49;1mInitialization complete" | ||
echo -en "\033[39;49;0m" | ||
|
Oops, something went wrong.