Skip to content

Latest commit

 

History

History
255 lines (163 loc) · 5.43 KB

README.md

File metadata and controls

255 lines (163 loc) · 5.43 KB

Linux Control Panel

bilibili 演示

Build Status

1️⃣ How To Use

  1. 配置
sh script/install_*

virtualenv venv
venv/bin/python main.py
  1. config目录下新建oss.yaml

    oss:
      Auth:
        AccessKeyId: XXXXXXXXXX
        AccessKeySecret: XXXXXXXXXXX
      Bucket:
        EndPoint: XXXXXXXXXXX
        BucketName: XXXXXXXXXXXX

2️⃣ 功能介绍

2.1 资源监控

image-20200525205201420

2.2 进程管理(每秒刷新)

image-20200525205235288

2.3 容器管理

image-20200525205309309

2.4 FTP服务

image-20200525205526117

2.5 文件管理

image-20200525205554646

2.6 网站管理

image-20200525210110429

image-20200525210121127

image-20200525210138367

image-20200525210152084

2.7 定时任务

image-20200525210249706

image-20200525210550651

3️⃣ 后端功能的实现

3.1 系统管理

3.1.1 DNS设置

vim /etc/resolvconf/resolv.conf.d/base

image-20200509104046360

3.1.2 用户管理

  1. 创建user

    useradd -m chunibyo
    # -m 创建/home目录
  2. 设置user密码

    passwd chunibyo
  3. 删除user

    userdel chunibyo
  4. 创建group

    groupadd test_group
  5. 删除group

    groupdel test_group
  6. 添加user到group

    usermod -G test_group chunibyo
  7. 删除user从group

    gpasswd -d chunibyo test_group

3.2 docker

docker run --name some-mysql --restart=always -e MYSQL_ROOT_PASSWORD=foo -d mysql:latest

docker run --name some-nginx --restart=unless-stopped -d nginx

docker run --name some-redis --restart=unless-stopped  -d redis

3.3 网络安全

  1. 添加拒绝8888端口的tcp连接

    sudo iptables -t filter -A INPUT -j DROP -p tcp --dport 8888

    image-20200521151342244

  2. 删除拒绝8888端口的tcp连接

4️⃣ ​DevOps工作流

软件工程综合实习

  1. MySQL建库

    create database sonarqube character set utf8 collate utf8_general_ci;
  2. 建立 sonar 用户(因为mysql在容器里面并且没有开放端口, 所以直接监听公网最方便)

     create user 'sonar'@'%' identified by 'foo';
     
     grant all privileges on sonar.* to 'sonar'@'%' ;
     
     flush privileges;
  3. 安装sonar

  4. 打包成service

    /lib/systemd/system/sonar.service
    
    [Unit]
    Description=SonarQube service
    After=syslog.target network.target
    
    [Service]
    Type=forking
    
    ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
    ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
    
    User=sonar
    Group=sonar
    Restart=always
    
    LimitNOFILE=65536
    LimitNPROC=4096
    
    
    [Install]
    WantedBy=multi-user.target
    

    image-20200516100948576

4.2 Ansible

apt仓库默认安装

---
- hosts: cugergz.chunibyo.xyz
  vars:
    repo_folder: /root/Panel
  remote_user: root
  tasks:

    - name: "Create directory if not exists"
      file:
        path: "{{ repo_folder }}"
        state: directory
        mode: 0755
        group: root
        owner: root

    - name: kill old process
      shell: ps aux | grep main.p[y] | awk '{print $2}' | xargs kill
      ignore_errors: true

    - name: clone repository
      git:
        repo: https://github.com/chunibyo-wly/LinuxControlPanel.git
        dest: "{{ repo_folder }}"
        update: yes
        force: yes

    - name: create python virtualenv
      pip:
        requirements: "{{ repo_folder }}/requirements.txt"
        virtualenv: "{{ repo_folder }}/venv"
        virtualenv_command: /usr/bin/python3 -m venv

    - name: install ftp
      shell: "sh {{ repo_folder }}/script/install_ftp.sh"

    - name: install nginx
      shell: "sh {{ repo_folder }}/script/install_nginx.sh"

    - name: install cron
      shell: "sh {{ repo_folder }}/script/install_crontab.sh"

    - name: create database
      shell: "cd {{ repo_folder }} && sudo venv/bin/python db/init.py"

    - name: start server
      shell: "cd {{ repo_folder }} && nohup sudo {{ repo_folder }}/venv/bin/python main.py > /tmp/LinuxControlPanel.log 2>&1 &"