URL检查 跳板机 创建用户 Nginx启动 随机密码的脚本

简介:

URL检查

#!/bin/bash
path=/home/scripts
MAIL_GROUP="12306@qq.com 123456@163.com"
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 '3秒后开始执行检查UEL操作';
 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


############################

跳板机

#!/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 have input is error"
  esac
 done
}
main



###############################

批量创建用户设置密码

#!/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 "请到/tmp/user.log中查看账户和密码"




#########################

Nginx启动

#!/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 "$1" in 
 start)
  start
  RETVAL=$?
  ;;
 stop)
  stop
  RETVAL=$?
  ;;
 restart)
  stop
  sleep 1
  start
  RETVAL=$?
  ;;
 *)
  echo $"Usage: $0 {start|stop|restart}"
  exit 1
esac
exit $RETVAL



#################

随机密码生产

随机密码生产的6种不同方法

################随机生成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 10`"|passwd --stdin username >> /tmp/1.log


关闭不需要的服务
chkconfig |egrep -vE "crond|sshd|network|rsyslog|sysstat" |awk '{print "chkconfig",$1,"off"}'|bash



















本文转自super李导51CTO博客,原文链接:http://blog.51cto.com/superleedo/1933903 ,如需转载请自行联系原作者

相关文章
|
Web App开发 编解码 运维
LNMP详解(十二)——Nginx URL重写实战
LNMP详解(十二)——Nginx URL重写实战
219 2
|
移动开发 前端开发 JavaScript
前端vue2、vue3去掉url路由“ # ”号——nginx配置(一)
前端vue2、vue3去掉url路由“ # ”号——nginx配置
1257 0
|
前端开发 JavaScript 应用服务中间件
前端vue2、vue3去掉url路由“ # ”号——nginx配置(二)
前端vue2、vue3去掉url路由“ # ”号——nginx配置
792 0
|
域名解析 存储 缓存
HTTP请求流程概览:浏览器构建请求行含方法、URL和版本;检查缓存;解析IP与端口
【6月更文挑战第23天】 HTTP请求流程概览:浏览器构建请求行含方法、URL和版本;检查缓存;解析IP与端口;TCP连接(HTTP/1.1可能需排队);三次握手;发送请求头与体;服务器处理并返回响应;TCP连接可能关闭或保持;浏览器接收并显示响应,更新缓存。HTTP版本间有差异。
454 5
|
文字识别 小程序 API
视觉智能开放平台产品使用合集之使用SDK进行视频活体检查时,如何将视频URL传递给后端服务
视觉智能开放平台是指提供一系列基于视觉识别技术的API和服务的平台,这些服务通常包括图像识别、人脸识别、物体检测、文字识别、场景理解等。企业或开发者可以通过调用这些API,快速将视觉智能功能集成到自己的应用或服务中,而无需从零开始研发相关算法和技术。以下是一些常见的视觉智能开放平台产品及其应用场景的概览。
180 1
|
Ubuntu 应用服务中间件 Linux
Linux Centos7 ubuntu 安装nginx,脚本一键安装nginx
Linux Centos7 ubuntu 安装nginx,脚本一键安装nginx
438 2
|
应用服务中间件 nginx Windows
nginx实现网站url带参跳转 POST请求GET请求跳转
nginx实现网站url带参跳转 POST请求GET请求跳转
811 1
|
网络协议 应用服务中间件 nginx
nginx 302 301 设置 url 转跳 nginx 资源重定向 nginx tcp 和 http 转发
nginx 代理后端网站,和 网站资源目录重定向到其他连接地址
620 3
|
弹性计算 应用服务中间件 Shell
一键编译安装Nginx脚本
【4月更文挑战第30天】
398 1
|
弹性计算 应用服务中间件 Shell
编写nginx 启动脚本
【4月更文挑战第29天】
227 1