URL Check
#!/bin/bash
Path=/home/scripts
mail_group= "[email protected] [email protected]"
photo_group= "13502693568 18023569846"
. /etc/init.d/functions
Check_count=0
Url_list (
Http://www.baidu.com
Http://blog.51cto.com
Http://www.qq.com
http://192.168.1.5
)
Functions Wait ()
{
Echo-n ' after 3 seconds to perform check uel operation ';
For ((i=0;i<3;i++))
Do
Echo-n "1 ..."; Sleep 1
Done
Echo
}
Functions Check_url ()
{
Wait
For ((i=0;i< ' echo ${#url_list [*]} '; i++))
Do
Wget-o/dev/null-t 3--tries=1--spider ${url_list[$i]} >/dev/null 2>&1
If [$?-eq 0]
Then
Action "${url_list[$i]}"/bin/true
Else
Action "${url_list[$i]}"/bin/false
Fi
Done
((check_count++))
}
Functions MAIL () {
For user in ' echo $MAIL _group '
Do
Mail-s "$content" $user < $logfile
Done
}
Main ()
{
While True
Do
Check_url
echo "----------Check_count: $check _count----------"
Sleep
Done
}
Main
############################
Springboard machine
#!/bin/bash
Trapper () {
Trap ': ' INT EXIT TSTP term HUP
}
Main () {
While:
Do
Trapper
Clear
Cat <<menu
1) web01-192.168.1.5
2) web02-192.168.1.6
3) web03-192.168.1.7
4) mysql-192.168.1.8
Menu
Read-p "Please input the num:" num
Case ' $num ' in
1)
Echo ' Login in 192.168.1.5 Web01-nginx '
SSH 192.168.1.5
;;
2)
Echo ' Login in 192.168.1.6 web02-nginx '
SSH 192.168.1.6
;;
3)
Echo ' Login in 192.168.1.7 web03-nginx '
SSH 192.168.1.7
;;
4)
Echo ' Login in 192.168.1.8 mysql-192 '
SSH 192.168.1.8
;;
*)
echo "The num you had input is error"
Esac
Done
}
Main
###############################
Bulk Create user settings password
#!/bin/bash
. /etc/init.d/functions
User= "Kaifa"
Passdile= "/tmp/user.log"
For num in ' sed-w 1 20 '
Do
Password= "' OpenSSL rand-base64 10 '"
Useradd $user $num &>/dev/null &&\
echo "$password" |passwd--stdin $user $num &>/dev/null &&\
Echo-e "$user $num:: $password" >> $passdile
If [#?-EQ 0]
Then
Action "$user $num is OK"/bin/true
Else
Action "$user $num is fail"/bin/false
Fi
Done
echo "############## #创建完成 ###################"
echo "Please check your account and password in/tmp/user.log"
#########################
Nginx Boot
#!/bin/bash
# Chkconfig 2345 50 98
Path=/usr/local/nginx/sbin
Pid=/usr/local/nginx/logs/nginx.pid
Retval=0
. /etc/init.d/functions
Start () {
if[' netstat-lunpt|grep nginx |wc-l '-eq 0];then
$pash/nginx
Retval=$?
If [$RETVAL-eq 0];then
Action "Nginx is started"/bin/true
Return $RETVAL
Else
Action "Nginx is started"/bin/false
Return $RETVAL
Fi
Else
echo "Nginx is running"
return 0
Fi
}
Stop () {
If [-F $pid]
$path/nginx-s Stop
Retval=$?
If [$RETVAL-eq 0];then
Action "Nginx is stoped"/bin/true
Return $RETVAL
Else
Action "Nginx is stoped"/bin/false
Return $RETVAL
Fi
Else
echo "Nginx is not running"
Return $RETVAL
Fi
}
Case "$" in
Start
Start
Retval=$?
;;
Stop
Stop
Retval=$?
;;
Restart
Stop
Sleep 1
Start
Retval=$?
;;
*)
echo $ "Usage: $ {Start|stop|restart}"
Exit 1
Esac
Exit $RETVAL
#################
Random password production
6 different methods of random password production
############### #随机生成10位的密码
echo "Helloboy$random" |md5sum|cut-c 3-13
OpenSSL rand-base64 10
Date +%s%n |md5sum|cut-c 2-12
Head/dev/urandom|cksum|md5sum|cut-c 2-12
Mkpasswd-l 9-d 2-c 3-c 3-s 1|md5sum|cut-c 3-13
echo "' OpenSSL rand-base64 '" |passwd--stdin username >>/tmp/1.log
Turn off services that you do not need
Chkconfig |egrep-ve "Crond|sshd|network|rsyslog|sysstat" |awk ' {print "Chkconfig", $, "Off"} ' |bash
This article is from the "[email protected]" blog, please be sure to keep this source http://superleedo.blog.51cto.com/12164670/1933903
URL check Springboard machine create user nginx startup random password script