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

 #!/bin/bash
#this script is appropriate for minimize installation system centos or linux .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=
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=
enabled=
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
#(设置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[]="-geometry 1024x768 -nolisten tcp "
EOF
service vncserver restart
vncserver -kill :
vncserver :
chkconfig --add vncserver
chkconfig --level vncserver on
service sshd restart
echo "==========it is ok==========="
#(做完这些你的linux服务器既可以ssh上去也可以用vnc连接linux的图形化界面)
上一篇:我对大项目的看法(定义)


下一篇:生产服务器环境最小化安装后 Centos 6.5优化配置[转]