[关闭]
@xxliixin1993 2016-01-08T03:12:45.000000Z 字数 1176 阅读 1137

initCentOS6.6

linux


  1. #!/bin/bash
  2. if [[ "$(whoami)" != "root" ]]; then
  3. echo "please run this script as root ." >&2
  4. exit 1
  5. fi
  6. echo -e "\033[31m 这个是系统初始化脚本,请慎重运行!确定使用请注释指定行 \033[0m"
  7. #请注释下一行
  8. exit 1;
  9. #设置动态ip
  10. ip(){
  11. sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-eth0
  12. service network restart > /dev/null
  13. }
  14. yum_update(){
  15. yum -y install wget
  16. cd /etc/yum.repos.d/
  17. mkdir bak
  18. mv ./*.repo bak
  19. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  20. wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
  21. # yum clean all && yum makecache
  22. # yum -y install vim unzip openssl-client gcc gcc-c++ ntp
  23. }
  24. #关闭SELINUX
  25. selinux(){
  26. sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
  27. setenforce 0
  28. }
  29. #设置时间时区同步
  30. zone_time(){
  31. rm -rf /etc/localtime
  32. ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  33. # Update time
  34. /usr/sbin/ntpdate pool.ntp.org
  35. echo '*/5 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1' > /var/spool/cron/root;chmod 600 /var/spool/cron/root
  36. /sbin/service crond restart
  37. }
  38. # iptables
  39. iptables(){
  40. iptables -F
  41. iptables -P INPUT ACCEPT
  42. iptables -P OUTPUT ACCEPT
  43. service iptables save
  44. }
  45. other(){
  46. # initdefault
  47. # sed -i 's/^id:.*$/id:3:initdefault:/' /etc/inittab
  48. # /sbin/init q
  49. }
  50. main(){
  51. ip
  52. yum_update
  53. selinux
  54. zone_time
  55. iptables
  56. }
  57. main
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注