#!/bin/bash
最小化安装centos的init初始化脚本
原创jie783213507 博主文章分类:linux shell脚本 ©著作权
©著作权归作者所有:来自51CTO博客作者jie783213507的原创作品,请联系作者获取转载授权,否则将追究法律责任
#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\nNETMASK=255.255.255.0" >> $eth_conf
echo -e "GATEWAY=$gate\nDNS1=$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的图形化界面)
下一篇:SHELL的变量和运算字符笔记
![](https://ucenter.51cto.com/images/noavatar_middle.gif)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
CentOS7.9系统初始化安装配置操作
CentOS7.9系统初始化安装配置
sed 配置文件 重启 -
CentOS7最小化安装后初始化脚本
CentOS7最小化安装后初始化脚本
CentOS7最小化安装后初始化脚本 -
最小化安装Linux系统初始化脚本
最小化安装Linux系统初始化脚本
linux centos ubuntu init 最小化安装 -
centos的非最小化安装 centos7最小化安装
centos 7虚拟机安装手册。环境:VMware虚拟机软件 centos7最小化安装包 步骤:第一步:新建虚拟机 第二步:选择要安装的虚拟机的操作系统镜像。如我这里使用的就是CentOS7最小化安装的ISO镜像文件:Cent
centos的非最小化安装 centos7最小化安装手册 centos VMware 主机名