#!/sbin/bash
#
#initial envirment
#variable define
IPADDR=192.168.0.12
NETMASK=255.255.255.0
HOSTNAME=station.domain12
DOMAIN='.example.com'
SERVER=instructor$DOMAIN
NAME_SERVER=192.168.0.1
GATEWAY=192.168.0.1
#Checking Selinux status
if [[ $(getenforce) == Disabled ]]
then
echo "Selinus is disabled, no aciton is requird!!"
else
echo > /etc/sysconfig/selinux
echo "SELINUX=disabled" >>/etc/sysconfig/selinux
echo "SELINUXTYPE=targeted" >>/etc/sysconfig/selinux
echo "Selinux status has been chenged successful!"
fi
#Setup ip address and dns
DEVICE=eth0
IFPATH=/etc/sysconfig/network-scripts
cat $IFPATH/ifcfg-$DEVICE >> /tmp/ifcfg-$DEVICE.bak
echo > $IFPATH/ifcfg-$DEVICE
echo "DEVICE=$DEVICE" >>$IFPATH/ifcfg-$DEVICE
echo "BOOTPROTO=static" >>$IFPATH/ifcfg-$DEVICE
echo "IPADDR=$IPADDR" >>$IFPATH/ifcfg-$DEVICE
echo "NETMASK=$NATMASK" >>$IFPATH/ifcfg-$DEVICE
echo "GATEWAY=$GATEWAY" >>$IFPATH/ifcfg-$DEVICE
echo "DNS1=$NAME_SERVER" >>$IFPATH/ifcfg-$DEVICE
echo "ONBOOT=yes" >>$IFPATH/ifcfg-$DEVICE
chkconfig NetworkManager off
service NetworkManager stop
service network restart
#hostname setup
NETWORK_FILE=/etc/sysconfig/network
echo > $NETWORK_FILE
echo "NETWORKING=yes" >> $NETWORK_FILE
echo "HOSTNANE=$HOSTNAME$DOMAIN" >> $NETWORK_FILE
echo "192.168.0.12 $HOSTNAME$DOMAIN" >> /etc/hosts
hostname $HOSTNAME$DOMAIN
echo "Hostname change succesfull, you may need to religin to aviod it."
#Add users
groupadd admin
useradd -G admin harry
useradd -G admin natasha
useradd -s /sbin/nologin tom
#setpassword for users
echo "harry"|passwd harry --stdin
echo "natasha"|passwd natasha --stdin
echo "User and passwd setup successful."
#Create dir for group admin with sepecial permssion.
mkdir /home/admins
chgrp admin /home/admins
chmod g+ws /home/admins
chmod o-rx /home/admins
#Create cron task for root
echo "23 14 * * * /bin/echo hello" > /root/cron.txt
crontab -e <<EOF
:r /root/cron.txt
:wq
EOF
chkconfig crond on
crontab -l
#
#find file and copy to another folder
mkdir /opt/dir
find / -user harry -exec cp -a {} /opt/dir \;
ls -l /opt/dir
#find key word from file and output to another one.
grep root /etc/passwd >/tmp/testfile
#add more swaps for linux
fdisk -cu /dev/sda <<EOF
n
e
4
+2G
n
l
t
5
82
p
wq
EOF
partx -a /dev/sda
mkswap /dev/sda5
echo "$(blkid /dev/sda5|awk '{print $2}') swap swap defauts 0 0" >> /etc/fstab
swapon -a
#User file swap, please un comment blow
#dd if=/dev/zero of=/tmp/swap.img bs=1M count=2000
#mkswap /tmp/swap.img
#echo "$(blkid /tmp/swap.img|awk '{print $2}') swap swap defauts 0 0" >> /etc/fstab
#swapon -a
swapon -s
free -m
#create with specified id and passwd
useradd -u 1234 alex
echo "alex111" |passwd alex --stdin
#Install ftpserver
REPO=/etc/yum.repos.d/rhel6.repo
echo "[Base]" > $REPO
echo "name=base" >> $REPO
echo "baseurl=http://$SERVER/rhel6" >> $REPO
echo "enabled=1" >> $REPO
echo "gpgcheck=0" >> $REPO
yum makecache
yum install vsftpd -y
chkconfig vsftpd on
service vsftpd start
#setup a simple http server
yum install httpd -y
chkconfig httpd on
cd /var/www/html
wget http://$SERVER/pub/example.html
mv example.html index.html
service httpd restart
#LDAP with autofs
yum groupinstall 'Directory Client' -y
service ntpd stop
ntpdate $SERVER
#cat /root/ntpconf.txt >/etc/ntp.conf
echo "$SERVER iburst">>/etc/ntp.conf
chkconfig ntpd on
service ntpd restart
vi /etc/sysconfig/authconfig <<EOF
:%s/USERLDAPAUTH=no/USERLDAPAUTH=yes/g
:wq
EOF
echo "URI ldap://$SERVER/" >/etc/openldap/ldap.conf
echo "BASE dc=example, dc=com" >>/etc/openldap/ldap.conf
echo "TLS_CACERTDIR /etc/openldap/cacerts" >> /etc/openldap/ldap.conf
cd /etc/openldap/cacerts
wget http://$SERVER/certs/cacert.pem
#cat /root/sssd.txt > /etc/sssd/sssd.conf
#service start sssd
authconfig --enableldap --enableldapauth --enablemkhomedir --ldapserver=instructor.example.com --ldapbasedn="dc=example,dc=com" --update
yum install autofs -y
echo "/lhome /etc/auto.ldap" >> /etc/auto.master
echo "* -fstype=nfs,rw $SERVER:/lhome/&"> /etc/auto.ldap
yum install nfs-utils -y
chkconfig autofs on
service autofs restart
- 在centos 7.0上利用yum一键安装mono
首先我们需要先配置一下yum源中mono的引用说明: 第一步: vi /etc/yum.repos.d/mono.repo 第二步:在刚打开的文件中编辑如下内容 [mono]name=monobase ...
- zabbix3.0 安装方法,一键实现短信、电话、微信、APP 告警
引言 免费开源监控工具 Zabbix 因其强大的监控功能得到各大互联网公司的广泛认可,具体功能不再详细介绍,在之前发布的 Zabbix 2.4.1 安装及微信短信提醒已经做了详细介绍,本篇主要对 Za ...
- destoon7.0后台栏目分类一键获取所有栏目拼音目录
近期研究DT,从DT4.0一直研究到DT7.0,总算也有些心得.最近重新开发设计了一个信息资讯站点:http://www.xuetong365.com/ 废话不多说,上教程 用于DESTOON7.0系 ...
- [Oracle/SQL]找出id为0的科目考试成绩及格的学生名单的四种等效SQL语句
本文是受网文 <一次非常有意思的SQL优化经历:从30248.271s到0.001s>启发而产生的. 网文没讲创建表的数据过程,我帮他给出. 创建科目表及数据: CREATE TABLE ...
- RHCE7.0练习题汇总[转]
RHCE7.0练习题汇总38 RHCSA部分 关于密码破解,在上午的考试中需要我们自己安装图形化界面和破解root密码,root的密码按照题目的要求来进行修改.可以使用单用户模式或者使用上课讲的re. ...
- PKUSC 模拟赛 day2 上午总结
今天上午考得不是很好,主要还是自己太弱QAQ 开场第一题给的图和题意不符,搞了半天才知道原来是走日字形的 然后BFS即可 #include<cstdio> #include<cstr ...
- 云数据库 MySQL 8.0 重磅发布,更适合企业使用场景的RDS数据库
点击订阅新品发布会! 新产品.新版本.新技术.新功能.价格调整,评论在下方,下期更新!关注更多内容,了解更多 最新发布 云数据库MySQL 8.0 升级发布会 2019年5月29日15时,阿里云云数据 ...
- 软媒魔方 v6.2.1.0 绿色纯净版及经典版
软媒魔方,最好用的 Windows 系统增强软件!从最早的优化大师发展为一款系统超级增强套装,自动化.智能化解决各种电脑问题.软媒魔方,全新一代Windows系统增强辅助工具,智能+专业双操控模式,系 ...
- [转载]在线考试javaScript倒计时
<script type="text/javascript"> /* ================== hi.baidu.com/coolinc === */ va ...
随机推荐
- Vue指令 常见的几个内置指令
1.v-if指令:判断指令,根据表达式值得真假来插入或删除相应的值. 2.v-show指令:条件渲染指令,无论返回的布尔值是true还是false,元素都会存在在html中,只是false的元素会隐藏 ...
- Web框架——XWAF的代码结构和运行机制(4)
XWAF是一套基于Servlet和java反射技术的Web应用程序框架,它利用Servlet运行机制在服务器上加载和运行,接管客户端请求,依靠ServletRequest对象获取用户请求信息,使用Se ...
- 1.高并发教程-基础篇-之nginx负载均衡的搭建
温馨提示:请不要盲目的进行横向扩展,优先考虑对单台服务器的性能优化,只有单台服务器的性能达到最优化之后,集群才会被最大的发挥作用. 一.架构图: 服务器准备:3台,ubuntu16.04系统maste ...
- JAVA中的一些内置方法
Math 函数: Math.E //自然常数e Math.abs(12.3); //返回该值的绝对值 Math.ceil(12.3); //向上取整 Math.floor(12.3); //向下取整 ...
- docker-maven-plugin 完全免Dockerfile 文件
# DockerSpringBootPlugin docker-maven-plugin 完全免Dockerfile 文件 使用docker-maven-plugin 进行完全免 Dockerfile ...
- redis学习笔记(三)
Spring data redis: 要求: Redis 版本 > 2.6 与 Lettuce 或 Jedis 集成,两种java开源Redis库. Spring redis主要做的两件事: 连 ...
- Hadoop(12)-MapReduce框架原理-Hadoop序列化和源码追踪
1.什么是序列化 2.为什么要序列化 3.为什么不用Java的序列化 4.自定义bean对象实现序列化接口(Writable) 在企业开发中往往常用的基本序列化类型不能满足所有需求,比如在Hadoop ...
- JVM类加载机制概述
首先类加载在整个体系结构的哪一个环节呢?见红色圈住的部分. 类加载器分为那几个过程呢?五个过程 加载 根据类的全限定名(简单理解为类的绝对路径,见附录),找到指定的字节码文件,并在内存中生产一个jav ...
- 原生js三级联动
<!DOCTYPE html> <html lang="en"> <head> <title> 三级联动 </title> ...
- GNU Radio在SDR领域的应用
1 Software Defined Radio 软件无线电(Software Defined Radio,SDR)是一种实现无线通信的新概念和体制.其中以往只能在硬件中实现的组件(例如混频器,滤波器 ...