Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose部署报错 Error: unknown shorthand flag: 'c' in -config #235

Closed
2 tasks done
HCLonely opened this issue Feb 28, 2023 · 7 comments · Fixed by #236
Closed
2 tasks done

docker-compose部署报错 Error: unknown shorthand flag: 'c' in -config #235

HCLonely opened this issue Feb 28, 2023 · 7 comments · Fixed by #236
Labels

Comments

@HCLonely
Copy link

  • 我已升级贴吧云签到到最新版本,并且运行了升级脚本
  • 我已搜索过 Issue 区,没有找到相关问题

问题描述

docker-compose部署后访问网站返回502,查看日志发现报错 Error: unknown shorthand flag: 'c' in -config
image

复现步骤

docker-compose up -d

环境

  • 云签到版本:Latest
  • 服务器系统和版本:Ubuntu 20.04 LTS
  • 云签到是否在 Docker 中运行:是
  • PHP 版本:
  • MySQL 版本:
@n0099
Copy link
Collaborator

n0099 commented Feb 28, 2023

#232

@BANKA2017
Copy link
Collaborator

看了一下应该是执行 s6-overlay 启动脚本出现的问题,怀疑是 sed 不再支持这种 flag,但我并不熟悉 sed 的使用

sed -i ''"$(cat $file_config -n | grep "DB_HOST" | awk '{print $1}')"'c '"$(echo "define('DB_HOST','${DB_HOST}');")"'' $file_config
sed -i ''"$(cat $file_config -n | grep "DB_USER" | awk '{print $1}')"'c '"$(echo "define('DB_USER','${DB_USER}');")"'' $file_config
sed -i ''"$(cat $file_config -n | grep "DB_PASSWD" | awk '{print $1}')"'c '"$(echo "define('DB_PASSWD','${DB_PASSWD}');")"'' $file_config
sed -i ''"$(cat $file_config -n | grep "DB_NAME" | awk '{print $1}')"'c '"$(echo "define('DB_NAME','${DB_NAME}');")"'' $file_config
sed -i ''"$(cat $file_config -n | grep "ANTI_CSRF" | awk '{print $1}')"'c '"$(echo "define('ANTI_CSRF',"${CSRF}");")"'' $file_config

@n0099
Copy link
Collaborator

n0099 commented Feb 28, 2023

什么flag?您在macos上用着BSD sed而非GNU/Linux的GNU sed吗?如同 n0099/tbclient.protobuf#2 (comment)
先看看单独执行cat $file_config -n | grep "DB_USER" | awk '{print $1}'的结果是什么
以及变量$file_config里是不是有可能出现空格或glob等unexpected expansion,如果可能应该套""避免word splitting和unexpected expansion
建议直接无脑set -x

@BANKA2017
Copy link
Collaborator

先看看单独执行cat $file_config -n | grep "DB_USER" | awk '{print $1}'的结果是什么

得到的是对应内容所在的行数,c 的作用是将 c 后面的内容替换掉前面的行对应的内容

@n0099
Copy link
Collaborator

n0099 commented Feb 28, 2023

为什么不是grep -n而是cat -n,效果一样但with line num应该在grep一层进行以避免经典半谓词问题,即假如grep的是数字(但这里是字面量的字符串"DB_USER",建议换成''避免expansion)那就会匹配到cat -n所附带的line num造成歧义

@BANKA2017
Copy link
Collaborator

看了一下应该是执行 s6-overlay 启动脚本出现的问题

我重新看了一下,问题并不在这个脚本,目前不知道问题所在

@gitcps
Copy link

gitcps commented Feb 28, 2023

宝塔环境安装,出现同样的问题

BANKA2017 added a commit to kdnetwork/Tieba-Cloud-Sign that referenced this issue Feb 28, 2023
尝试修复 docker 版无法启动 caddy 的问题
@BANKA2017 BANKA2017 linked a pull request Feb 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants