JumpServer脚本

这里需要安装阿里的yum源和epel源并解压:

epel源地址https://mirrors.tuna.tsinghua.edu.cn/epel//

安装阿里互联网yum仓库

[root@192 ~]# cd /etc/yum.repos.d/

[root@192 yum.repos.d]# wget -O /etc/yum.repos.d/aliyun.repo https://mirrors.aliyum.com/repo/Centos-7.repo

[root@192 ~]# rz -E

这个就是epel源:epel-release-latest-7.noarch.rpm

把包解压到repos.d下

r[root@192 yum.repos.d]#rpm -ivh epel-release-7-9.noarch.rpm

[root@192 yum.repos.d]# ls

aliyun.repo       CentOS-Debuginfo.repo  CentOS-Vault.repo            epel-testing.repo

bak               CentOS-fasttrack.repo  docker-ce.repo               nginx.repo

CentOS-Base.repo  CentOS-Media.repo      epel-release-7-9.noarch.rpm

CentOS-CR.repo    CentOS-Sources.repo    epel.repo

[root@192 ~]# vim jumpserver.sh

#!/bin/bash

echo -e "\033[31m 1. 防火墙 Selinux 设置 \033[0m" \

  && if [ "$(systemctl status firewalld | grep running)" != "" ]; then firewall-cmd --zone=public --add-port=80/tcp --permanent; firewall-cmd --zone=public --add-port=2222/tcp --permanent; firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.17.0.0/16" port protocol="tcp" port="8080" accept"; firewall-cmd --reload; fi \

  && if [ "$(getenforce)" != "Disabled" ]; then setsebool -P httpd_can_network_connect 1; fi

 

echo -e "\033[31m 2. 部署环境 \033[0m" \

  && yum update -y \

  && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \

  && yum -y install kde-l10n-Chinese \

  && localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8 \

  && export LC_ALL=zh_CN.UTF-8 \

  && echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf \

  && yum -y install wget gcc epel-release git \

  && yum install -y yum-utils device-mapper-persistent-data lvm2 \

  && yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo \

  && yum makecache fast \

  && rpm --import https://mirrors.aliyun.com/docker-ce/linux/centos/gpg \

  && echo -e "[nginx-stable]\nname=nginx stable repo\nbaseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/\ngpgcheck=1\nenabled=1\ngpgkey=https://nginx.org/keys/nginx_signing.key" > /etc/yum.repos.d/nginx.repo \

  && rpm --import https://nginx.org/keys/nginx_signing.key \

  && yum -y install redis mariadb mariadb-devel mariadb-server nginx docker-ce \

  && systemctl enable redis mariadb nginx docker \

  && systemctl start redis mariadb \

  && yum -y install python36 python36-devel \

  && python3.6 -m venv /opt/py3

 

echo -e "\033[31m 3. 下载组件 \033[0m" \

  && cd /opt \

  && if [ ! -d "/opt/jumpserver" ]; then git clone --depth=1 https://github.com/jumpserver/jumpserver.git; fi \

  && if [ ! -f "/opt/luna.tar.gz" ]; then wget https://demo.jumpserver.org/download/luna/1.4.9/luna.tar.gz; tar xf luna.tar.gz; chown -R root:root luna; fi \

  && yum -y install $(cat /opt/jumpserver/requirements/rpm_requirements.txt) \

  && source /opt/py3/bin/activate \

  && pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/ \

  && pip install -r /opt/jumpserver/requirements/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ \

  && curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io \

  && systemctl restart docker \

  && docker pull jumpserver/jms_coco:1.4.9 \

  && docker pull jumpserver/jms_guacamole:1.4.9 \

  && rm -rf /etc/nginx/conf.d/default.conf \

  && curl -o /etc/nginx/conf.d/jumpserver.conf https://demo.jumpserver.org/download/nginx/conf.d/jumpserver.conf

 

echo -e "\033[31m 4. 处理配置文件 \033[0m" \

  && if [ "$DB_PASSWORD" = "" ]; then DB_PASSWORD=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24`; fi \

  && if [ "$SECRET_KEY" = "" ]; then SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`; echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc; fi \

  && if [ "$BOOTSTRAP_TOKEN" = "" ]; then BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`; echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc; fi \

  && if [ "$Server_IP" = "" ]; then Server_IP=`ip addr | grep inet | egrep -v '(127.0.0.1|inet6|docker)' | awk '{print $2}' | tr -d "addr:" | head -n 1 | cut -d / -f1`; fi \

  && if [ ! -d "/var/lib/mysql/jumpserver" ]; then mysql -uroot -e "create database jumpserver default charset 'utf8';grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by '$DB_PASSWORD';flush privileges;"; fi \

  && if [ ! -f "/opt/jumpserver/config.yml" ]; then cp /opt/jumpserver/config_example.yml /opt/jumpserver/config.yml; sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /opt/jumpserver/config.yml; sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/jumpserver/config.yml; sed -i "s/# DEBUG: true/DEBUG: false/g" /opt/jumpserver/config.yml; sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /opt/jumpserver/config.yml; sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /opt/jumpserver/config.yml; sed -i "s/DB_PASSWORD: /DB_PASSWORD: $DB_PASSWORD/g" /opt/jumpserver/config.yml; fi

 

echo -e "\033[31m 5. 启动 Jumpserver \033[0m" \

  && systemctl start nginx \

  && cd /opt/jumpserver \

  && ./jms start all -d \

  && docker run --name jms_coco -d -p 2222:2222 -p 5000:5000 -e CORE_HOST=http://$Server_IP:8080 -e BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN jumpserver/jms_coco:1.4.9 \

  && docker run --name jms_guacamole -d -p 8081:8081 -e JUMPSERVER_SERVER=http://$Server_IP:8080 -e BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN jumpserver/jms_guacamole:1.4.9 \

  && echo -e "\033[31m 你的数据库密码是 $DB_PASSWORD \033[0m" \

  && echo -e "\033[31m 你的SECRET_KEY是 $SECRET_KEY \033[0m" \

  && echo -e "\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m" \

  && echo -e "\033[31m 你的服务器IP是 $Server_IP \033[0m" \

  && echo -e "\033[31m 请打开浏览器访问 http://$Server_IP 用户名:admin 密码:admin \033[0m"

 

脚本执行后会给出以下提示,请保存

你的数据库密码是 ep40Jo1ePuGr6E0syeILIv8U

你的SECRET_KEY是 2iVyw2k3t6gSzVwM8dc3WWOrygdRODAbpyv90a3T5056bM9x00

你的BOOTSTRAP_TOKEN是 fk0G7iITiSUIfMPI

你的服务器IP是 192.168.0.110

请打开浏览器访问 http://192.168.0.110 用户名:admin 密码:admin

配置自启

启动停止的脚本在 /opt 目录下, 如果自启失败可以手动启动

Centos7自动式脚本搭建jumpserver的更多相关文章

  1. SQL Server镜像自动生成脚本

    SQL Server镜像自动生成脚本 镜像的搭建非常繁琐,花了一点时间写了这个脚本,方便大家搭建镜像 执行完这个镜像脚本之后,最好在每台机器都绑定一下hosts文件,不然的话,镜像可能会不work 1 ...

  2. 企业IT管理员IE11升级指南【15】—— 代理自动配置脚本

    企业IT管理员IE11升级指南 系列: [1]—— Internet Explorer 11增强保护模式 (EPM) 介绍 [2]—— Internet Explorer 11 对Adobe Flas ...

  3. hive 中间会话临时文件自动清理脚本

    hive在运行过程中,我们经常会发现 hdfs /tmp/hive/hive or hdfs 目录占用空间巨大,我这里已经清理过了所以,相对较小.但是初次使用hive的用户,一定会发现 随着时间的推移 ...

  4. centos7下git服务器端搭建

    git的安装: yum 源仓库里的 Git 版本更新不及时,最新版本的 Git 是 1.8.3.1,但是官方最新版本已经到了 2.9.2.想要安装最新版本的的 Git,只能下载源码进行安装. 1. 查 ...

  5. centos7下git服务器端搭建(转)

    git的安装: yum 源仓库里的 Git 版本更新不及时,最新版本的 Git 是 1.8.3.1,但是官方最新版本已经到了 2.9.2.想要安装最新版本的的 Git,只能下载源码进行安装. 1. 查 ...

  6. Oracle自动备份脚本的实现

    问题描述: Oracle自动备份脚本的实现. 错误提示1: Message file RMAN.msb not found Verify that Oracle_HOME is set properl ...

  7. React Native开发中自动打包脚本

    React Native开发中自动打包脚本 在日常的RN开发中,我们避免不了需要将我们编写的代码编译成安装包,然后生成二维码,供需要测试的人员扫描下载.但是对于非原生的开发人员来说,可能不知如何使用X ...

  8. MVC的验证(模型注解和非侵入式脚本的结合使用) .Net中初探Redis .net通过代码发送邮件 Log4net (Log for .net) 使用GDI技术创建ASP.NET验证码 Razor模板引擎 (RazorEngine) .Net程序员应该掌握的正则表达式

    MVC的验证(模型注解和非侵入式脚本的结合使用)   @HtmlHrlper方式创建的标签,会自动生成一些属性,其中一些属性就是关于验证 如图示例: 模型注解 通过模型注解后,MVC的验证,包括前台客 ...

  9. LAMP自动安装脚本

    #!/bin/bash # 功能描述:LAMP自动安装脚本 # 初始化 if [ "$(cat /etc/system-release | awk '{print $(NF-1)}' | a ...

随机推荐

  1. 从Linux 2.6.8内核的一个TSO/NAT bug引出的网络问题排查观点(附一个skb的优化点)

    梦中没有错与对,梦中没有恨和悔...最好闭上你的嘴.这样才算可爱...我不会说:这不公道,我不能接受.我会用朴素的文字记录点点滴滴,早上4点多起来,一气呵成最近的收获与评价,愤慨与忏悔. 四年多前的一 ...

  2. C++对象模型——Template中的名称决议方式 (第七章)

    Template中的名称决议方式 (Name Resolution within a Template) 必须可以区分下面两种意义,一种是C++ Standard所谓的"sope of th ...

  3. ES 2016+

    ES2016(ES7)新增: Array.prototype.includes Exponentiation Operator 求冥运算 ES2017 (ES8)新增: ECMAScript® 201 ...

  4. 安卓dex 文件结构简要说明

    #ifndef _DEX_FILE_HELPER_ #define _DEX_FILE_HELPER_ //此文件仅仅是起帮助作用,帮助不太了解DexFile结构的了解一下DexFile相关结构,想更 ...

  5. IE浏览器 多版本之间切换

    由于Win7系统最低支持IE8的版本,不能通过安装IE7版本来达到要求. 有一个替代方案,通过IE自带Emulation来实现,实现步骤如下: 打开现有的IE浏览器 按下F12键 切换到“Emulat ...

  6. bzoj2131: 免费的馅饼

    首先我们很容易看出是一个DP 然后容易看出是数据结构优化DP 但是这个限制条件有点鬼畜: abs(p[i]-p[j])/2<=(t[i]-t[j]) p[i]>p[j] -> t[i ...

  7. ::before和::after伪元素的使用

    :before和:after伪元素在CSS中可以被用来添加元素.加小标.清浮动等. 基本用法: p::before {} p::after {} 1.string <style type=&qu ...

  8. 利用SSL For Free工具3分钟获取Let's Encrypt免费SSL证书

    https://www.sslforfree.com/

  9. 如何为你的Go应用创建轻量级Docker镜像?

    介绍 多什么? 简单来讲,多阶段. 多阶段允许在创建Dockerfile时使用多个from,它非常有用,因为它使我们能够使用所有必需的工具构建应用程序.举个例子,首先我们使用Golang的基础镜像,然 ...

  10. Docker为什么刚运行就退出了

    引言 最近群里的好多新接触Docker的朋友,好多都遇到了相同的问题,使用 $ docker run -d ubuntu /bin/bash 运行了一个简单的容器后,然后docker ps -a 进行 ...