Skip to content
Snippets Groups Projects
Commit c3e1ebd4 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Change intall script

parent ab3af3b3
No related branches found
No related tags found
No related merge requests found
......@@ -33,77 +33,10 @@ ucoin_download() {
fi
}
ucoin_is_ubuntu_install() {
local distribution
distribution=`cat /etc/*-release file 2>/dev/null | grep "Ubuntu"`
if [[ "$distribution" = *Ubuntu* ]]; then
return 0
else
return 1
fi
}
ucoin_is_debian_install() {
local distribution
distribution=`cat /etc/*-release file 2>/dev/null | grep "Debian"`
if [[ "$distribution" = *Debian* ]]; then
return 0
else
return 1
fi
}
ucoin_is_fedora_install() {
local distribution
distribution=`cat /etc/*-release file 2>/dev/null | grep "Fedora"`
if [[ "$distribution" = *Fedora* ]]; then
return 0
else
return 1
fi
}
install_ucoin_from_git() {
if ! ucoin_has "make"; then
if ucoin_is_ubuntu_install; then
echo "=> make is not available. Please install 'build-essential' package with 'sudo apt-get install build-essential' command, then retry uCoin installation."
exit 1
fi
if ucoin_is_debian_install; then
echo "=> make is not available. Please install 'build-essentials' package with 'apt-get install build-essential' command as root, then retry uCoin installation."
exit 1
fi
fi
if ! ucoin_has "g++"; then
if ucoin_is_ubuntu_install; then
echo "=> g++ is not available. Please install 'build-essential' package with 'sudo apt-get install build-essential' command, then retry uCoin installation."
exit 1
elif ucoin_is_debian_install; then
echo "=> g++ is not available. Please install 'build-essentials' package with 'apt-get install build-essential' command as root, then retry uCoin installation."
exit 1
else
echo "=> g++ is not available"
fi
return 11
fi
if ! ucoin_has "python"; then
if ucoin_is_ubuntu_install; then
echo "=> python is not available. Please install 'build-essential' package with 'sudo apt-get install build-essential' command, then retry uCoin installation."
exit 1
elif ucoin_is_debian_install; then
echo "=> python is not available. Please install 'build-essentials' package with 'apt-get install build-essential' command as root, then retry uCoin installation."
exit 1
else
echo "=> python is not available"
fi
return 11
fi
local PREVIOUS_PATH
PREVIOUS_PATH=$PATH
if ucoin_has "git"; then
# Git is here: clone repository
if [ -d "$UCOIN_DIR/.git" ]; then
echo "=> ucoin is already installed in $UCOIN_DIR, trying to update using git"
printf "\r=> "
......@@ -126,33 +59,6 @@ install_ucoin_from_git() {
cd "$UCOIN_DIR" && command git branch -D master >/dev/null 2>&1
fi
fi
else
# Fallback: git is not available, we download sources tarball
local UCOIN_SRC_TARBALL=https://github.com/ucoin-io/ucoin/archive/$(ucoin_latest_version).tar.gz
local UCOIN_SRC_ARCHIVE=$UCOIN_DIR/ucoin_$(ucoin_latest_version).tar.gz
local UCOIN_SRC_FOLDER=$UCOIN_DIR/ucoin-$(ucoin_latest_version | sed -e s/^v//)
echo "=> Downloading '$UCOIN_SRC_TARBALL' to '$UCOIN_SRC_ARCHIVE'"
mkdir -p "$UCOIN_DIR"
ucoin_download "$UCOIN_SRC_TARBALL" -o "$UCOIN_SRC_ARCHIVE" || {
echo >&2 "Failed to download '$UCOIN_SRC_TARBALL'"
return 7
}
echo "=> Extracting..."
cd "$UCOIN_DIR" && tar xzf $UCOIN_SRC_ARCHIVE || {
echo >&2 "Failed to extract '$UCOIN_SRC_ARCHIVE'"
return 8
}
echo "=> Moving..."
mv $UCOIN_SRC_FOLDER/* $UCOIN_DIR || {
echo >&2 "Failed to move files from '$UCOIN_SRC_FOLDER'"
return 9
}
echo "=> Cleaning ucoin sources..."
rm -Rf $UCOIN_ARCHIVE $UCOIN_SRC_ARCHIVE $UCOIN_SRC_FOLDER || {
echo >&2 "Failed to clean ucoin sources"
return 10
}
fi
# Download Nodejs
local NVER="5.8.0";
......@@ -183,45 +89,13 @@ install_ucoin_from_git() {
# Install uCoin dependencies (NPM modules)
export PATH=$PATH:$UCOIN_DIR/node/bin/
npm install -g node-pre-gyp
export PATH=$PATH:$UCOIN_DIR/node/lib/node_modules/node-pre-gyp/bin/
npm install
export PATH=$PREVIOUS_PATH
return
}
install_ucoin_as_script() {
local ARCH="32"
local X64=`uname -a | grep "x86_64"`
if [ ! -z "$X64" ]; then
ARCH="64"
fi
local UCOIN_SOURCE_LOCAL
UCOIN_SOURCE_LOCAL=https://github.com/ucoin-io/ucoin/releases/download/$(ucoin_latest_version)/ucoin-x${ARCH}.tar.gz
local UCOIN_ARCHIVE
UCOIN_ARCHIVE=$UCOIN_DIR/ucoin.tar.gz
# Downloading to $UCOIN_DIR
mkdir -p "$UCOIN_DIR"
if [ -d "$UCOIN_DIR/ucoin" ]; then
echo "=> ucoin is already installed in $UCOIN_DIR, trying to update"
else
echo "=> Downloading ucoin binary to '$UCOIN_DIR'"
fi
ucoin_download "$UCOIN_SOURCE_LOCAL" -o "$UCOIN_ARCHIVE" || {
echo >&2 "Failed to download '$UCOIN_SOURCE_LOCAL'"
return 1
}
echo "=> Extracting ucoin sources..."
tar xzf $UCOIN_ARCHIVE -C $UCOIN_DIR || {
echo >&2 "Failed to extract $UCOIN_ARCHIVE to $UCOIN_DIR"
return 2
}
echo "=> Cleaning..."
rm $UCOIN_ARCHIVE || {
echo >&2 "Failed to remove $UCOIN_ARCHIVE"
return 2
}
}
#
# Detect profile file if not specified as environment variable
# (eg: PROFILE=~/.myprofile)
......@@ -264,46 +138,31 @@ ucoin_detect_profile() {
fi
}
ucoin_is_available_for_distribution() {
local distribution
local distribution_deb
local distribution_fedora
distribution=`cat /etc/*-release file 2>/dev/null | grep "Ubuntu"`
distribution_deb=`cat /etc/*-release file 2>/dev/null | grep "Debian"`
distribution_fedora=`cat /etc/*-release file 2>/dev/null | grep "Fedora"`
ucoin_do_install() {
if [[ "$distribution" = *Ubuntu\ 14* ]] || [[ "$distribution" = *Ubuntu\ 15* ]] || [[ "$distribution_deb" = *Debian*8*jessie* ]] || [[ "$distribution_fedora" = *Fedora\ 23* ]]; then
local X64=`uname -a | grep "x86_64"`
if [ ! -z "$X64" ]; then
return 0
# Check required commands
if ! ucoin_has "git"; then
echo "=> git is not available. You will likely need to install 'git' package."
exit 1
fi
echo "=> 32-bit OS, requires to build"
return 1
else
echo "=> No binary for this system, requires to build"
return 1
if ! ucoin_has "curl"; then
echo "=> curl is not available. You will likely need to install 'curl' package."
exit 1
fi
}
ucoin_do_install() {
# Autodetect install method
if [ "_$1" == "_git" ]; then
install_ucoin_from_git
elif ucoin_is_available_for_distribution; then
install_ucoin_as_script
elif ucoin_has "git"; then
install_ucoin_from_git
elif ucoin_has "curl"; then
install_ucoin_from_git
elif ucoin_has "wget"; then
install_ucoin_from_git
else
echo >&2 "You need git, curl, or wget to install ucoin"
if ! ucoin_has "make"; then
echo "=> make is not available. You will likely need to install 'build-essential' package."
exit 1
fi
if ! ucoin_has "g++"; then
echo "=> g++ is not available. You will likely need to install 'build-essential' package."
exit 1
fi
if ! ucoin_has "python"; then
echo "=> python is not available. You will likely need to install 'build-essential' package."
exit 1
fi
install_ucoin_from_git
echo
......@@ -343,9 +202,8 @@ ucoin_do_install() {
#
ucoin_reset() {
unset -f ucoin_reset ucoin_has ucoin_latest_version \
ucoin_download install_ucoin_as_script install_ucoin_from_git \
ucoin_detect_profile ucoin_do_install \
ucoin_is_available_for_distribution
ucoin_download install_ucoin_from_git \
ucoin_detect_profile ucoin_do_install
}
[ "_$UCOIN_ENV" = "_testing" ] || ucoin_do_install $1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment