#!/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 ...
随机推荐
- HDU 1272小希的迷宫(裸并查集,要判断是否构成环,是否是连通图)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1272 小希的迷宫 Time Limit: 2000/1000 MS (Java/Others) ...
- Unity Loding白屏
卡loading很多时候是由于网络原因造成的,你可以尝试断网,进入离线模式.如果使用VPN也可以先关闭使用,部分Vpn的配置也会导致该问题出现.最后可以查看一下防火墙的设置.
- 国产开源JavaWeb应用程序框架——XWAF(1)
XWAF是一个基于java反射和Servlet 技术的国产开源Web应用程序框架.其英文全称为“eXtensible Web Application Framework”,意即“可扩展的网络应用程序框 ...
- Java中的IO流(五)
上一篇<Java中的IO流(四)>记录了一下Properties类,此类不属于IO流,它属于集合框架.接下来说一下IO流中的其它流 一,打印流PrintStream PrintStream ...
- DBA手记(学习)-library cache pin
select sid,event,p1raw from v$session_wait where event like 'library cache pin%'; select sql_text fr ...
- 『ACM C++』 PTA 天梯赛练习集L1 | 025-026
满课一天,做25的时候还疯狂WA,进度可以说是很慢了 哭泣 ------------------------------------------------L1-025---------------- ...
- vue-cli3 创建选项选择
1.创建新项目: vue create hello-world 2.选择配置 3.自定义选择配置,需要什么就选什么 4. 是否使用带历史纪录的路由,这里一般是Y 5.预编译器选择什么 6.eslint ...
- sign
sign字段构成:登录类型(2Bytes) + userid(不定长,最长10Bytes,用户id或设备id) + time(10Bytes) + token(32Bytes).其中:token = ...
- Asp.Ner Core定时任务
AspNet Core定时任务 纪念人类首张黑洞照片发布 第一种方式BackgroundService 基于后台服务类BackgroundService实现,类所在命名空间Microsoft.Exte ...
- 汇编程序返回dos
汇编程序返回dos有两种方式: 1. push ds sub ax,ax push ax ... ret 作用:一开始ds是指向psp的,在psp:0000处放着int 20h ...