Commit fb78c335 authored by mlsuyt2718's avatar mlsuyt2718

add parameter d for generating salt and password randomly and fill in config file

parent 1ed196cc
#!/usr/bin/env sh
# gmixer-py installation : installation de gmixer-py : mixeur de monnaie libre
# License : Creative Commons http://creativecommons.org/licenses/by-nd/4.0/deed.fr
# Project : https://git.duniter.org/tuxmain/gmixer-py
# contact mail : <pytlin@protonmail.com>
VERSION="2019.05.03"
set -e
#set -x
# VARIABLES
blanc="\033[1;37m"
blank="\033[1;37m"
grey="\033[0;37m"
pink="\033[0;35m"
red="\033[1;31m"
......@@ -25,15 +27,18 @@ noError="false"
# Start of script
printf "\n%b$green\n"
printf "#########################################################\n"
printf "# #\n"
printf "# Installation script GMIXER #\n"
printf "# #\n"
printf "# Tested on Debian 9.8 x64 #\n"
printf "# by @pytlin #\n"
printf "# #\n"
printf "# For any bug please send mail to pytlin@protonmail.com #\n"
printf "#########################################################\n"
printf "######################################################################\n"
printf "# #\n"
printf "# Installation script GMIXER #\n"
printf "# #\n"
printf "# Tested on Debian 9.8 x64 #\n"
printf "# by @pytlin #\n"
printf "# #\n"
printf "# For any bug please send mail to pytlin@protonmail.com #\n"
printf "# OR #\n"
printf "# Create an issue here : https://git.duniter.org/tuxmain/gmixer-py #\n"
printf "# #\n"
printf "######################################################################\n"
printf %b "\t\t\t$VERSION\n"
printf %b "$rescolor\n"
sleep 3
......@@ -89,13 +94,54 @@ helpFunction ()
printf "\t\t 1 => mixer node without tor (default value)\n"
printf "\t\t 2 => mixer node connected to tor\n"
printf "\t\t 3 => mixer node into tor network : hidden service\n"
#printf "\t-g This parameter permits to generate randomly the public key\n"
printf "\t-g This parameter permits to generate randomly the salt and password\n"
#printf "\t-d This parameter permits to launch gmixer in daemon\n"
printf "\t-v This parameter activate verbose mode\n"
printf "\t-h This parameter print out the help\n"
exit 1 # Exit script after printing help
}
helpFunctionWithoutExit ()
{
printf ""
echo "Usage: $0 -t [1,2,3] -v -h\n"
printf "\t-t This parameter enable to create onion node\n"
printf "\t\t 1 => mixer node without tor (default value)\n"
printf "\t\t 2 => mixer node connected to tor\n"
printf "\t\t 3 => mixer node into tor network : hidden service\n"
printf "\t-g This parameter permits to generate randomly the salt and password\n"
#printf "\t-d This parameter permits to launch gmixer in daemon\n"
printf "\t-v This parameter activate verbose mode\n"
printf "\t-h This parameter print out the help\n"
}
# Read secret string #read -s is not compliant POSIX
readSecret ()
{
# Disable echo.
stty -echo
# Set up trap to ensure echo is enabled before exiting if the script
# is terminated while echo is disabled.
trap 'stty echo' EXIT
# Read secret.
read "$@"
# Enable echo.
stty echo
trap - EXIT
# Print a newline because the newline entered by the user after
# entering the passcode is not echoed. This ensures that the
# next line of output begins at a new line.
echo
}
#retrieve public ip
......@@ -558,18 +604,13 @@ configurationTor () {
generateRandomSalt () {
salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-44} | head -n 1)
pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-44} | head -n 1)
echo $salt
echo $pass
}
generateRandomPass () {
salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-44} | head -n 1)
echo $salt
}
generateRandomKey () {
generateRandomPass () {
pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-44} | head -n 1)
echo $pass
}
main () {
......@@ -590,11 +631,11 @@ main () {
#for centos
#printf "\n%bInstallation of g++...%b\n" "${yellow}" "${rescolor}"
#sudo yum -y install gcc-c++
printf "%bBuild of cmake 3.14.3 (necessary for leveldb 1.21), this step may take time, don't hesitate to take a coffee...%b" "${yellow}" "${rescolor}"
printf "%bBuild of cmake 3.14.3 (necessary for leveldb 1.21), this step may take time, don't hesitate to take a tea...%b" "${yellow}" "${rescolor}"
installOrBuildCmake > /dev/null
checkInstallCmake > /dev/null
printOkKo
printf "%bBuild of leveldb 1.21, this step may take time, don't hesitate to take a coffee....%b" "${yellow}" "${rescolor}"
printf "%bBuild of leveldb 1.21, this step may take time, don't hesitate to take a beer....%b" "${yellow}" "${rescolor}"
buildLevelDB > /dev/null
checkBuildLevelDB > /dev/null
printOkKo
......@@ -648,6 +689,27 @@ main () {
fi
fi
fi
if [ "$parameterG" = "true" ]
then
printf "%bGenerate Salt and Password...%b" "${yellow}" "${rescolor}"
salt=$(generateRandomSalt)
password=$(generateRandomPass)
sed -i "s/\"id_salt\": \"\",/\"id_salt\": \"`echo $salt`\",/g" $HOME/.gmixer/config.json
sed -i "s/\"id_password\": \"\"/\"id_password\": \"`echo $password`\"/g" $HOME/.gmixer/config.json
checkCommand
printOkKo
else
printf "%bEnter Salt and Password...%b\n" "${yellow}" "${rescolor}"
printf "%bEnter Salt:%b" "${blue}" "${rescolor}"
readSecret salt
printf "%bEnter Password:%b" "${blue}" "${rescolor}"
readSecret password
sed -i "s/\"id_salt\": \"\",/\"id_salt\": \"`echo $salt`\",/g" $HOME/.gmixer/config.json
sed -i "s/\"id_password\": \"\"/\"id_password\": \"`echo $password`\"/g" $HOME/.gmixer/config.json
fi
printf "%bLaunch GMixer : %b\n" "${yellow}" "${rescolor}"
launchGMixer
......@@ -673,11 +735,11 @@ mainVerbose () {
#for centos
#printf "\n%bInstallation of g++...%b\n" "${yellow}" "${rescolor}"
#sudo yum -y install gcc-c++
printf "%bBuild of cmake 3.14.3 (necessary for leveldb 1.21), this step may take time, don't hesitate to take a coffee...%b" "${yellow}" "${rescolor}"
printf "%bBuild of cmake 3.14.3 (necessary for leveldb 1.21), this step may take time, don't hesitate to take a tea...%b" "${yellow}" "${rescolor}"
installOrBuildCmake
checkInstallCmake
printOkKo
printf "%bBuild of leveldb 1.21, this step may take time, don't hesitate to take a coffee....%b" "${yellow}" "${rescolor}"
printf "%bBuild of leveldb 1.21, this step may take time, don't hesitate to take a beer....%b" "${yellow}" "${rescolor}"
buildLevelDB
checkBuildLevelDB
printOkKo
......@@ -733,15 +795,22 @@ mainVerbose () {
if [ "$parameterG" = "true" ]
then
printf "%bGenerate Random Key...%b" "${yellow}" "${rescolor}"
generateRandomSalt
generateRandomPass
printf "%bGenerate Salt and Password...%b" "${yellow}" "${rescolor}"
salt=$(generateRandomSalt)
password=$(generateRandomPass)
sed -i "s/\"id_salt\": \"\",/\"id_salt\": \"`echo $salt`\",/g" $HOME/.gmixer/config.json
sed -i "s/\"id_password\": \"\"/\"id_password\": \"`echo $password`\"/g" $HOME/.gmixer/config.json
checkCommand
printOkKo
else
printf "%bEnter Salt and Password...%b" "${yellow}" "${rescolor}"
printf "%bEnter Salt and Password...%b\n" "${yellow}" "${rescolor}"
printf "%bEnter Salt:%b" "${blue}" "${rescolor}"
readSecret salt
printf "%bEnter Password:%b" "${blue}" "${rescolor}"
readSecret password
sed -i "s/\"id_salt\": \"\",/\"id_salt\": \"`echo $salt`\",/g" $HOME/.gmixer/config.json
sed -i "s/\"id_password\": \"\"/\"id_password\": \"`echo $password`\"/g" $HOME/.gmixer/config.json
fi
printf "%bLaunch GMixer : %b\n" "${yellow}" "${rescolor}"
......@@ -782,10 +851,17 @@ fi
if [ "$parameterV" = "false" ]; then
printf "\n"
helpFunctionWithoutExit
printf "\n"
main
exit 0
else
printf "\n"
helpFunctionWithoutExit
printf "\n"
mainVerbose
exit 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment