GoAuthing
                                
                                 GoAuthing copied to clipboard
                                
                                    GoAuthing copied to clipboard
                            
                            
                            
                        使用 UCI 的 init.d 脚本在 OpenWRT 21.02 无法运行
在 OpenWRT 21.02 版本上,文档中提供的 uci set goauthing.config.username='<YOUR-TUNET-ACCOUNT-NAME>' 运行报错,提示 uci: Invalid argument ;尝试手写配置文件后,goauthing@ init.d 脚本中所用的 config_get 函数也无法获取到相应的配置值。
经测试,一种可能正常工作的组合如下:
命令行:
touch /etc/config/goauthing
uci add goauthing goauthing
uci set goauthing.@goauthing[0].username='<YOUR-TUNET-ACCOUNT-NAME>'
uci set goauthing.@goauthing[0].password='<YOUR-TUNET-PASSWORD>'
uci commit
对应的 /etc/config/goauthing 配置文件格式:
config goauthing
        option username '<YOUR-TUNET-ACCOUNT-NAME>'
        option password '<YOUR-TUNET-PASSWORD>'
在 init.d 脚本中,需要修改获取配置的命令如下:
start_instance() {
  local config=$1
  local username password
  config_get username $config username
  config_get password $config password
  ...
}
logout() {
  local config=$1
  local username password
  config_get username $config username
  config_get password $config password
  ...
}
欢迎发一个 PR 修改文档与相应脚本。由于个人没使用过 openwrt,不知道是哪个版本开始语法发生了改变。
Cc @BaksiLi