Maktub_Wiki Maktub_Wiki
主站 (opens new window)
  • 服务搭建
  • 网络服务
  • 开源框架
  • 操作系统
  • iOS/MacOS
  • 算法导论(Python)
  • Leetcode
  • 线性代数
主站 (opens new window)
  • 服务搭建
  • 网络服务
  • 开源框架
  • 操作系统
  • iOS/MacOS
  • 算法导论(Python)
  • Leetcode
  • 线性代数
  • Linux系统

    • 常规配置
    • 树莓派
    • 极简系统问题
    • dd Debian系统
    • samba服务配置
  • MacOS系统

    • 设置问题
  • Windows系统

    • 命令行操作
  • Openwrt路由系统

    • 优化操作
    • 相关功能软件包
    • 服务自启动
      • MT7621适配问题
    • 树莓派
    • 操作系统
    • Openwrt路由系统
    Maktub_小明
    2024-03-26
    目录

    服务自启动

    # 说明

    服务自启动,和添加守护进程,以ServerStatus客户端为例

    # 创建服务

    编辑/etc/init.d/client

    #!/bin/sh /etc/rc.common
    
    START=99
    USE_PROCD=1
    
    start_service() {
        procd_open_instance
        procd_set_param command /root/.tool/client-linux.py
        procd_set_param respawn
        procd_close_instance
    }
    
    stop_service() {
        procd_close_instance
    }
    

    启动服务

    /etc/init.d/client start
    /etc/init.d/client enable
    /etc/init.d/client status
    

    # 其他

    编辑修改/root/.tool/client-linux.py的get_hdd函数,原来的--total参数是计算磁盘总和的,openwrt的df没有此参数

    def get_hdd():
        p = subprocess.check_output(['df', '-Tm', '-t', 'ext4']).decode("Utf-8")
        total = p.splitlines()[-1]
        used = total.split()[3]
        size = total.split()[2]
        return int(size), int(used)
    

    安装相关依赖

    opkg update
    opkg install ss
    
    上次更新: 2025/03/22, 03:52:10
    相关功能软件包
    MT7621适配问题

    ← 相关功能软件包 MT7621适配问题→

    Theme by Vdoing | Copyright © 2021-2025 Maktub_小明 | MIT License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式