一个简单的shell脚本—–实现虚拟机实验环境的简单配置
2023-06-13 09:17:43 时间
亲自写过shell脚本后才发现,这玩意真是太方便了,当你想把一些琐碎的、细节性的小指令一次性来完成时,脚本无疑是最好的选择,方便、快捷,关键是真是懒人必备啊。
由于安装的centos6.5是最小化安装,且是实验环境,即安装在vmware workstations上面,在首次安装完成后,配置完IP地址的相关信息后,就做了一个初始的快照,以便下次实验完后,可以通过快照快速还原系统。
但是由于实验环境的要求,例如防火墙、SELinux、光盘挂载、yum源配置等,都是最常需要修改的选项,并且由于最小化安装,系统里并没有vim编译工
具和man手册的查询,所以导致每次还原快照后,还要处理这些琐碎的问题。为此,我就专门写了这么一个小脚本,内容并不复杂,但是也是一种学习过程,发出
来和大家一起分享一下,顺便求指教
代码: #!/bin/bash # Config some simple order when the system start # Create by phoenix # Specify the path server=/etc/init.d yum=/etc/yum.repos.d mountdir=/media/cdrom selinux=/etc/selinux/config # stop the iptabes and set it cant start when the system start $server/iptables stop /dev/null if [ "$?" = "0" ]; then chkconfig iptables off chkconfig ip6tables off echo "1# The iptables stop successfully" echo "1# The iptables stop failed" # shutdown the selinxu system setenforce 0 sed -e s/^SELINUX=enforcing/SELINUX=disabled/g $selinux $selinux.bak mv -f $selinux.bak $selinux echo "2# The selinux system is disabled" # Mount the CD-ROM mount |grep sr0 /dev/null if [ ! "$?" = "0" ]; then if [ ! -e $mountdir ]; then mkdir -p $mountdir /dev/null else mount /dev/cdrom $mountdir /dev/null echo "3# The CD-ROM is mounting successfully" echo "3# The CD-ROM is already mounted" # Config the source of yum if [ -e $yum/CentOS-Base.repo ];then mv -f $yum/CentOS-Base.repo $yum/CentOS-Base.repo.bak /dev/null echo "4# Starting config the source of yum" sleep 3 sed -e s/^enabled=0/enabled=1/g $yum/CentOS-Media.repo $yum/CentOS-Media.repo.bak mv -f $yum/CentOS-Media.repo.bak $yum/CentOS-Media.repo /dev/null yum clean all /dev/null echo "5# The source of yum configed successfully" # Modify the code of language echo "#LANG=zh_CN.UTF-8" /etc/sysconfig/i18n echo "6# The language is modify successfully" # Install the tools "VIM" and "MAN" echo "7# Starting install vim and man,please wait......" sleep 3 yum install vim man -y /dev/null # Reboot the system when all the work is done echo "######### All work is done ########" sleep 2 echo "Please wait the syatem restart......" sleep 2 init 6
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/57729.html
centosiptableslinuxshell相关文章
- 【说站】使用systemctl配置dnspod-shell实现ddns
- Fail2Ban安全配置与应用 - 高度可定制化/支持多种服务
- Shell脚本编程_shell脚本编程100例pdf
- ruoyi-vue版本(四)@PreAuthorize 注解在若依里面的作用,springsecurity 框架相关的配置
- 【Android 安装包优化】使用 lib7zr.so 动态库处理压缩文件 ( 拷贝 lib7zr.so 动态库到 Android Studio 工程 | 配置 build.gradle 构建脚本 )
- Spring Cloud Gateway环境搭建和配置(一)
- Shell脚本编程:使用shell打印九九乘法表详解程序员
- 脚本开启Linux之旅:学习Shell脚本编程(linux下的shell)
- MySQL Variables sql_log_off 数据库 参数变量解释及正确配置使用
- Filter配置多个url-pattern详解编程语言
- Linux逆向远程连接:反弹Shell技术(linux反弹shell)
- 安全保护Linux用户Shell安全的措施(linux用户shell)
- 数据使用Shell指令读取MySQL数据库(shell读取mysql)
- 使用Shell脚本操作MySQL数据库(shell连接mysql)
- 如何正确配置Oracle数据库(如何配置oracle)
- 学习Linux:掌握Shell修改技巧(linux修改shell)
- 脚本MySQL数据库定时备份之Shell脚本实现(MySQL备份shell)
- Oracle 11监听:配置实现可靠连接(oracle11监听)
- win2008 Iis7伪静态配置方法
- Linux 中最常用的Shell:为你提供便捷生活(linux常用shell)
- 七日杀游戏在Linux服务器上的安装与配置详解(七日杀linux服务器)
- 配置 MSSQL 连接服务器的步骤.(mssql 连接服务器)
- 脚本快速学习执行Linux Shell脚本的技巧(linux 执行shell)
- Linux下切换Shell的技巧:简单迅速!(linux切换shell)
- 让Oracle灵活的运行Shell脚本(oracle写shell)
- 持久化Oracle免配置持久化极简部署让人们惊喜(oracle免配置)
- 应用程序部署MySQL 配置指南(app部署mysql配置)
- Shell脚本调用Redis解决数据缓存问题(shell调redis)
- Shell实时监听Redis自动化解决方案(shell监听redis)
- 命令Shell下执行Redis命令的简单操作(shell执行redis)
- Redis集群配置出现无效情况处理(redis 集群配置无效)
- 红色的集群配置Redis集群(redis集群配置描述)