zenith-installer - Zenith Binary Installer

First commit
This commit is contained in:
Rene V. Vergara A. 2024-07-01 22:01:18 -04:00
parent 28f8650d68
commit 898de4b611
19 changed files with 93 additions and 274 deletions

View file

@ -199,14 +199,16 @@ processUri user pwd =
main :: IO () main :: IO ()
main = do main = do
config <- load ["/home/zenith/zenith.cfg"] config <- load [ "$(HOME)/Zenith/zenith.cfg" ]
args <- getArgs args <- getArgs
dbFilePath <- require config "dbFilePath" --dbFilePath <- require config "dbFilePath"
nodeUser <- require config "nodeUser" nodeUser <- require config "nodeUser"
nodePwd <- require config "nodePwd" nodePwd <- require config "nodePwd"
zebraPort <- require config "zebraPort" zebraPort <- require config "zebraPort"
zebraHost <- require config "zebraHost" zebraHost <- require config "zebraHost"
let myConfig = Config dbFilePath zebraHost zebraPort dbFP <- getZenithPath
let dbFilePath = dbFP ++ "zenith.db"
let myConfig = Config (T.pack dbFilePath) zebraHost zebraPort
if not (null args) if not (null args)
then do then do
case head args of case head args of
@ -224,7 +226,7 @@ main = do
"rescan" -> clearSync myConfig "rescan" -> clearSync myConfig
_ -> printUsage _ -> printUsage
else printUsage else printUsage
printUsage :: IO () printUsage :: IO ()
printUsage = do printUsage = do
putStrLn "zenith [command] [parameters]\n" putStrLn "zenith [command] [parameters]\n"

View file

@ -2,7 +2,7 @@ packages:
./*.cabal ./*.cabal
zcash-haskell/zcash-haskell.cabal zcash-haskell/zcash-haskell.cabal
with-compiler: ghc-9.4.8 with-compiler: ghc-9.6.5
source-repository-package source-repository-package
type: git type: git

View file

@ -113,7 +113,7 @@ constraints: any.Cabal ==3.8.1.0,
any.foreign-rust ==0.1.0, any.foreign-rust ==0.1.0,
any.generically ==0.1.1, any.generically ==0.1.1,
any.generics-sop ==0.5.1.4, any.generics-sop ==0.5.1.4,
any.ghc ==9.4.8, any.ghc ==9.6.5,
any.ghc-bignum ==1.3, any.ghc-bignum ==1.3,
any.ghc-boot ==9.4.8, any.ghc-boot ==9.4.8,
any.ghc-boot-th ==9.4.8, any.ghc-boot-th ==9.4.8,

View file

@ -1,21 +0,0 @@
FROM ubuntu:22.04
MAINTAINER Rene V. Vergara A. <rvergara59@kprotonmail.com>
RUN apt update
RUN apt -y install libxss-dev
RUN apt -y install libxrandr-dev
RUN apt -y install libsecp256k1-dev
RUN apt -y install xclip
RUN mkdir /home/zenith
RUN useradd -ms /bin/bash zenusr
COPY bash_rc_adm /root/.bashrc
COPY bash_rc_usr /home/zenusr/.bashrc
COPY zenith /usr/local/bin
COPY librustzcash_wrapper.so /usr/local/lib
COPY sapling-spend.params /usr/local/lib
COPY sapling-output.params /usr/local/lib
CMD ["/bin/bash"]

View file

@ -1,100 +0,0 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi
export LD_LIBRARY_PATH=/usr/local/lib

View file

@ -1,118 +0,0 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
export LD_LIBRARY_PATH=/usr/local/lib

View file

@ -1,24 +0,0 @@
#!/bin/bash
ZFOLDER=~/Zenith
IMAGE_NAME=zenith-docker:0.5.3.0
# Check if data folder exists
if [ ! -d "$ZFOLDER" ]; then
echo "Error starting Zenith image"
echo "Zenith configurtion and data folder ($ZFOLDER) does not exists."
echo "Aborting process..."
exit
fi
# Check if the image exists locally
if [[ "$(docker images -q $IMAGE_NAME 2> /dev/null)" == "" ]]; then
echo "Error starting Zenith image"
echo "Image $IMAGE_NAME not found locally."
echo "Aborting process..."
exit
fi
docker run -it --mount src=$ZFOLDER,target=/home/zenith,type=bind --net=host $IMAGE_NAME
# End

Binary file not shown.

View file

@ -0,0 +1,12 @@
Para instalar solo el ejecutable
1.- Instalar el programa compilado utilizando el siguiente commando
sudo zeninstall
2.- Crear los elementos basicos y la configuracion default
zenconfig

View file

@ -1,5 +1,5 @@
nodeUser = "user" nodeUser = "user"
nodePwd = "superSecret" nodePwd = "superSecret"
dbFilePath = "/home/zenith/zenith.db" dbFileName = "zenith.db"
zebraHost = "127.0.0.1" zebraHost = "127.0.0.1"
zebraPort = 18232 zebraPort = 18232

View file

@ -0,0 +1,29 @@
#!/bin/bash
echo
echo Zenith Full Node Wallet Config
echo
if [ -d $HOME/Zenith ]; then
echo "Configuration files found, please backup your Zenith folder or"
echo "remove it before trying to configure Zenith again."
echo
exit
else
if [ -f /usr/local/bin/zenith ] && [ -f /usr/local/bin/librustzcash_wrapper.so ]; then
echo "Creating Zenith folder ...."
mkdir -p $HOME/Zenith
echo "Copying default configuration ...."
cp ./cfg/zenith.cfg $HOME/Zenith/
echo "Configuring library path ...."
if [ ! grep -q "LD_LIBRARY_PATH" "$HOME/.bashrc" ]; then
echo 'export LD_LIBRARY_PATH=/usr/local/lib' | tee -a $HOME/.bashrc
echo "Loading configuration ...."
source $HOME/.bashrc
else
echo "Library path configured ...."
fi
echo "Zenith is ready!!"
else
echo "Please, install Zenith first!!!"
fi
echo
fi

View file

@ -0,0 +1,28 @@
#!/bin/bash
echo
echo "Zenith Full Node Wallet Installer (Version 0.5.3.0)"
echo
if [ "$UID" != "0" ]; then
echo "Please run the installer using 'sudo'!!!"
echo
exit
else
echo "Starting zenith installation ...."
echo
echo "Installing dependencies ...."
apt update
apt -y install libxss-dev
apt -y install libxrandr-dev
apt -y install libsecp256k1-dev
apt -y install xclip
apt -y clean
echo
echo "Installing zenith ...."
cp ./bin/zenith /usr/local/bin
cp ./lib/librustzcash_wrapper.so /usr/local/lib
cp ./lib/sapling-spend.params /usr/local/lib
cp ./lib/sapling-output.params /usr/local/lib
echo
echo "Zenith installed !!!"
echo
fi

View file

@ -104,7 +104,7 @@ import Zenith.Types
, UnifiedAddressDB(..) , UnifiedAddressDB(..)
, ZcashNetDB(..) , ZcashNetDB(..)
) )
import Zenith.Utils (displayTaz, displayZec, jsonNumber, showAddress) import Zenith.Utils (displayTaz, displayZec, jsonNumber, showAddress, getZenithPath)
data Name data Name
= WList = WList
@ -1574,9 +1574,11 @@ sendTransaction ::
-> IO () -> IO ()
sendTransaction pool chan zHost zPort znet accId bl amt ua memo = do sendTransaction pool chan zHost zPort znet accId bl amt ua memo = do
BC.writeBChan chan $ TickMsg "Preparing transaction..." BC.writeBChan chan $ TickMsg "Preparing transaction..."
zenithPath <- getZenithPath
let zenithLogPath = ( zenithPath ++ "zenith.log" )
outUA <- parseAddress ua outUA <- parseAddress ua
res <- res <-
runFileLoggingT "/home/zenith/zenith.log" $ runFileLoggingT zenithLogPath $
prepareTx pool zHost zPort znet accId bl amt outUA memo prepareTx pool zHost zPort znet accId bl amt outUA memo
BC.writeBChan chan $ TickMsg "Transaction ready, sending to Zebra..." BC.writeBChan chan $ TickMsg "Transaction ready, sending to Zebra..."
case res of case res of

View file

@ -9,6 +9,7 @@ import Data.Scientific (Scientific(..), scientific)
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Text.Encoding as E import qualified Data.Text.Encoding as E
import System.Process (createProcess_, shell) import System.Process (createProcess_, shell)
import System.Directory
import Text.Regex.Posix import Text.Regex.Posix
import ZcashHaskell.Orchard (encodeUnifiedAddress, isValidUnifiedAddress) import ZcashHaskell.Orchard (encodeUnifiedAddress, isValidUnifiedAddress)
import ZcashHaskell.Sapling (isValidShieldedAddress) import ZcashHaskell.Sapling (isValidShieldedAddress)
@ -72,3 +73,10 @@ copyAddress a =
void $ void $
createProcess_ "toClipboard" $ createProcess_ "toClipboard" $
shell $ "echo " ++ T.unpack (addy a) ++ " | xclip -r -selection clipboard" shell $ "echo " ++ T.unpack (addy a) ++ " | xclip -r -selection clipboard"
-- | Get current user and build zenith path
getZenithPath :: IO String
getZenithPath = do
d <- getHomeDirectory
let homeDirectory = d
return (homeDirectory ++ "/Zenith/")

View file

@ -52,7 +52,7 @@ library
, vty-crossplatform , vty-crossplatform
, secp256k1-haskell , secp256k1-haskell
, pureMD5 , pureMD5
, ghc , ghc >=9.6.5
, haskoin-core , haskoin-core
, hexstring , hexstring
, http-client , http-client
@ -77,7 +77,8 @@ library
, vty , vty
, word-wrap , word-wrap
, zcash-haskell , zcash-haskell
--pkgconfig-depends: rustzcash_wrapper , directory
--pkgconfig-depends: rustzcash_wrapper
default-language: Haskell2010 default-language: Haskell2010
executable zenith executable zenith