#!/bin/bash
#
#*********************************************************
#Author: ez4cyka
#QQ: NULL
#Date: 2022-10-06
#FileName: reset.sh
#URL: https://www.google.com
#Description: 请在root 权限下运行该脚本!!!!!
#Copyright: 2022 All rights reserved
#********************************************************
disable_selinux(){
#配置文件在/etc/selinux/config
# awk '{sub(/^SELINUX=.*/,"SELINUX=disabled");print > "/etc/selinux/config"}' /etc/selinux/config #awk改法,呵呵
sed -ri "s|(^SELINUX=)(.*)|\1disabled|" /etc/selinux/config
echo "SELINUX已禁用,重启后才生效"
}
disable_firewall(){
systemctl disable --now firewalld &>/dev/null
echo "防火墙已经禁用"
}
set_ps1(){
echo PS1="\[\e[1;32m\][\t \[\e[1;33m\]\u\[\e[35m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$" > /etc/profile.d/reset.sh
echo "提示符已修改成功,请重新登陆"
}
set_eth(){
sed -ri 's|(^.*LINUX.*)"$|\1 net.ifnames=0"|' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg &> /dev/null
echo "网络名称已修改成功,请重新启动才能生效"
}
set_ubuntu_mirror(){
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
}
set_ubuntu_root(){
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/#Port 22/Port 22/' /etc/ssh/sshd_config
}
MENU='
1.禁用SELINUX
2.禁用防火墙
3.修改PS1
4.修改网卡名称
5.一键全改(1-4)
6.修改Ubuntu镜像源
7.修改ubuntu_root用户远程登录
8.退出
'
PS3="请选择"
select M in $MENU ;do
case $REPLY in
1) disable_selinux
;;
2) disable_firewall
;;
3) set_ps1
;;
4) set_eth
;;
5) disable_selinux
disable_firewall
set_ps1
set_eth
;;
6) set_ubuntu_mirror
;;
7) set_ubuntu_root
;;
8)
break
;;
*)
错误选项
;;
esac
done