Make etcd.conf editing more robust
The AWK incantation that we used to remove an existing /usr/bin/etcd invocation from /etc/init/etcd.conf did not work correctly if there was nothing in the file after that invocation; it left the final line of the invocation in place. This commit simplifies and improves the script so that it works in that case. Change-Id: Icc82ed36485b24468b02eabddac86ae73ea6a29b
This commit is contained in:
parent
859bbbb426
commit
b2c0af1a80
|
@ -60,7 +60,7 @@ initial_cluster=${initial_cluster::-1} # remove trailing comma
|
|||
|
||||
service etcd stop
|
||||
rm -rf /var/lib/etcd/*
|
||||
awk '/exec \/usr\/bin\/etcd/{while(getline && $0 != ""){}}1' /etc/init/etcd.conf > tmp
|
||||
awk 'BEGIN{p=1}/exec \/usr\/bin\/etcd/{p=0}/^\s*$/{p=1}p' /etc/init/etcd.conf > tmp
|
||||
mv tmp /etc/init/etcd.conf
|
||||
cat << EXEC_CMD >> /etc/init/etcd.conf
|
||||
exec /usr/bin/etcd -proxy on \\
|
||||
|
|
|
@ -60,7 +60,7 @@ initial_cluster=${initial_cluster::-1} # remove trailing comma
|
|||
|
||||
service etcd stop
|
||||
rm -rf /var/lib/etcd/*
|
||||
awk '/exec \/usr\/bin\/etcd/{while(getline && $0 != ""){}}1' /etc/init/etcd.conf > tmp
|
||||
awk 'BEGIN{p=1}/exec \/usr\/bin\/etcd/{p=0}/^\s*$/{p=1}p' /etc/init/etcd.conf > tmp
|
||||
mv tmp /etc/init/etcd.conf
|
||||
cat << EXEC_CMD >> /etc/init/etcd.conf
|
||||
exec /usr/bin/etcd -name ${this_node_address} \\
|
||||
|
|
|
@ -13,7 +13,7 @@ initial_cluster=${initial_cluster::-1} # remove trailing comma
|
|||
|
||||
service etcd stop
|
||||
rm -rf /var/lib/etcd/*
|
||||
awk '/exec \/usr\/bin\/etcd/{while(getline && $0 != ""){}}1' /etc/init/etcd.conf > tmp
|
||||
awk 'BEGIN{p=1}/exec \/usr\/bin\/etcd/{p=0}/^\s*$/{p=1}p' /etc/init/etcd.conf > tmp
|
||||
mv tmp /etc/init/etcd.conf
|
||||
cat << EXEC_CMD >> /etc/init/etcd.conf
|
||||
exec /usr/bin/etcd -name ${this_node_address} \\
|
||||
|
@ -39,4 +39,3 @@ while [[ $retry_count < 5 ]]; do
|
|||
sleep 2
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in New Issue