开机自启

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.  
  8. [Service]
  9. Type=forking
  10. Environment="PATH=/opt/py3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
  11. ExecStart=/opt/jumpserver/jms start all -d
  12. ExecReload=
  13. ExecStop=/opt/jumpserver/jms stop
  14.  
  15. [Install]
  16. WantedBy=multi-user.target
  1. # 启动
  2. $ vi /opt/start_jms.sh
  3.  
  4. #!/bin/bash
  5. set -e
  6.  
  7. export LANG=zh_CN.UTF-8
  8.  
  9. systemctl start jms
  10. docker start jms_coco
  11. docker start jms_guacamole
  12.  
  13. exit 0
  1. # 停止
  2. $ vi /opt/stop_jms.sh
  3.  
  4. #!/bin/bash
  5. set -e
  6.  
  7. export LANG=zh_CN.UTF-8
  8.  
  9. docker stop jms_coco
  10. docker stop jms_guacamole
  11. systemctl stop jms
  12.  
  13. 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.  
  8. [Service]
  9. Type=forking
  10. Environment="PATH=/opt/py3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
  11. ExecStart=/opt/jumpserver/jms start all -d
  12. ExecReload=
  13. ExecStop=/opt/jumpserver/jms stop
  14.  
  15. [Install]
  16. WantedBy=multi-user.target
  1. # 启动
  2. $ vi /opt/start_jms.sh
  3.  
  4. #!/bin/bash
  5. set -e
  6.  
  7. export LANG=zh_CN.utf8
  8.  
  9. systemctl start jms
  10. docker start jms_coco
  11. docker start jms_guacamole
  12.  
  13. exit 0
  1. # 停止
  2. $ vi /opt/stop_jms.sh
  3.  
  4. #!/bin/bash
  5. set -e
  6.  
  7. export LANG=zh_CN.utf8
  8.  
  9. docker stop jms_coco
  10. docker stop jms_guacamole
  11. systemctl stop jms
  12.  
  13. 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