开机自启

Docker 组件部署自启 (Centos 7)

  • 极速安装适用 (CentOS 7)
  • 一体化部署适用 (CentOS 7)
  1. # Jumpserver
  2. $ vi /usr/lib/systemd/system/jms.service
  3. [Unit]
  4. Description=jms
  5. After=network.target mariadb.service redis.service docker.service
  6. Wants=mariadb.service redis.service docker.service
  7. [Service]
  8. Type=forking
  9. Environment="PATH=/opt/py3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
  10. ExecStart=/opt/jumpserver/jms start all -d
  11. ExecReload=
  12. ExecStop=/opt/jumpserver/jms stop
  13. [Install]
  14. WantedBy=multi-user.target
  1. # 启动
  2. $ vi /opt/start_jms.sh
  3. #!/bin/bash
  4. set -e
  5. export LANG=zh_CN.UTF-8
  6. systemctl start jms
  7. docker start jms_coco
  8. docker start jms_guacamole
  9. exit 0
  1. # 停止
  2. $ vi /opt/stop_jms.sh
  3. #!/bin/bash
  4. set -e
  5. export LANG=zh_CN.UTF-8
  6. docker stop jms_coco
  7. docker stop jms_guacamole
  8. systemctl stop jms
  9. exit 0
  1. # 写入 rc.local
  2. $ chmod +x /etc/rc.d/rc.local
  3. $ if [ "$(cat /etc/rc.local | grep start_jms.sh)" == "" ]; then echo "sh /opt/start_jms.sh" >> /etc/rc.local; fi

Docker 组件部署自启 (Ubuntu 18)

  • 一体化部署适用 (Ubuntu 18)
  1. # Jumpserver
  2. $ vi /lib/systemd/system/jms.service
  3. [Unit]
  4. Description=jms
  5. After=network.target mysql.service redis-server.service docker.service
  6. Wants=mysql.service redis-server.service docker.service
  7. [Service]
  8. Type=forking
  9. Environment="PATH=/opt/py3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
  10. ExecStart=/opt/jumpserver/jms start all -d
  11. ExecReload=
  12. ExecStop=/opt/jumpserver/jms stop
  13. [Install]
  14. WantedBy=multi-user.target
  1. # 启动
  2. $ vi /opt/start_jms.sh
  3. #!/bin/bash
  4. set -e
  5. export LANG=zh_CN.utf8
  6. systemctl start jms
  7. docker start jms_coco
  8. docker start jms_guacamole
  9. exit 0
  1. # 停止
  2. $ vi /opt/stop_jms.sh
  3. #!/bin/bash
  4. set -e
  5. export LANG=zh_CN.utf8
  6. docker stop jms_coco
  7. docker stop jms_guacamole
  8. systemctl stop jms
  9. exit 0
  1. # 写入 rc.local
  2. $ chmod +x /etc/rc.d/rc.local
  3. $ if [ "$(cat /etc/rc.local | grep start_jms.sh)" == "" ]; then echo "sh /opt/start_jms.sh" >> /etc/rc.local; fi