You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
1.9 KiB

3 years ago
  1. #!/bin/sh
  2. pgm="${0##*/}"
  3. what="${1:-usage}"
  4. # vim: syntax=sh
  5. #
  6. echo "--- # $pgm"
  7. if [ "x$what" = 'xusage' ]; then
  8. cat <<EOT
  9. # welcome to toychain a simple educational blockchain
  10. available commands:
  11. $pgm init \$name # to initialize \$name node
  12. $pgm config \$name # to change configuration to this \$name node
  13. $pgm start \$name # to start a local \$name node
  14. $pgm stop \$name # to stop a \$name node
  15. $pgm restart \$name # to restart a \$name node
  16. $pgm sync \$name # to synchronize a \$name node
  17. $pgm update \$tag # to synchronize a \$tag node
  18. $pgm test \$tc # to run the \$tc test case
  19. $pgm debug \$cmd # to running \$cmd in debug mode
  20. EOT
  21. fi
  22. main() {
  23. case $what in
  24. init) tcinitialize $2;;
  25. config) tcconfigure $@;;
  26. start) tcstart $2;;
  27. stop) tcstop $2;;
  28. stop) tcstop $2;;
  29. update) tcupdate $@;;
  30. test) tctest $@;;
  31. debug) tcdebug $@;;
  32. support) echo "do you need help with $pgm ?\n- call our support line at https://www.drit.ml\n-- Dr I·T";;
  33. log) tclog;;
  34. *) tcrun $@;;
  35. esac
  36. }
  37. tcinitialize() {
  38. echo "$pgm: initializing ..."
  39. echo "---"
  40. }
  41. tcconfigure() {
  42. echo "$pgm: configure ..."
  43. echo "---"
  44. }
  45. tcstart() {
  46. echo "$pgm: starting daemon ..."
  47. echo "---"
  48. }
  49. tcstop() {
  50. echo "$pgm: stopping daemon ..."
  51. echo "---"
  52. }
  53. tcsync() {
  54. echo "$pgm: synchronizing daemon ..."
  55. echo "---"
  56. }
  57. tcupdate() {
  58. shift;
  59. tag=$2
  60. echo "$pgm: updating daemon with tag $tag..."
  61. git pull origin master # 1> transcript.log 2>&1
  62. git checkout $tag # 1> transcript.log 2>&1
  63. echo "---"
  64. }
  65. tclog() {
  66. echo "$pgm: transcript log"
  67. tail -f transctip.log
  68. echo "---"
  69. }
  70. tctest() {
  71. tc="$2"
  72. echo "$pgm: running $1 $tc"
  73. echo "---"
  74. }
  75. tcrun() {
  76. cmd="$@"
  77. echo "$pgm: running $cmd"
  78. $cmd
  79. echo "..."
  80. }
  81. tcdebug() {
  82. shift;
  83. cmd="$@"
  84. echo "$pgm: running $cmd in debug mode..."
  85. echo "---"
  86. }
  87. main $@;
  88. exit $?;
  89. true; # $Source: /my/shell/scripts/toychain.sh $