#!/bin/bash
release=`grep -o "\<[[:digit:]]\>" /etc/centos-release | head -` # 、shutdown selinux
[ -e "/etc/selinux/config" ] && sed -i 's@^SELINUX=.*@SELINUX=disabled@' /etc/selinux/config
setenforce &> /dev/null # 2、shudown firewall
[ $release = "" ] && service iptables stop && chkconfig iptables off
[ $release = "" ] && systemctl stop firewalld && systemctl disable firewalld # 3、set own alias
echo "alias cdnet='cd /etc/sysconfig/network-scripts/'" >> /etc/profile.d/myalias.sh
source /etc/profile.d/myalias.sh # 4、set evironment "PS1 color"
# 30:black, 31:red, 32:green, 33:yellow, 34:blue, 35:pink, 36:cyan, 37:white
ps1_color=
echo 'PS1="\[\e[1;'''${ps1_color}'''m\][\u@\h \w]\$\[\e[0m\]"' >> /etc/profile.d/evironment.sh
source /etc/profile.d/myalias.sh # 5、set aliyun repo
rpm -q wget &> /dev/null || yum -y install wget
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[ $release = "" ] && wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
[ $release = "" ] && wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum makecache &> /dev/null

注意:请使用source命令执行此脚本。为什么?

  1、source执行某个脚本,会影响当前bash的参数,所以要调用某些变量的时候可以采用此方法

  2、/bin/bash执行某个脚本,脚本会在子shell中运行,当前bash参数

CentOS初始化脚本(未完)的更多相关文章

  1. centos初始化脚本

    centos初始化脚本 添加IP.主机名.挂载/dev/sdb1磁盘 #!/bin/bash # ip=$ hostname=$ if [ -z $ip ] || [ -z $hostname ]; ...

  2. CentOS 初始化脚本

    #!/bin/bash # curl https://yiyingcanfeng.github.io/centos-init.sh | bash # 可选参数base kernel python ph ...

  3. centos7初始化脚本(转)

    #!/bin/bash # 描述: CentOS 初始化脚本 # 加载配置文件 if [ -n "${1}" ];then /bin/} fi # 可接受配置(shell 变量格式 ...

  4. centos 7 初始化脚本

    #!/bin/bash # 时间: 2018-11-21 # 作者: HuYuan # 描述: CentOS 7 初始化脚本 # 加载配置文件 if [ -n "${1}" ];t ...

  5. bash-1 初始化CentOS系统的初始化脚本

    初始化CentOS系统的初始化脚本 #!/bin/bash # #******************************************************************* ...

  6. Go web编程学习笔记——未完待续

    1. 1).GOPATH设置 先设置自己的GOPATH,可以在本机中运行$PATH进行查看: userdeMacBook-Pro:~ user$ $GOPATH -bash: /Users/user/ ...

  7. Centos7初始化脚本

    今天分享一个自己写的一个初始化的小脚本. 编写初始化系统要考虑到系统的版本问题,现在用的比较多的就是centos6和centos7,所以首先要判断一下系统的版本. cat /etc/redhat-re ...

  8. 构建Linux根文件系统(未完待续)

          所谓制作根文件系统, 就是创建各种目录, 并且在里面创建各种文件. 比如在/bin ./sbin 目录下存放各种可执行程序, 在/etc 目录下存放配置文件, 在/lib 目录下存放库文件 ...

  9. javascript有用小功能总结(未完待续)

    1)javascript让页面标题滚动效果 代码如下: <title>您好,欢迎访问我的博客</title> <script type="text/javasc ...

随机推荐

  1. JS中的解构

    先看看数组解构: function fn(){ return [1,2,3]; } var [a,b,c] = fn(); console.log(a,b,c); // 1 2 3 var [d,,f ...

  2. 数据库中的null,踩坑笔记

    问题来源:查询表中,complete_type 不为2的数据. 我的想法:select * from 表名 where complete_type != '2'  (除了第2条,全部显示,没问题呀) ...

  3. 【C语言】编写程序,输出以下图形

    编写程序输出以下图形: * ** *** **** ***** 代码: #include <stdio.h> int main() { int i, j; ; i <= ; i++) ...

  4. java泛型demo

    1.泛型类 public class Dog<T> { private T age; public Dog(T age) { this.age = age; } public T getA ...

  5. jQuery中$("input")与$(":input")的区别

    $("input")表示获取页面所有的input元素 $(":input")选取表单中所有的input,select 和 button元素

  6. Linux - Windows下的Linux工具

    1. putty, 2. winscp(可下载文件) 3. SecureCRT

  7. Educational Codeforces Round 82 B. National Project

    Your company was appointed to lay new asphalt on the highway of length nn. You know that every day y ...

  8. (转)Oracle数据库备份与恢复总结

    http://blog.csdn.net/xyz846/article/details/6437963 http://blog.csdn.net/hollboy/article/details/867 ...

  9. Linux 下忘记mysql 密码

    ERROR (): Access denied for user 'root'@'localhost' (using password: YES). 一.停止 mysql 数据库 /etc/init. ...

  10. ➡️➡️➡️IELTS reading by Simon on Bili

    高分必备 雅思考官Simon手把手教你做阅读 p1 https://www.bilibili.com/video/av40131278?p=2 p2 https://www.bilibili.com/ ...