zoukankan      html  css  js  c++  java
  • 最小化安装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的图形化界面)
  • 相关阅读:
    一些你可能用到的代码
    iOS 键盘下去的方法
    iOS设计模式汇总
    随笔
    Spring cloud config 分布式配置中心 (三) 总结
    Spring cloud config 分布式配置中心(二) 客户端
    Spring cloud config 分布式配置中心(一) 服务端
    jdbcUrl is required with driverClassName spring boot 2.0版本
    JpaRepository接口找不到 spring boot 项目
    解决IntelliJ “Initialization failed for 'https://start.spring.io'
  • 原文地址:https://www.cnblogs.com/sysk/p/4877913.html
Copyright © 2011-2022 走看看