#!/bin/sh
>>>>>>>>##
# 系统初始化脚本
# 版本 V 0.1.2
# 作者
# 说明:
#
BASH_VER=0.0.1
fuction check_used()
{
  if [-d /root/confbak] then
  echo "Already Init"
  exit 1
}
confbakdir="/root/confbak"
mkdir -p $confbakdir
LAN_IP=`ifconfig|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p' |grep 172. |head -1`
SYS_VER=`cat /etc/redhat-release |awk '{print $3}'`
fuction check_system()
{
  if [-f /etc/redhat-release ] then
  echo "System Check Pass!"
  exit 1
  else
  echo "This System ----"
  exit 1
}
echo "nameserver 10.20.0.191" > /f
rpm --import mirrors.sohu/centos/5.7/os/x86_64/RPM-GPG-KEY-CentOS-5
#修改运行等级为3
pro_runlevel()
{
    cp /etc/inittab $confbakdir
    sed  -i -e  "s/id:5:initdefault:/id:3:initdefault:/" /etc/inittab
}
#禁止使用IP-V6
pro_disaipv6()
{
    cp /f $confbakdir
    echo "alias net-pf-10 off" >> /f
    echo "alias ipv6 off" >> /f
}
#修改GRUB超市时间为1秒
pro_grubtimeout()
{
    cp /boot/f $confbakdir
    sed -i -e  "s/timeout=5/timeout=1/" /boot/f
}
#关闭不必要的服务
pro_tunseroff()
  {
  for ser in `chkconfig --list  |grep 3:on |awk '{print $1}'`
        do
                echo $ser
                case $ser in
                  crond | irqbalance | microcode_ctl | network | random | sendmail \
                        | sshd | syslog | messagebus | haldaemon | readahead_early | \
                        apmd | readahead_later | readahead | iptables |lvm2-monitor |vmware-tools )
                echo "Base services, Skip"
            ;;
            *)
                echo "change $ser to off"
                chkconfig --level 3 $ser off
                service $ser stop
            ;;
                esac
        done
  }
#使用VI取代VIM
pro_aliasvi()
{
    sed -i "8 s/^/alias vi='vim'/" /root/.bashrc
    echo 'syntax on' > /root/.vimrc
conf
}
#将yum源更改为中科大源
pro_changemirr()
{
    mv /pos.po  $po.save
    wget -P /pos.d mirrors.sohu/repos/$SYS_po
}
#安装必须的软件
pro_sysyum()
{
    yum -y install  zlib-devel ncurses-devel gd-devel libpng-devel  libjpeg-devel freetype-devel \
        libxml2-devel curl-devel libtool ntp vim-enhanced gcc gcc-c++  \
        flex bison autoconf automake bzip2-devel  kernel net-snmp
}
#设置时间同步
pro_timentp()
{
    echo "5 * * * * /usr/sbin/ntpdate time.windows" >> /var/spool/cron/root
    service crond restart
}
#添加用户
pro_useradd()
{
    NEWUSER=test
    useradd $NEWUSER -u 21345
    echo test123 |passwd $NEWUSER --stdin
    sed -i 's#test:x:21345:21345#test:x:0:21345#' /etc/passwd
}
#修改ssh默认端口
pro_sshdset()
{
    cp /etc/ssh/sshd_config $confbakdir
    sed -i "s/#Port 22/Port 12345/" /etc/ssh/sshd_config
    sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
#    sed -i "s/#ListenAddress 0.0.0.0/ListenAddress $LAN_IP/" /etc/ssh/sshd_config
}
#关闭selinux
pro_iptables()
{
        sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/sysconfig/selinux
        sed -i "s/-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT/-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 12345 -j ACCEPT/" /etc/sysconfig/iptables
}
#添加snmp服务
pro_snmp()
{
mv /etc/f /etc/f.bak
echo "com2sec notConfigUser 127.0.0.1      szpub
com2sec notConfigUser 172.16.21.118      szpub
group  notConfigGroup v1          notConfigUser
group  notConfigGroup v2c          notConfigUser
view    systemview    included  .1.3.6.1.2.1.1
view    systemview    included  .1.3.6.1.2.1.25.1.1
access  notConfigGroup "\""""\"      any      noauth    exact  all  none none
view all    included  .1                              80
syslocation Unknown (edit /etc/f)
syscontact Root <root@localhost> (configure /etc/snmp/f)
proc mountd
proc sendmail 10 1
exec shelltest /bin/sh /tmp/testindex.sh
includeAllDisks 80%
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat" >> /etc/f
chkconfig snmpd on
sed -i '13a\-A RH-Firewall-1-INPUT -p udp --dport 161 -j ACCEPT' /etc/sysconfig/iptables
}
pro_disaipv6
pro_grubtimeout
pro_changemirr
pro_sysyum
pro_aliasvi
pro_timentp
pro_useradd
pro_tunseroff
pro_sshdset
pro_iptables
pro_snmp

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

FPGA各管脚简介
« 上一篇
Linux题库及答案
下一篇 »

发表评论