aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlogin000 <34250284+login000@users.noreply.github.com>2019-03-10 17:05:20 +1100
committerGitHub <noreply@github.com>2019-03-10 17:05:20 +1100
commitbd45e807eda9c72981fba015c5ae7dff4054e2f1 (patch)
tree006b00c234871dd72f23566475b429485ae6d23f
parentfa215b7d0dbfa08ddeeb487e9c60b990130379d8 (diff)
downloadtcoin-bd45e807eda9c72981fba015c5ae7dff4054e2f1.tar.gz
bash script to create new program accounts
bash script creates directory structure for new program accounts
-rw-r--r--npcoin53
1 files changed, 53 insertions, 0 deletions
diff --git a/npcoin b/npcoin
new file mode 100644
index 0000000..c497ba5
--- /dev/null
+++ b/npcoin
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+if [ "$#" -eq 0 ] || [ "${@^}" = "--help" ] || [ "${@^}" = "-h" ]
+then
+ /bin/echo "Usage:"
+ /bin/echo " npcoin <Nameofprogram> : to create pcoin directories for <Nameofprogram>"
+ /bin/echo " npcoin [ --help | -h ] : to print this help"
+else
+ if [ -e "/home/login/tcoin/${@^}.txt" ]
+ then
+ /bin/echo "Sorry, '/home/login/tcoin/${@^}.txt' already exists."
+ exit 1
+ else
+ /bin/echo "0" > "/home/login/tcoin/${@^}.txt"
+ /bin/chmod 600 "/home/login/tcoin/${@^}.txt"
+ fi
+
+ if [ -e "/home/login/tcoin/messages/${@^}_messages.txt" ]
+ then
+ /bin/echo "Sorry, '/home/login/tcoin/messages/${@^}_messages.txt' already exists."
+ exit 1
+ else
+ /usr/bin/touch "/home/login/tcoin/messages/${@^}_messages.txt"
+ /bin/chmod 600 "/home/login/tcoin/messages/${@^}_messages.txt"
+ fi
+
+ if [ -e "/home/login/tcoin/program_accounting/${@^}" ]
+ then
+ /bin/echo "Sorry, '/home/login/tcoin/program_accounting/${@^}' aleady exists."
+ exit 1
+ else
+ /bin/mkdir "/home/login/tcoin/program_accounting/${@^}"
+ /bin/chmod 700 "/home/login/tcoin/program_accounting/${@^}"
+ fi
+
+ if [ -e "/home/login/tcoin/program_accounting/${@^}/_TOTAL.txt" ]
+ then
+ /bin/echo "Sorry, '/home/login/tcoin/program_accounting/${@^}/_TOTAL.txt' already exists."
+ exit 1
+ else
+ /bin/echo "0" > "/home/login/tcoin/program_accounting/${@^}/_TOTAL.txt"
+ /bin/chmod 600 "/home/login/tcoin/program_accounting/${@^}/_TOTAL.txt"
+ fi
+
+ if [ -e "/home/login/tcoin/program_accounting/${@^}/_MESSAGES.txt" ]
+ then
+ /bin/echo "Sorry, '/home/login/tcoin/program_accounting/${@^}/_MESSAGES.txt' already exists."
+ exit 1
+ else
+ /bin/echo "0" > "/home/login/tcoin/program_accounting/${@^}/_MESSAGES.txt"
+ /bin/chmod 600 "/home/login/tcoin/program_accounting/${@^}/_MESSAGES.txt"
+ fi
+fi