diff options
| author | login000 <34250284+login000@users.noreply.github.com> | 2019-09-30 19:15:11 +1000 |
|---|---|---|
| committer | login000 <34250284+login000@users.noreply.github.com> | 2019-09-30 19:15:11 +1000 |
| commit | fb302642bbccc8e3dec36de858379407b905e77d (patch) | |
| tree | c47f488056946b5a72c101dd0571944e2ac64cac | |
| parent | 6e7087c66f837a1449fc9d1bc773a4c26f6551fe (diff) | |
| download | tcoin-fb302642bbccc8e3dec36de858379407b905e77d.tar.gz | |
Updated ntcoin to get rid of trailing slash
Uses "realpath" to get rid of all trailing slashes and check that each directory in the path supplied exist (other than the innermost directory).
| -rw-r--r-- | ntcoin | 154 |
1 files changed, 77 insertions, 77 deletions
@@ -6,145 +6,145 @@ then /bin/echo " ntcoin <path (no slash)> <n> : to create tcoin subdirectories in <path (no slash)> with <n> basecoins per user" /bin/echo " ntcoin [ --help | -h ] : to print this help" else - if [ -d "$1/tcoin" ] + if [ -d "`/usr/bin/realpath -s $1`/tcoin" ] then - /bin/echo "Sorry, '$1/tcoin' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin' already exists." exit 1 else - /bin/mkdir "$1/tcoin" - /bin/chmod 700 "$1/tcoin" + /bin/mkdir "`/usr/bin/realpath -s $1`/tcoin" + /bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin" fi - if [ -d "$1/tcoin/salts" ] + if [ -d "`/usr/bin/realpath -s $1`/tcoin/salts" ] then - /bin/echo "Sorry, '$1/tcoin/salts' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/salts' already exists." exit 1 else - /bin/mkdir "$1/tcoin/salts" - /bin/chmod 700 "$1/tcoin/salts" + /bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/salts" + /bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/salts" fi - if [ -d "$1/tcoin/passwords" ] + if [ -d "`/usr/bin/realpath -s $1`/tcoin/passwords" ] then - /bin/echo "Sorry, '$1/tcoin/passwords' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/passwords' already exists." exit 1 else - /bin/mkdir "$1/tcoin/passwords" - /bin/chmod 700 "$1/tcoin/passwords" + /bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/passwords" + /bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/passwords" fi - if [ -d "$1/tcoin/program_accounting" ] + if [ -d "`/usr/bin/realpath -s $1`/tcoin/program_accounting" ] then - /bin/echo "Sorry, '$1/tcoin/program_accounting' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/program_accounting' already exists." exit 1 else - /bin/mkdir "$1/tcoin/program_accounting" - /bin/chmod 700 "$1/tcoin/program_accounting" + /bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/program_accounting" + /bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/program_accounting" fi - if [ -d "$1/tcoin/messages" ] + if [ -d "`/usr/bin/realpath -s $1`/tcoin/messages" ] then - /bin/echo "Sorry, '$1/tcoin/messages' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/messages' already exists." exit 1 else - /bin/mkdir "$1/tcoin/messages" - /bin/chmod 700 "$1/tcoin/messages" + /bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/messages" + /bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/messages" fi - if [ -d "$1/tcoin/base" ] + if [ -d "`/usr/bin/realpath -s $1`/tcoin/base" ] then - /bin/echo "Sorry, '$1/tcoin/base' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/base' already exists." exit 1 else - /bin/mkdir "$1/tcoin/base" - /bin/chmod 700 "$1/tcoin/base" - if [ -e "$1/tcoin/base/base.txt" ] + /bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/base" + /bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/base" + if [ -e "`/usr/bin/realpath -s $1`/tcoin/base/base.txt" ] then - /bin/echo "Sorry, '$1/tcoin/base/base.txt' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/base/base.txt' already exists." exit 1 else /bin/echo "$2" > "./tcoin/$2.txt" - /bin/chmod 600 "$1/tcoin/base/base.txt" + /bin/chmod 600 "`/usr/bin/realpath -s $1`/tcoin/base/base.txt" fi fi - if [ -d "$1/tcoin/secrets" ] + if [ -d "`/usr/bin/realpath -s $1`/tcoin/secrets" ] then - /bin/echo "Sorry, '$1/tcoin/secrets' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/secrets' already exists." exit 1 else - /bin/mkdir "$1/tcoin/secrets" - /bin/chmod 700 "$1/tcoin/secrets" - if [ -e "$1/tcoin/secrets/pcoin_keys" ] + /bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/secrets" + /bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/secrets" + if [ -e "`/usr/bin/realpath -s $1`/tcoin/secrets/pcoin_keys" ] then - /bin/echo "Sorry, '$1/tcoin/secrets/pcoin_keys' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/secrets/pcoin_keys' already exists." exit 1 else - /bin/echo "" > "$1/tcoin/secrets/pcoin_keys" - /bin/chmod 400 "$1/tcoin/secrets/pcoin_keys" + /bin/echo "" > "`/usr/bin/realpath -s $1`/tcoin/secrets/pcoin_keys" + /bin/chmod 400 "`/usr/bin/realpath -s $1`/tcoin/secrets/pcoin_keys" fi - if [ -e "$1/tcoin/secrets/tcoin_codez" ] + if [ -e "`/usr/bin/realpath -s $1`/tcoin/secrets/tcoin_codez" ] then - /bin/echo "Sorry, '$1/tcoin/secrets/tcoin_codez' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/secrets/tcoin_codez' already exists." exit 1 else - /bin/echo "`cat /dev/urandom | base64 | head -c 512 | tr -d '\n' | tr '+' '-' | tr '/' '_'` `cat /dev/urandom | base64 | head -c 512 | tr -d '\n' | tr '+' '-' | tr '/' '_'`" > "$1/tcoin/secrets/tcoin_codez" - /bin/chmod 400 "$1/tcoin/secrets/tcoin_codez" + /bin/echo "`cat /dev/urandom | base64 | head -c 512 | tr -d '\n' | tr '+' '-' | tr '/' '_'` `cat /dev/urandom | base64 | head -c 512 | tr -d '\n' | tr '+' '-' | tr '/' '_'`" > "`/usr/bin/realpath -s $1`/tcoin/secrets/tcoin_codez" + /bin/chmod 400 "`/usr/bin/realpath -s $1`/tcoin/secrets/tcoin_codez" fi fi - if [ -d "$1/tcoin/bin" ] + if [ -d "`/usr/bin/realpath -s $1`/tcoin/bin" ] then - /bin/echo "Sorry, '$1/tcoin/bin' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/bin' already exists." exit 1 else - /bin/mkdir "$1/tcoin/bin" - /bin/chmod 700 "$1/tcoin/bin" - if [ -e "$1/tcoin/bin/scrypt" ] + /bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/bin" + /bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/bin" + if [ -e "`/usr/bin/realpath -s $1`/tcoin/bin/scrypt" ] then - /bin/echo "Sorry, '$1/tcoin/bin/scrypt' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/bin/scrypt' already exists." exit 1 else - /bin/cp ./scrypt "$1/tcoin/bin/scrypt" - /bin/chmod 500 "$1/tcoin/bin/scrypt" + /bin/cp ./scrypt "`/usr/bin/realpath -s $1`/tcoin/bin/scrypt" + /bin/chmod 500 "`/usr/bin/realpath -s $1`/tcoin/bin/scrypt" fi - if [ -e "$1/tcoin/bin/tcoin" ] + if [ -e "`/usr/bin/realpath -s $1`/tcoin/bin/tcoin" ] then - /bin/echo "Sorry, '$1/tcoin/bin/tcoin' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/bin/tcoin' already exists." exit 1 else /bin/echo '#!/bin/bash -(/usr/bin/g++ '`/bin/pwd`'/tcoin.cpp -o "$1/tcoin/bin/tcoin" -std=c++11) \ -&& (/bin/chmod 550 "$1/tcoin/bin/tcoin") \ -&& (/bin/chmod u+s "$1/tcoin/bin/tcoin")' > "$1/tcoin/bin/compile_tcoin" - /bin/chmod 540 "$1/tcoin/bin/compile_tcoin" +(/usr/bin/g++ '`/bin/pwd`'/tcoin.cpp -o "`/usr/bin/realpath -s $1`/tcoin/bin/tcoin" -std=c++11) \ +&& (/bin/chmod 550 "`/usr/bin/realpath -s $1`/tcoin/bin/tcoin") \ +&& (/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin/bin/tcoin")' > "`/usr/bin/realpath -s $1`/tcoin/bin/compile_tcoin" + /bin/chmod 540 "`/usr/bin/realpath -s $1`/tcoin/bin/compile_tcoin" /bin/echo '#!/bin/bash -/bin/nano '`/bin/pwd`'/tcoin.cpp' > "$1/tcoin/bin/edit_tcoin" - /bin/chmod 540 "$1/tcoin/bin/edit_tcoin" - /bin/bash "$1/tcoin/bin/compile_tcoin" - /bin/ln -s "$1/tcoin/bin/tcoin" "$1/tcoin/bin/compile_tcoin" "$1/tcoin/bin/edit_tcoin" ~/bin +/bin/nano '`/bin/pwd`'/tcoin.cpp' > "`/usr/bin/realpath -s $1`/tcoin/bin/edit_tcoin" + /bin/chmod 540 "`/usr/bin/realpath -s $1`/tcoin/bin/edit_tcoin" + /bin/bash "`/usr/bin/realpath -s $1`/tcoin/bin/compile_tcoin" + /bin/ln -s "`/usr/bin/realpath -s $1`/tcoin/bin/tcoin" "`/usr/bin/realpath -s $1`/tcoin/bin/compile_tcoin" "`/usr/bin/realpath -s $1`/tcoin/bin/edit_tcoin" ~/bin fi - if [ -e "$1/tcoin/bin/pcoin" ] + if [ -e "`/usr/bin/realpath -s $1`/tcoin/bin/pcoin" ] then - /bin/echo "Sorry, '$1/tcoin/bin/pcoin' already exists." + /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/bin/pcoin' already exists." exit 1 else /bin/echo '#!/bin/bash -(/usr/bin/g++ '`/bin/pwd`'/pcoin.cpp -o "$1/tcoin/bin/pcoin" -std=c++11) \ -&& (/bin/chmod 550 "$1/tcoin/bin/pcoin") \ -&& (/bin/chmod u+s "$1/tcoin/bin/pcoin")' > "$1/tcoin/bin/compile_pcoin" - /bin/chmod 540 "$1/tcoin/bin/compile_pcoin" +(/usr/bin/g++ '`/bin/pwd`'/pcoin.cpp -o "`/usr/bin/realpath -s $1`/tcoin/bin/pcoin" -std=c++11) \ +&& (/bin/chmod 550 "`/usr/bin/realpath -s $1`/tcoin/bin/pcoin") \ +&& (/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin/bin/pcoin")' > "`/usr/bin/realpath -s $1`/tcoin/bin/compile_pcoin" + /bin/chmod 540 "`/usr/bin/realpath -s $1`/tcoin/bin/compile_pcoin" /bin/echo '#!/bin/bash -/bin/nano '`/bin/pwd`'/pcoin.cpp' > "$1/tcoin/bin/edit_pcoin" - /bin/chmod 540 "$1/tcoin/bin/edit_pcoin" - /bin/bash "$1/tcoin/bin/compile_pcoin" - /bin/ln -s "$1/tcoin/bin/pcoin" "$1/tcoin/bin/compile_pcoin" "$1/tcoin/bin/edit_pcoin" ~/bin +/bin/nano '`/bin/pwd`'/pcoin.cpp' > "`/usr/bin/realpath -s $1`/tcoin/bin/edit_pcoin" + /bin/chmod 540 "`/usr/bin/realpath -s $1`/tcoin/bin/edit_pcoin" + /bin/bash "`/usr/bin/realpath -s $1`/tcoin/bin/compile_pcoin" + /bin/ln -s "`/usr/bin/realpath -s $1`/tcoin/bin/pcoin" "`/usr/bin/realpath -s $1`/tcoin/bin/compile_pcoin" "`/usr/bin/realpath -s $1`/tcoin/bin/edit_pcoin" ~/bin fi fi /bin/echo "Printing tcoin.cpp (and pcoin.cpp) preprocessor directives." /bin/echo "Paste the following after the #includes inside tcoin.cpp (and pcoin.cpp):" - /bin/echo '#define TCOIN_PATH "$1/tcoin" -#define TCOIN_MSG_PATH "$1/tcoin/messages/" -#define TCOIN_SALT_PATH "$1/tcoin/salts/" -#define TCOIN_PASS_PATH "$1/tcoin/passwords/" -#define TCOIN_PROG_ACT_PATH "$1/tcoin/program_accounting/" + /bin/echo '#define TCOIN_PATH "`/usr/bin/realpath -s $1`/tcoin" +#define TCOIN_MSG_PATH "`/usr/bin/realpath -s $1`/tcoin/messages/" +#define TCOIN_SALT_PATH "`/usr/bin/realpath -s $1`/tcoin/salts/" +#define TCOIN_PASS_PATH "`/usr/bin/realpath -s $1`/tcoin/passwords/" +#define TCOIN_PROG_ACT_PATH "`/usr/bin/realpath -s $1`/tcoin/program_accounting/" #define PROG_ACT_W_SLASH "program_accounting/" -#define PCOIN_KEY_PATH "$1/tcoin/secrets/pcoin_keys" -#define TCOIN_CODEZ_PATH "$1/tcoin/secrets/tcoin_codez" -#define TCOIN_BIN_PATH_W_SPACE "$1/tcoin/bin/tcoin " -#define TCOIN_PATH_W_SLASH "$1/tcoin/" -#define TCOIN_SCRYPT_PATH "$1/tcoin/bin/scrypt"' +#define PCOIN_KEY_PATH "`/usr/bin/realpath -s $1`/tcoin/secrets/pcoin_keys" +#define TCOIN_CODEZ_PATH "`/usr/bin/realpath -s $1`/tcoin/secrets/tcoin_codez" +#define TCOIN_BIN_PATH_W_SPACE "`/usr/bin/realpath -s $1`/tcoin/bin/tcoin " +#define TCOIN_PATH_W_SLASH "`/usr/bin/realpath -s $1`/tcoin/" +#define TCOIN_SCRYPT_PATH "`/usr/bin/realpath -s $1`/tcoin/bin/scrypt"' fi
\ No newline at end of file |