yum install epel-release -y
release=`cat /etc/redhat-release |grep release | awk -F" " '{print $4}' | awk -F"." '{print $1}'` ; echo "centos 版本为: $release "
case "$release" in
"6") echo " 当前匹配centos 版本为 6"
centos6
;;
"7") echo " 当前匹配centos 版本为 7"
yum groupinstall -y "GNOME Desktop" ##centos7 安装桌面 安装GNOME Desktop图形桌面服务
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
# 设置桌面运行模式为默认启动模式
# reboot # 重启系统或者 init 5 # 启动桌面模式
;;
"8") echo "当前匹配centos 版本为 8"
sudo dnf groupinstall "Server with GUI" -y # Gnome 是 CentOS 8 中的默认桌面环境
;;
*) echo "您的centos过于老旧,正在匹配低版本"
centos6d
;;
esac
yum install xrdp tigervnc-server -y
systemctl enable xrdp --now
systemctl status xrdp
echo "exec gnome-session" >> /etc/xrdp/xrdp.ini
systemctl restart xrdp
systemctl start firewalld
#限制防火墙
sudo firewall-cmd --add-port=3389/tcp --permanent
sudo firewall-cmd --reload
# 一键安装:wget www.eisc.cn/file/shell/centos-mstsc.sh ; sh centos-mstsc.sh
#相关链接: 升级bash 设置中文语言:https://www.eisc.cn/index.php?c=read&id=616&page=1
# ubuntu 安装桌面:https://help.aliyun.com/document_detail/59330.html