|
@ -0,0 +1,112 @@ |
|
|
|
|
|
#!/bin/sh |
|
|
|
|
|
|
|
|
|
|
|
pgm="${0##*/}" |
|
|
|
|
|
what="${1:-usage}" |
|
|
|
|
|
# vim: syntax=sh |
|
|
|
|
|
# |
|
|
|
|
|
echo "--- # $pgm" |
|
|
|
|
|
|
|
|
|
|
|
if [ "x$what" = 'xusage' ]; then |
|
|
|
|
|
cat <<EOT |
|
|
|
|
|
# welcome to toychain a simple educational blockchain |
|
|
|
|
|
|
|
|
|
|
|
available commands: |
|
|
|
|
|
|
|
|
|
|
|
$pgm init \$name # to initialize \$name node |
|
|
|
|
|
$pgm config \$name # to change configuration to this \$name node |
|
|
|
|
|
$pgm start \$name # to start a local \$name node |
|
|
|
|
|
$pgm stop \$name # to stop a \$name node |
|
|
|
|
|
$pgm restart \$name # to restart a \$name node |
|
|
|
|
|
$pgm sync \$name # to synchronize a \$name node |
|
|
|
|
|
$pgm update \$tag # to synchronize a \$tag node |
|
|
|
|
|
$pgm test \$tc # to run the \$tc test case |
|
|
|
|
|
$pgm debug \$cmd # to running \$cmd in debug mode |
|
|
|
|
|
|
|
|
|
|
|
EOT |
|
|
|
|
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main() { |
|
|
|
|
|
case $what in |
|
|
|
|
|
init) tcinitialize $2;; |
|
|
|
|
|
config) tcconfigure $@;; |
|
|
|
|
|
start) tcstart $2;; |
|
|
|
|
|
stop) tcstop $2;; |
|
|
|
|
|
stop) tcstop $2;; |
|
|
|
|
|
update) tcupdate $@;; |
|
|
|
|
|
test) tctest $@;; |
|
|
|
|
|
debug) tcdebug $@;; |
|
|
|
|
|
support) echo "do you need help with $pgm ?\n- call our support line at https://www.drit.ml\n-- Dr I·T";; |
|
|
|
|
|
log) tclog;; |
|
|
|
|
|
*) tcrun $@;; |
|
|
|
|
|
esac |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tcinitialize() { |
|
|
|
|
|
echo "$pgm: initializing ..." |
|
|
|
|
|
echo "---" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tcconfigure() { |
|
|
|
|
|
echo "$pgm: configure ..." |
|
|
|
|
|
echo "---" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tcstart() { |
|
|
|
|
|
echo "$pgm: starting daemon ..." |
|
|
|
|
|
echo "---" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tcstop() { |
|
|
|
|
|
echo "$pgm: stopping daemon ..." |
|
|
|
|
|
echo "---" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tcsync() { |
|
|
|
|
|
echo "$pgm: synchronizing daemon ..." |
|
|
|
|
|
echo "---" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tcupdate() { |
|
|
|
|
|
shift; |
|
|
|
|
|
tag=$2 |
|
|
|
|
|
echo "$pgm: updating daemon with tag $tag..." |
|
|
|
|
|
git pull origin master # 1> transcript.log 2>&1 |
|
|
|
|
|
git checkout $tag # 1> transcript.log 2>&1 |
|
|
|
|
|
echo "---" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tclog() { |
|
|
|
|
|
echo "$pgm: transcript log" |
|
|
|
|
|
tail -f transctip.log |
|
|
|
|
|
echo "---" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tctest() { |
|
|
|
|
|
tc="$2" |
|
|
|
|
|
echo "$pgm: running $1 $tc" |
|
|
|
|
|
echo "---" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tcrun() { |
|
|
|
|
|
cmd="$@" |
|
|
|
|
|
echo "$pgm: running $cmd" |
|
|
|
|
|
$cmd |
|
|
|
|
|
echo "..." |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tcdebug() { |
|
|
|
|
|
shift; |
|
|
|
|
|
cmd="$@" |
|
|
|
|
|
echo "$pgm: running $cmd in debug mode..." |
|
|
|
|
|
echo "---" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main $@; |
|
|
|
|
|
exit $?; |
|
|
|
|
|
true; # $Source: /my/shell/scripts/toychain.sh $ |