我正在尝试在bash脚本中设置条件,以确保文件是否存在,跳过整个代码并转到下一部分。
“”“
echo "k8s: starting the init script"
if [ ! -e /etc/sawtooth/keys/validator.priv ]; then
echo $pbft0priv > /etc/sawtooth/keys/validator.priv
echo $pbft0pub > /etc/sawtooth/keys/validator.pub
fi &&
echo "k8s: checking for keys"
if [ ! -e /root/.sawtooth/keys/my_key.priv ]; then
sawtooth keygen my_key
fi &&
echo "k8s: checking for config-genesis.batch"
if [ ! -e /var/lib/sawtooth/genesis.batch.file ]; then
if [ ! -e config-genesis.batch ]; then
sawset genesis -k /root/.sawtooth/keys/my_key.priv -o config-genesis.batch
fi &&
echo "k8s: sleeping for 30 sec"
sleep 30 &&
echo sawtooth.consensus.pbft.members=["\"$pbft0pub\",\"$pbft1pub\",\"$pbft2pub\",\"$pbft3pub\",\"$pbft4pub\""] &&
if [ ! -e config.batch ]; then
sawset proposal create \
-k /root/.sawtooth/keys/my_key.priv \
sawtooth.consensus.algorithm.name=pbft \
sawtooth.consensus.algorithm.version=1.0\
sawtooth.consensus.pbft.members=["\"$pbft0pub\",\"$pbft1pub\",\"$pbft2pub\",\"$pbft3pub\",\"$pbft4pub\""] \
sawtooth.publisher.max_batches_per_block=1200 \
-o config.batch
fi && \
fi &&
if [ ! -e /var/lib/sawtooth/genesis.batch ]; then
sawadm genesis config-genesis.batch config.batch
fi &&
sawtooth-validator -vv \
--endpoint tcp://$SAWTOOTH_0_SERVICE_HOST:8800 \
--bind component:tcp://eth0:4004 \
--bind consensus:tcp://eth0:5050 \
--bind network:tcp://eth0:8800 \
--scheduler parallel \
--peering static \
--maximum-peer-connectivity 10000“”“
但是我得到了第28行的错误:在意外令牌fi' line 28: fi &&‘附近的语法错误
这是28号线:
26: -o config.batch
27: fi && \
28: fi &&发布于 2022-08-10 16:40:37
您的问题出现在第27行:
fi && \&& \不属于那里。这是块中的最后一个if,因此不应该将&&放在那里,因为之后没有命令。
if true; then
if true; then
echo one
fi &&
if true; then
echo two
fi
fi &&
echo threehttps://stackoverflow.com/questions/73308548
复制相似问题