zoukankan      html  css  js  c++  java
  • 配置IP地址及HOSTNAME脚本

    #!/bin/bash
    
    #修改IP及HOSTNAME
    
     ETHCONF=/etc/sysconfig/network-scripts/ifcfg-eth0
     HOSTS=/etc/hosts
     NETWORK=/etc/sysconfig/network
     DIR=/root/backup/`date +%Y%m%d` 
     NETMASK=255.255.255.0
     
    rm -rf /etc/udev/rules.d/70-persistent-net.rules

    function Change_ip () { if [ ! -d $DIR ];then mkdir -p $DIR fi echo "Now Change ip address ,Doing Backup Interface eth0" cp $ETHCONF $DIR read -p "Please insert ip Address:" IPADDR sed -i "s/IPADDR=.*/IPADDR=$IPADDR/g" $ETHCONF echo "This IP address Change success !" } function Change_hosts () { if [ ! -d $DIR ];then mkdir -p $DIR fi cp $HOSTS $DIR echo "Please insert IP and HOSTNAME" read -p "Please insert ip address": IPADDR read -p "Please insert HOSTNAME": HOSTNAMES if [ -n $IPADDR -a -n $HOSTNAMES ];then echo $IPADDR $HOSTNAMES >> $HOSTS sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAMES/g" $NETWORK echo "This hosts change success " else echo "This $host IS Exist .........." fi } PS3="Please Select ip or hosts Menu": select i in "Change_ip" "Change_hosts" "Reboot" "Quit" do case $i in Change_ip ) Change_ip ;; Change_hosts ) Change_hosts ;; Reboot ) sync;sync;sync;init 6 ;; Quit ) exit 0 ;; *) echo echo "Please Insert $0: Change_ip(1)|Change_hosts(2)" echo ;; esac done

    参考:http://www.jb51.net/article/56611.htm

  • 相关阅读:
    Nginx是如何配置为 Web 服务器的【转载】
    BeanUtil工具类的使用
    数据库:XML,解析Dom4J
    jsp简单标签开发
    Java 反射 使用总结
    JAVA 对象序列化——Serializable
    使用Session防止表单重复提交
    EasyUi模糊匹配搜索框combobox
    Cookie工作原理
    COOKIE和SESSION有什么区别?
  • 原文地址:https://www.cnblogs.com/storymedia/p/4475529.html
Copyright © 2011-2022 走看看