summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBMF <d3@dharma.lol>2014-01-14 23:53:59 (GMT)
committer BMF <d3@dharma.lol>2014-01-14 23:53:59 (GMT)
commite65f4478f3a7d8e1e316edd9e74a90405ee4cea9 (patch)
tree1c77ddbbaf8c82a9987e201f25ba0dab2301d896
parent3f3a364c974081bb8634ef8358f30b2e8e87ae8c (diff)
local install fixed. custom install always have some poison.unstable
-rwxr-xr-xinstall-sx.sh259
1 files changed, 157 insertions, 102 deletions
diff --git a/install-sx.sh b/install-sx.sh
index 6830aa4..5e59924 100755
--- a/install-sx.sh
+++ b/install-sx.sh
@@ -18,30 +18,37 @@ set -e
echo
echo " [+] Welcome to S(pesmilo)X(changer)."
echo
-sleep 0.3
help_install(){
- if [ "$1" = "help" ]; then
- echo
- echo " [+] Install script help:"
- echo " With this script you can install libbitcoin, libwallet, obelisk and sx tools."
- echo " You can choose betwen a local, custom or a standard (root) install."
- echo " To execute this script and build a local instalation, run:"
- echo " <bash install-sx.sh PATH/...>"
- echo " To execute this script and build a custom instalation type:"
- echo " <sudo bash install-sx.sh /PATH/...>"
- echo " To execute this script and build a standard (root) instalation type:"
- echo " <sudo bash install-sx.sh>"
- echo " The standard path to the source instalation is /usr/local/src."
- echo " The stardard path for the conf files is /etc."
- echo " Requires sudo."
- echo
- exit
+ echo
+ echo " [+] Install script help:"
+ echo " With this script you can install libbitcoin, libwallet, obelisk and sx tools."
+ echo " You can choose betwen a local, custom or a standard (root) install."
+ echo " To execute this script and build a local instalation, run:"
+ echo " <bash install-sx.sh PATH/...>"
+ echo " To execute this script and build a custom instalation type:"
+ echo " <sudo bash install-sx.sh /PATH/...>"
+ echo " To execute this script and build a standard (root) instalation type:"
+ echo " <sudo bash install-sx.sh>"
+ echo " The standard path to the source instalation is /usr/local/src."
+ echo " The stardard path for the conf files is /etc."
+ echo " Requires sudo."
+ echo
+}
+
+
+function prompt_user(){
+ # Prompt user before continuing
+ read -p "Would you like to continue the installation? [Y/n] "
+ echo # (optional) move to a new line
+ if [[ $REPLY =~ ^[Nn]$ ]]; then
+ echo "Install aborted."
+ exit
fi
}
# Custom path:
-custom_install(){
+custom_root_install(){
if [[ "$1" = "/*" ]]; then
if [ `id -u` = "0" ]; then
INSTALL_PREFIX=$1
@@ -60,81 +67,77 @@ custom_install(){
}
# Local path:
-local_install(){
- if [[ -n "$1" ]]; then
- RELATIVE=`pwd`
- INSTALL_PREFIX=$RELATIVE/$1
- CONF_DIR=$INSTALL_PREFIX/etc
- RUN_LDCONFIG=
- ROOT_INSTALL=0
- elif [[ -z "$1" ]]; then
- echo " You need to set a path to build this instalation."
- echo " To setup a local path to install type:"
- echo " <bash install PATH/...>"
- echo " To setup a custom path or to setup a standard (root) path to install,"
- echo " exit with CTRL+c and run this script as root:"
- echo " <sudo bash install-sx.sh /PATH> for a custom install, or:"
- echo " <sudo bash install-sx.sh> for a standard (root) install."
- echo " Help menu:"
- echo " <bash install-sx.sh help>"
- exit
- fi
+relative_local_install(){
+ RELATIVE=`pwd`
+ INSTALL_PREFIX="$RELATIVE/$1"
+ CONF_DIR="$INSTALL_PREFIX/etc"
+ RUN_LDCONFIG=
+ ROOT_INSTALL=0
+}
+
+absolute_local_install(){
+ INSTALL_PREFIX=$1
+ CONF_DIR="$INSTALL_PREFIX/etc"
+ RUN_LDCONFIG=
+ ROOT_INSTALL=0
}
# Standard (root) path:
root_install(){
- if [[ -z "$1" ]]; then
- if [ `id -u` = "0" ]; then
+ if [ `id -u` = "0" ]; then
INSTALL_PREFIX=/usr/local
CONF_DIR=/etc
RUN_LDCONFIG=ldconfig
ROOT_INSTALL=1
- elif [ `id -u` != "0" ]; then
- local_path
- fi
+ else
+ echo
+ echo "[+] ERROR: This script must be run as root." 1>&2
+ echo
+ echo "<sudo bash install-sx.sh>"
+ echo
+ exit
fi
}
+D_DEPENDENCIES="\
+git build-essential autoconf apt-utils libtool libboost-all-dev \
+pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev \
+libconfig++-dev libncurses5-dev"
+
+U_DEPENDENCIES="\
+git build-essential autoconf apt-utils libtool libboost1.49-all-dev \
+pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev \
+libconfig++8-dev libncurses5-dev"
+
+F_DEPENDENCIES=
+
install_dependencies(){
flavour_id=`cat /etc/*-release | egrep -i "^ID=" | cut -f 2 -d "="`
echo " Flavour: $flavour_id."
echo
+ if [ "$flavour_id" = "debian" ]; then
+ INSTALL_COMMAND="sudo apt-get install -y $D_DEPENDENCIES"
+ elif [ "$flavour_id" = "ubuntu" ]; then
+ INSTALL_COMMAND="sudo apt-get install -y $U_DEPENDENCIES"
+ #elif [ "$flavour_id" = "fedora" ]; then
+ # INSTALL_COMMAND="...??? $F_DEPENDENCIES"
+ else
+ echo
+ echo " [+] ERROR: No GNU/Linux flavour properly detected: $flavour_id" 1>&2
+ echo
+ echo " Please, review the script."
+ echo
+ exit
+ fi
+
if [ "$ROOT_INSTALL" = 1 ]; then
- if [ "$flavour_id" = "debian" ]; then
- sleep 0.5
- apt-get install -y git build-essential autoconf apt-utils libtool libboost-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++-dev libncurses5-dev
- elif [ "$flavour_id" = "ubuntu" ]; then
- sleep 0.5
- apt-get install -y git build-essential autoconf apt-utils libtool libboost1.49-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++8-dev libncurses5-dev
-# elif [ "$flavour_id" = "fedora" ]; then
-# sleep 0.5
-# $F_DEPENDENCIES
- else
- echo
- echo " [+] ERROR: No GNU/Linux flavour properly detected: $flavour_id" 1>&2
- echo
- echo " Please, review the script."
- echo
- exit
- fi
- elif [ "$ROOT_INSTALL" = 1 ]; then
- if [ "$flavour_id" = "debian" ]; then
- sleep 0.5
- sudo apt-get install -y git build-essential autoconf apt-utils libtool libboost-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++-dev libncurses5-dev
- elif [ "$flavour_id" = "ubuntu" ]; then
- sleep 0.5
- sudo apt-get install -y git build-essential autoconf apt-utils libtool libboost1.49-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++8-dev libncurses5-dev
-# elif [ "$flavour_id" = "fedora" ]; then
-# sleep 0.5
-# sudo $F_DEPENDENCIES
- else
- echo
- echo " [+] ERROR: No GNU/Linux flavour properly detected: $flavour_id" 1>&2
- echo
- echo " Please, review the script."
- echo
- exit
- fi
+ $INSTALL_COMMAND
+ else
+ echo "Please run this command to install the neccessary dependencies before continuing."
+ echo
+ echo " $INSTALL_COMMAND"
+ echo
+ prompt_user
fi
}
@@ -265,33 +268,85 @@ install_sx(){
show_finish_install_info(){
echo " --> Installation finished!"
- if [ "$ROOT_INSTALL" = "1" ]; then
+ echo
+ echo "Config Files are in: $CONF_DIR"
+ echo " obelisk configuration files: $CONF_DIR/obelisk/*.cfg"
+ echo " sx configuration file: ~/.sx.cfg (see $INSTALL_PREFIX/share/sx/sx.cfg for an example config file)"
+ echo
+ echo "Documentation available /usr/local/doc:"
+ echo " libbitcoin doc: $INSTALL_PREFIX/share/doc/libbitcoin/"
+ echo " obelisk doc: $INSTALL_PREFIX/share/doc/obelisk/"
+ echo " sx doc: $INSTALL_PREFIX/share/doc/sx/"
+ echo
+ echo "To setup a obelisk node, you will need obworker and obbalancer daemons running."
+ echo "Run <sudo bash $SRC_DIR/obelisk-git/scripts/setup.sh> to create, configure and start the daemons."
+ echo
+ echo "You may need to reload your shell before continuing."
+}
+
+if [ "$1" = "--help" ] || [ "$1" == "-h" ]; then
+ help_install
+ exit
+fi
+
+if [ "$#" == "1" ]; then
+ # Perform install to use specified path.
+ if [[ $1 =~ ^\/home ]]; then
+ # Install without needing root (path begins with /home)
+ absolute_local_install $1
+ elif [[ $1 =~ ^\/ ]]; then
+ # Install needing root (path begins with / but not /home)
+ custom_root_install $1
+ else
+ # Relative path: root not needed
+ relative_local_install $1
+ fi
+
+ if [ "$ROOT_INSTALL" = "0" ]; then
+ PROFILE_FILE=~/.bashrc
+ else
+ PROFILE_FILE=/etc/profile
+ fi
+
+ EXPORT_LD="export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib"
+ EXPORT_PKG="export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig"
+ EXPORT_PATH="export PATH=\$PATH:$INSTALL_PREFIX/bin"
+
+ # If variables are not in your $PROFILE_FILE then adds them.
+ # We check if they're there already by looking for the "Added by..." line
+ if ! grep -q "Added by install-sx" $PROFILE_FILE; then
+ echo "# Added by install-sx" >> $PROFILE_FILE
+ echo "$EXPORT_LD" >> $PROFILE_FILE
+ echo "$EXPORT_PKG" >> $PROFILE_FILE
+ echo "$EXPORT_PATH" >> $PROFILE_FILE
+ elif [ "$ROOT_INSTALL" = "1" ]; then
+ # TODO: Should use sed to add path if it doesn't exist (hard mode).
+ echo "Previous values detected. They may need manual updating if"
+ echo "creating multiple custom path installs on the same system."
echo
- echo " Config Files are in: $CONF_DIR"
- echo " obelisk configuration files: $CONF_DIR/obelisk/*.cfg"
- echo " sx configuration file: ~/.sx.cfg (see $INSTALL_PREFIX/share/sx/sx.cfg for an example config file)"
- echo
- echo " Documentation available /usr/local/doc:"
- echo " libbitcoin doc: $INSTALL_PREFIX/share/doc/libbitcoin/"
- echo " obelisk doc: $INSTALL_PREFIX/share/doc/obelisk/"
- echo " sx doc: $INSTALL_PREFIX/share/doc/sx/"
+ echo " $EXPORT_LD"
+ echo " $EXPORT_PKG"
+ echo " $EXPORT_PATH"
echo
- elif [ "$ROOT_INSTALL" = "0" ]; then
+ echo "Patches to handle this case are welcome."
echo
- echo " Add these lines to your ~/.bashrc"
- echo " export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib"
- echo " export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig"
- echo " export PATH=\$PATH:$INSTALL_PREFIX/bin"
+ prompt_user
fi
- echo
- echo " To setup a obelisk node, you will need obworker and obbalancer daemons running."
- echo " Run <sudo bash $SRC_DIR/obelisk-git/scripts/setup.sh> to create, configure and start the daemons."
- echo
-}
-case "$1" in
- "/*") custom_install ; install_dependencies ; add_src_dir ; install_libbitcoin ; install_libwallet ; install_obelisk ; install_sx ; show_finish_install_info ;;
- "1") local_install ; install_dependencies ; add_src_dir ; install_libbitcoin ; install_libwallet ; install_obelisk ; install_sx ; show_finish_install_info ;;
- "") root_install ; install_dependencies ; add_src_dir ; install_libbitcoin ; install_libwallet ; install_obelisk ; install_sx ; show_finish_install_info;;
- "--help") help_install ;;
-esac
+ # Actually run exports do script can continue running.
+ $EXPORT_LD
+ $EXPORT_PKG
+ source $PROFILE_FILE
+else
+ # Default root install
+ root_install
+fi
+
+install_dependencies
+add_src_dir
+install_libbitcoin
+install_libwallet
+install_obelisk
+install_sx
+show_finish_install_info
+