91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

linux初始化腳本1.1

發布時間:2020-06-14 06:56:40 來源:網絡 閱讀:365 作者:唯愛你的 欄目:系統運維

version:1.1
des:主要針對redhat系列操作系統虛擬機的初始化配置
更新以下內容:

  • 添加網絡檢測
  • 添加網卡名稱判斷
  • 添加主機變量配置
  • 精簡yum和.bashrc配置文件生成,通過'EOF'在配置文件中直接引用變量,去掉了變量$前的\
  • 修復yum配置時移動命令報錯不能移動bak目錄本身
  • 修復未配置網關錯誤

#!/bin/bash
#====================================================
# Author: Mr.Song
# Create Date: 2019-10-27
# Description:
#====================================================
########################################################
set -x 
echo  'nameserver 119.29.29.29' >> /etc/resolv.conf 
ping -c 2   www.baidu.com  2>&1  >/dev/null  || 'echo -e '\033[31mNetwork test fail,please check network configuration \033[0m' && exit 1 '
########################################################

##start intial script
########################################################
NET_INETERFACE_NAME=`ip a|grep -v lo|egrep  ^[0-9] |cut -f 2 -d ':' |sed 's#[[:space:]]##'`
HOST_IP='192.168.10.11'
HOST_NETMASK='24'
HOST_GATEWAY='192.168.10.2'
HOST_DNS='119.29.29.29'
HOST_NAME='test'
########################################################

hostnamectl  set-hostname $HOST_NAME

########################################################
#disable firewalld and selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/enforcing$/disabled/g'  /etc/selinux/config
########################################################

########################################################
#yum config
mkdir -p /etc/yum.repos.d/bak
mv   /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
cat > /etc/yum.repos.d/CentOS-163.repo  <<- 'EOF'
#CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
EOF

#install common software
yum install -y vim nano wget gcc chrony lrzsz bash-completion net-tools psmisc
#yum install epel-release
#yum install -y atop htop iftop
########################################################

########################################################
#bash配置
cat >> ~/.bashrc  <<- 'EOF'
alias cls='clear'   #DOS風格的清空
alias h='history | tail'
alias hg='history | grep'
alias hl='history | less'
#stty erase ^H        #清除退格 (這個很有必要)
export PS1="[\[\e[0;36m\]\u\[\e[m\]@\[\e[0;32m\]\h \[\e[0;35m\]\W\[\e[m\]]\\$"
#export PS1="[\[\e[0;36m\]\u\[\e[m\]@\[\e[0;32m\]\h \[\e[0;35m\]\W\[\e[m\]]\\\\$"
EOF
#########################################################
#vim配置:行號、快捷鍵輸入文本、中文支持
cat >> ~/.vimrc <<-EOF
set autoindent
set nu
set paste
syntax on
set tabstop=4
set shiftwidth=4
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
function AddTitle()
call setline(1,"#!/bin/bash")
call append(1,"#====================================================")
call append(2,"# Author: Mr.Song")
call append(3,"# Create Date: " . strftime("%Y-%m-%d"))
call append(4,"# Description: ")
call append(5,"#====================================================")
endf
map <F4> :call AddTitle()<cr>
EOF
#########################################################
#openssh優化:禁用DNS查詢
sed -i  -e '/#UseDNS/a\UseDNS no' /etc/ssh/sshd_config
systemctl restart sshd
#########################################################

#########################################################
#ntp config
sed -i 's#0.centos.pool.ntp.org#s2b.time.edu.cn#;s#1.centos.pool.ntp.org#ntp1.aliyun.com#;s#server 2.#\#server 2.#;s#server 3.#\#server 3.#'  /etc/chrony.conf
systemctl restart chronyd
#########################################################

#########################################################
#network config
sed -i  "s/ONBOOT=no/ONBOOT=yes/;s/BOOTPROTO=dhcp/BOOTPROTO=static/;/ONBOOT/a\IPADDR=$HOST_IP\nPREFIX=$HOST_NETMASK\nGATEWAY=$HOST_GATEWAY\nDNS1=$HOST_DNS"  /etc/sysconfig/network-scripts/ifcfg-$NET_INETERFACE_NAME
systemctl restart network
#########################################################
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

灵石县| 顺平县| 连州市| 湖北省| 秦皇岛市| 古蔺县| 宁城县| 南岸区| 那坡县| 崇州市| 阳东县| 汉川市| 泌阳县| 洛宁县| 蕲春县| 友谊县| 高雄市| 利津县| 灵石县| 高青县| 岐山县| 诸暨市| 新津县| 门源| 清水河县| 临邑县| 娱乐| 二连浩特市| 额敏县| 淳安县| 象州县| 佛山市| 竹溪县| 自贡市| 德格县| 仁怀市| 四川省| 仙游县| 庄河市| 边坝县| 六安市|