2020年系统综合实践 期末大作业

选题简介

  • 本次期末大作业完成的是利用树莓派docker构建一个私有网盘云服务,并能够使用qq方便的对网盘进行操作而无需使用网页或者app,如查询、上传、下载等等。

设计,重点说明系统部署所使用的容器

项目架构

  • apache + nextcloud + mariadb + nonebot,其中web和mariadb部署在docker上,nonebot则部署在服务器上,主要负责用户和网盘的qq交互

docker相关配置文件

  • docker-compose.yml

    version: "3"
    services:
      db:
        image: izone/arm:mariadb
        container_name: mymysql
        command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
        restart: always
        volumes:
          - ./mysql_data:/var/lib/mysql
        environment:
          - MYSQL_DATABASE=nextcloud
          - MYSQL_ROOT_PASSWORD=admin
          - MYSQL_USER=nextcloud
          - MYSQL_PASSWORD=admin
      nextcloud:
        image: nextcloud
        container_name: nextcloud
        ports:
          - 8080:80
        links:
          - db
        volumes:
          - ./nextcloud:/var/www/html
        restart: always
    
  • apache2.conf

    <VirtualHost *:80>
            # The ServerName directive sets the request scheme, hostname and port that
            # the server uses to identify itself. This is used when creating
            # redirection URLs. In the context of virtual hosts, the ServerName
            # specifies what hostname must appear in the request's Host: header to
            # match this virtual host. For the default virtual host (this file) this
            # value is not decisive as it is used as a last resort host regardless.
            # However, you must set it for any further virtual host explicitly.
            #ServerName www.example.com
    
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
    
            # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
            # error, crit, alert, emerg.
            # It is also possible to configure the loglevel for particular
            # modules, e.g.
            #LogLevel info ssl:warn
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            # For most configuration files from conf-available/, which are
            # enabled or disabled at a global level, it is possible to
            # include a line for only one particular virtual host. For example the
            # following line enables the CGI configuration for this host only
            # after it has been globally disabled with "a2disconf".
            #Include conf-available/serve-cgi-bin.conf
    </VirtualHost>
    
  • docker运行实例

nonebot的部署

  • 项目结构

  • 服务启动

  • “展示”功能的代码

    @on_command('list', aliases=("展示", "show"))
    async def list_folders(session: CommandSession):
        path = session.get('path')
        r = await list_folder(path)
        first_flag = True
        if not r:
            await session.send("查询失败,无此目录")
        else:
            res = '|' + path + '\n'
            for item in r:
                if first_flag:
                    first_flag = False
                    continue
                else:
                    href = urllib.parse.unquote(item['href'])
                    name = re.findall((path if path else "admin") + r"(.*)", href)[-1][1:]
                    if item['resource_type'] == "collection":
                        res += '\t' + '|' + urllib.parse.unquote(name)[:-1] + '\n'
                    else:
                        res += '\t' + '-' + urllib.parse.unquote(name) + '\n'
            await session.send(res[:-1])
    
    
    @list_folders.args_parser
    async def _(session: CommandSession):
        # 去掉消息首尾的空白符
        stripped_arg = session.current_arg_text.strip()
        session.state['path'] = stripped_arg
        return
    
    async def list_folder(path):
        """
        展示目录文件
        :param path:
        :return:
        """
        nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_PASSWORD, json_output=to_js)
        r = nxc.list_folders("admin", path)
        if "Failed" in str(r):
            return False
        else:
            return r.data
    

运行结果,展示容器启动后,程序的运行结果

web端的上传下载

qq机器人的使用

  • 帮助菜单

  • 远程目录的创建

  • 远程文件的上传(能够返回一个短链)

  • 远程目录的展示

  • 查找所有包含关键字的文件

  • 远程文件的删除

最终的组内分工+贡献比

组员 分工 贡献比
031702626杨世杰 nonebot相关代码编写,博客PPT撰写 22%
031702642沈国煜 查阅nextcloud api文档,进行相关代码编写 18%
031702635陈郑铧 树莓派上部署web+mysql容器及稳定性维护 15%
031702625杨蓝宇 服务器上nonebot环境部署及稳定性维护 15%
031702637陈益 家庭网络的DDNS及端口映射的配置 15%
171709012沈鸿骁 代码和功能的测试,提出反馈和建议 15%

总结(组员分别撰写,统一提交)

  • 杨世杰
    • 本次实验在网盘环境的基础上实现了qq机器人对网盘的交互,无需网页和app,部署的各个服务紧密相连,才能最终轻松几句话即可操控网盘,方便至极~!
  • 沈国煜
    • 感悟:使用的是封装好的接口,完成了基本的功能,只做了一点微小的工作。
  • 陈郑铧
    • 在最后的大作业实验中,我主要负责的是在树莓派上部署web+mysql容器,其实关于Mysql服务在树莓派上的搭建在前几次作业中已经有涉及到了,还是有个机会再回顾了一下之前的内容,由于这次树莓派不在我这里,所以在团队协作中也是出现了不少的问题,好在我们通过种种方式最后仍然完成了这次作业,非常感谢我们大组的组长杨世杰同学的领导指挥,和小组组长沈国煜同学在大作业中负责了树莓派的实际操作。
  • 杨蓝宇
    • 本次实践使用到了基于酷Q的Python异步QQ机器人框架——NoneBot,同时使用到的Python包还有config、nextcloud和requests。由于QQ及相关插件在Windows下的支持比较好,故在Windows 10下运行该机器人,并以该Windows机器作为中转连接到在树莓派上的NextCloud。这次实践最大的感悟就是杰哥牛逼,在小组长杰哥的带领下逐渐成长...
  • 陈益
    • 在配置家庭网络的DDNS及端口映射的时候,由于对之前的计算机网络的知识有些遗忘,所以还花了一些时间去复习了一下关于网络的相关知识,也体现出了这门“综合实践”课的意义,就是对我们所学知识的一次综合运用。从最初的微服务docker,树莓派,到这次我们的云盘大作业中,我从中收获良多。
  • 沈鸿骁
    • 这次所完成作业包括一个QQ机器人的基于nextcloud与docker微服务架构的
      的私人文件系统,通过这个完成,在之前学习过docker微服务架构相关的内容与完成相关作业的基础上对微服务架构及其应用有更深刻的理解,同时此次在小组种完成的部分是代码与功能的测试,并且提出反馈,关于测试,主要是通过qq机器人与相关指令对其功能进行实际测试,其中包括用户查看、文件查看、文件上传、文件删除、指定文件代理、查找、展示、创建及其收到的通知查看,第一阶段测试仅有文件上传删除、用户创建等功能,后序加入其他功能,相关功能仍旧存在可能完善的空间譬如文件分类相关排序,分组等更加细致的服务。
posted @ 2020-06-27 23:08  Dicky99  阅读(301)  评论(0编辑  收藏  举报