scripts: Set 'echo -e' to make text colors work in alphanet.sh
Before this change, output from `alphanet.sh` looked like the following: ``` New contract alias 'my_account' saved. Contract memorized as my_account. \033[32mThe node is now running.\033[0m \033[32mThe baker is now running.\033[0m \033[32mThe endorser is now running.\033[0m \033[33mWarning: the container contains a new version of 'alphanet.sh'.\033[0m \033[33mYou might run './scripts/alphanet.sh update_script' to synchronize.\033[0m ``` I.e. control characters showed up, instead of modifying the color of the text output. Repro'd on Container Linux (CoreOS) 1492.3.0. After this change, `The node is now running` shows up in green &c.
This commit is contained in:
parent
1436286fd6
commit
f7d596ac50
@ -88,7 +88,7 @@ save_accounts() {
|
|||||||
if [ ! -f "$data_dir/secret keys" ]; then
|
if [ ! -f "$data_dir/secret keys" ]; then
|
||||||
echo "Saving the secrets into '$data_dir/secret keys'..."
|
echo "Saving the secrets into '$data_dir/secret keys'..."
|
||||||
echo
|
echo
|
||||||
echo "\033[33mWARNING: THE SECRET KEYS FILE IS UNENCRYPTED!!!\033[0m"
|
echo -e "\033[33mWARNING: THE SECRET KEYS FILE IS UNENCRYPTED!!!\033[0m"
|
||||||
echo
|
echo
|
||||||
mkdir -p "$data_dir/"
|
mkdir -p "$data_dir/"
|
||||||
fi
|
fi
|
||||||
@ -135,9 +135,9 @@ check_volume() {
|
|||||||
clear_volume() {
|
clear_volume() {
|
||||||
if check_volume ; then
|
if check_volume ; then
|
||||||
docker volume rm "$docker_volume" > /dev/null
|
docker volume rm "$docker_volume" > /dev/null
|
||||||
echo "\033[32mThe blockchain data has been removed from the disk.\033[0m"
|
echo -e "\033[32mThe blockchain data has been removed from the disk.\033[0m"
|
||||||
else
|
else
|
||||||
echo "\033[32mNo remaining data to be removed from the disk.\033[0m"
|
echo -e "\033[32mNo remaining data to be removed from the disk.\033[0m"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ assert_container_uptodate() {
|
|||||||
|
|
||||||
assert_container() {
|
assert_container() {
|
||||||
if ! check_container; then
|
if ! check_container; then
|
||||||
echo "\033[31mNo container currently running!\033[0m"
|
echo -e "\033[31mNo container currently running!\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ start_container() {
|
|||||||
|
|
||||||
stop_container() {
|
stop_container() {
|
||||||
if ! check_container; then
|
if ! check_container; then
|
||||||
echo "\033[31mNo container to kill!\033[0m"
|
echo -e "\033[31mNo container to kill!\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
save_identity ## Saving again, just in case...
|
save_identity ## Saving again, just in case...
|
||||||
@ -216,22 +216,22 @@ check_node() {
|
|||||||
|
|
||||||
assert_node() {
|
assert_node() {
|
||||||
if ! check_node; then
|
if ! check_node; then
|
||||||
echo "\033[31mNode is not running!\033[0m"
|
echo -e "\033[31mNode is not running!\033[0m"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
status_node() {
|
status_node() {
|
||||||
if check_node; then
|
if check_node; then
|
||||||
echo "\033[32mNode is running\033[0m"
|
echo -e "\033[32mNode is running\033[0m"
|
||||||
else
|
else
|
||||||
echo "\033[33mNode is not running\033[0m"
|
echo -e "\033[33mNode is not running\033[0m"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
start_node() {
|
start_node() {
|
||||||
if check_node; then
|
if check_node; then
|
||||||
echo "\033[31mCannot run two nodes in the same container!\033[0m"
|
echo -e "\033[31mCannot run two nodes in the same container!\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if $docker_1_13; then
|
if $docker_1_13; then
|
||||||
@ -241,7 +241,7 @@ start_node() {
|
|||||||
"$docker_container" tezos run_node
|
"$docker_container" tezos run_node
|
||||||
sleep 1
|
sleep 1
|
||||||
docker exec "$docker_container" tezos wait_node
|
docker exec "$docker_container" tezos wait_node
|
||||||
echo "\033[32mThe node is now running.\033[0m"
|
echo -e "\033[32mThe node is now running.\033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
log_node() {
|
log_node() {
|
||||||
@ -261,27 +261,27 @@ check_baker() {
|
|||||||
|
|
||||||
assert_baker() {
|
assert_baker() {
|
||||||
if ! check_baker; then
|
if ! check_baker; then
|
||||||
echo "\033[31mBaker is not running!\033[0m"
|
echo -e "\033[31mBaker is not running!\033[0m"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
status_baker() {
|
status_baker() {
|
||||||
if check_baker; then
|
if check_baker; then
|
||||||
echo "\033[32mBaker is running\033[0m"
|
echo -e "\033[32mBaker is running\033[0m"
|
||||||
else
|
else
|
||||||
echo "\033[33mBaker is not running\033[0m"
|
echo -e "\033[33mBaker is not running\033[0m"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
start_baker() {
|
start_baker() {
|
||||||
if check_baker; then
|
if check_baker; then
|
||||||
echo "\033[31mCannot run two bakers in the same container!\033[0m"
|
echo -e "\033[31mCannot run two bakers in the same container!\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
TEZOS_LOG="${TEZOS_LOG:=* -> info}"
|
TEZOS_LOG="${TEZOS_LOG:=* -> info}"
|
||||||
docker exec -d "$docker_container" tezos run_baker
|
docker exec -d "$docker_container" tezos run_baker
|
||||||
echo "\033[32mThe baker is now running.\033[0m"
|
echo -e "\033[32mThe baker is now running.\033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
log_baker() {
|
log_baker() {
|
||||||
@ -300,27 +300,27 @@ check_endorser() {
|
|||||||
|
|
||||||
assert_endorser() {
|
assert_endorser() {
|
||||||
if ! check_baker; then
|
if ! check_baker; then
|
||||||
echo "\033[31mEndorser is not running!\033[0m"
|
echo -e "\033[31mEndorser is not running!\033[0m"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
status_endorser() {
|
status_endorser() {
|
||||||
if check_endorser; then
|
if check_endorser; then
|
||||||
echo "\033[32mEndorser is running\033[0m"
|
echo -e "\033[32mEndorser is running\033[0m"
|
||||||
else
|
else
|
||||||
echo "\033[33mEndorser is not running\033[0m"
|
echo -e "\033[33mEndorser is not running\033[0m"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
start_endorser() {
|
start_endorser() {
|
||||||
if check_endorser; then
|
if check_endorser; then
|
||||||
echo "\033[31mCannot run two endorsers in the same container!\033[0m"
|
echo -e "\033[31mCannot run two endorsers in the same container!\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
TEZOS_LOG="${TEZOS_LOG:=* -> info}"
|
TEZOS_LOG="${TEZOS_LOG:=* -> info}"
|
||||||
docker exec -d "$docker_container" tezos run_endorser
|
docker exec -d "$docker_container" tezos run_endorser
|
||||||
echo "\033[32mThe endorser is now running.\033[0m"
|
echo -e "\033[32mThe endorser is now running.\033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
log_endorser() {
|
log_endorser() {
|
||||||
@ -399,10 +399,10 @@ stop() {
|
|||||||
status() {
|
status() {
|
||||||
pull_image
|
pull_image
|
||||||
if ! uptodate_container; then
|
if ! uptodate_container; then
|
||||||
echo "\033[31mThe container is running but not the latest available.\033[0m"
|
echo -e "\033[31mThe container is running but not the latest available.\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "\033[32mThe container is running and up to date.\033[0m"
|
echo -e "\033[32mThe container is running and up to date.\033[0m"
|
||||||
warn_script_uptodate verbose
|
warn_script_uptodate verbose
|
||||||
status_node
|
status_node
|
||||||
status_baker
|
status_baker
|
||||||
@ -416,10 +416,10 @@ warn_script_uptodate() {
|
|||||||
docker cp "$docker_container:home/tezos/scripts/alphanet.sh" \
|
docker cp "$docker_container:home/tezos/scripts/alphanet.sh" \
|
||||||
".alphanet.sh.new"
|
".alphanet.sh.new"
|
||||||
if ! diff .alphanet.sh.new "$0" >/dev/null 2>&1 ; then
|
if ! diff .alphanet.sh.new "$0" >/dev/null 2>&1 ; then
|
||||||
echo "\033[33mWarning: the container contains a new version of 'alphanet.sh'.\033[0m"
|
echo -e "\033[33mWarning: the container contains a new version of 'alphanet.sh'.\033[0m"
|
||||||
echo "\033[33mYou might run '$0 update_script' to synchronize.\033[0m"
|
echo -e "\033[33mYou might run '$0 update_script' to synchronize.\033[0m"
|
||||||
elif [ "$1" = "verbose" ] ; then
|
elif [ "$1" = "verbose" ] ; then
|
||||||
echo "\033[32mThe script is up to date.\033[0m"
|
echo -e "\033[32mThe script is up to date.\033[0m"
|
||||||
fi
|
fi
|
||||||
rm .alphanet.sh.new
|
rm .alphanet.sh.new
|
||||||
}
|
}
|
||||||
@ -437,10 +437,10 @@ update_script() {
|
|||||||
docker stop "$tmp" > /dev/null
|
docker stop "$tmp" > /dev/null
|
||||||
if ! diff .alphanet.sh.new "$0" >/dev/null 2>&1 ; then
|
if ! diff .alphanet.sh.new "$0" >/dev/null 2>&1 ; then
|
||||||
mv .alphanet.sh.new "$0"
|
mv .alphanet.sh.new "$0"
|
||||||
echo "\033[32mThe script has been updated.\033[0m"
|
echo -e "\033[32mThe script has been updated.\033[0m"
|
||||||
else
|
else
|
||||||
rm .alphanet.sh.new
|
rm .alphanet.sh.new
|
||||||
echo "\033[32mThe script is up to date.\033[0m"
|
echo -e "\033[32mThe script is up to date.\033[0m"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ case "$command" in
|
|||||||
;;
|
;;
|
||||||
clear)
|
clear)
|
||||||
if check_container; then
|
if check_container; then
|
||||||
echo "\033[31mCannot clear data while the container is running.\033[0m"
|
echo -e "\033[31mCannot clear data while the container is running.\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
clear_volume
|
clear_volume
|
||||||
@ -552,9 +552,9 @@ case "$command" in
|
|||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
if check_container; then
|
if check_container; then
|
||||||
echo "\033[32mContainer is running\033[0m"
|
echo -e "\033[32mContainer is running\033[0m"
|
||||||
else
|
else
|
||||||
echo "\033[33mContainer is not running\033[0m"
|
echo -e "\033[33mContainer is not running\033[0m"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
|
Loading…
Reference in New Issue
Block a user