• 最小化安装centos的init初始化脚本


     #!/bin/bash
    #this script is appropriate for minimize installation system centos or linux 6.x(这脚本适合最小化安装6.x版本的系统)
    #you have already install the os
    read -p "Pleases input hostname for linux:" hname
    sed -i "/HOSTNAME/s/localhost.localdomain/$hname/g" /etc/sysconfig/network
    sed -i 's/enforcing/disabled/g' /etc/selinux/config
    #set ip address
    read -p "please input IP for host(like 192.168.1.1):"  ip 
    read -p "please input gataway ip for host:" gate
    read -p "please input dns ip for host:"   dns
    eth_conf=/etc/sysconfig/network-scripts/ifcfg-eth0
    sed -i -e '/IPADDR/d' -e '/NETMASK/d'            $eth_conf
    sed -i '/NM_CONTROLLED/s/yes/no/g'               $eth_conf
    sed -i '/ONBOOT/s/no/yes/g'                      $eth_conf
    sed -i '$a BOOTPROTO=static'                     $eth_conf
    #cat >> $eth_conf <<EOF
    #IPADDR=$ip
    #NETMASK=255.255.255.0
    #GATEWAY=$gate
    #DNS1=$dns
    #EOF
    echo -e "IPADDR=$ip
    NETMASK=255.255.255.0" >>      $eth_conf
    echo -e "GATEWAY=$gate
    DNS1=$dns" >>               $eth_conf
    sed  -i  '/^$/d'                                    $eth_conf
    #if you host can serf internet we set up this yum (如果你电脑能上网,我们搭建这样的yum,centos就不用搭建,有直接的yum源)
    cd /etc/yum.repos.d/
    rm -rf *.repo
    cat >> /etc/yum.repos.d/my.repo <<EOF
    [base]
    name=centos6
    baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch
    gpgecheck=1
    gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
    EOF
    yum clean all
    #if you host cannot serf internet set up the yum(电脑不能上网yum这样搭建,centos和redhat都适合)
    mount /dev/cdrom   /media
    sed -i '$a /dev/cdrom      /media     iso9660    defaults   0 0'  /etc/fstab
    #echo "/dev/cdrom            /media      iso9660    defaults   0 0 " >> /etc/fstab
    cd /etc/yum.repos.d/
    rm -rf *.repo
    cat >> /etc/yum.repos.d/iso.repo <<EOF
    [Centos]
    name=CentOS
    baseurl=file:///media/  
    gpgcheck=1
    enabled=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    EOF
    yum clean all
    echo "####restart network card#####"
    service network restart
    #set up(vim编辑器)
    yum -y install vim
    #set up(开发包和开发工具)
    yum -y groupinstall "Development" "Development tools"
    #set up (图形化桌面)这些包有点多,建议搭建本地yum安装
    #yum -y groupinstall "Desktop" "X Window System"
    yum -y groupinstall "Desktop" "Desktop Debugging and Performance Tools" "X Window System" "Desktop Platform" "Desktop Platform Development" "General Purpose Desktop" "Remote Desktop Clients"
    init 5
    #(设置vncserver)
    yum -y install tigervnc-server.x86_64
    echo "#####please input vncserver passwd########"
    vncserver
    sed -i 's/xterm/#xterm/g' /root/.vnc/xstartup
    sed -i 's/twm/#twm/g' /root/.vnc/xstartup 
    echo "gnome-session &" >> /root/.vnc/xstartup
    cat >> /etc/sysconfig/vncservers << EOF
     VNCSERVERS="1:root"
     VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp "
    EOF
    service vncserver restart
    vncserver -kill :1
    vncserver  :1
    chkconfig --add vncserver
    chkconfig --level 35 vncserver on
    service sshd restart
    echo "==========it is ok==========="
    #(做完这些你的linux服务器既可以ssh上去也可以用vnc连接linux的图形化界面)
  • 相关阅读:
    Aspose.Words三 创建表格
    Aspose.words一 DOM结构
    Aspose.words四 bookmark
    Aspose.Words五 MergeField
    为什么使用Reazor
    C#实现发送给QQ邮件
    T4模板之基础篇
    avalon子孙元素属性监听
    C#设置WebBrowser IE浏览器版本
    【GoLang】GoLang GOPATH 工程管理 最佳实践
  • 原文地址:https://www.cnblogs.com/sysk/p/4877913.html
Copyright © 2020-2023  润新知