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
Branches
Tags
No related merge requests found
...@@ -33,77 +33,10 @@ ucoin_download() { ...@@ -33,77 +33,10 @@ ucoin_download() {
fi 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() { 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 local PREVIOUS_PATH
PREVIOUS_PATH=$PATH PREVIOUS_PATH=$PATH
if ucoin_has "git"; then
# Git is here: clone repository
if [ -d "$UCOIN_DIR/.git" ]; then if [ -d "$UCOIN_DIR/.git" ]; then
echo "=> ucoin is already installed in $UCOIN_DIR, trying to update using git" echo "=> ucoin is already installed in $UCOIN_DIR, trying to update using git"
printf "\r=> " printf "\r=> "
...@@ -126,33 +59,6 @@ install_ucoin_from_git() { ...@@ -126,33 +59,6 @@ install_ucoin_from_git() {
cd "$UCOIN_DIR" && command git branch -D master >/dev/null 2>&1 cd "$UCOIN_DIR" && command git branch -D master >/dev/null 2>&1
fi fi
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 # Download Nodejs
local NVER="5.8.0"; local NVER="5.8.0";
...@@ -183,45 +89,13 @@ install_ucoin_from_git() { ...@@ -183,45 +89,13 @@ install_ucoin_from_git() {
# Install uCoin dependencies (NPM modules) # Install uCoin dependencies (NPM modules)
export PATH=$PATH:$UCOIN_DIR/node/bin/ 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 npm install
export PATH=$PREVIOUS_PATH export PATH=$PREVIOUS_PATH
return 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 # Detect profile file if not specified as environment variable
# (eg: PROFILE=~/.myprofile) # (eg: PROFILE=~/.myprofile)
...@@ -264,46 +138,31 @@ ucoin_detect_profile() { ...@@ -264,46 +138,31 @@ ucoin_detect_profile() {
fi fi
} }
ucoin_is_available_for_distribution() { ucoin_do_install() {
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"`
if [[ "$distribution" = *Ubuntu\ 14* ]] || [[ "$distribution" = *Ubuntu\ 15* ]] || [[ "$distribution_deb" = *Debian*8*jessie* ]] || [[ "$distribution_fedora" = *Fedora\ 23* ]]; then # Check required commands
local X64=`uname -a | grep "x86_64"` if ! ucoin_has "git"; then
if [ ! -z "$X64" ]; then echo "=> git is not available. You will likely need to install 'git' package."
return 0 exit 1
fi fi
echo "=> 32-bit OS, requires to build" if ! ucoin_has "curl"; then
return 1 echo "=> curl is not available. You will likely need to install 'curl' package."
else exit 1
echo "=> No binary for this system, requires to build"
return 1
fi fi
} if ! ucoin_has "make"; then
echo "=> make is not available. You will likely need to install 'build-essential' package."
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"
exit 1 exit 1
fi 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 echo
...@@ -343,9 +202,8 @@ ucoin_do_install() { ...@@ -343,9 +202,8 @@ ucoin_do_install() {
# #
ucoin_reset() { ucoin_reset() {
unset -f ucoin_reset ucoin_has ucoin_latest_version \ unset -f ucoin_reset ucoin_has ucoin_latest_version \
ucoin_download install_ucoin_as_script install_ucoin_from_git \ ucoin_download install_ucoin_from_git \
ucoin_detect_profile ucoin_do_install \ ucoin_detect_profile ucoin_do_install
ucoin_is_available_for_distribution
} }
[ "_$UCOIN_ENV" = "_testing" ] || ucoin_do_install $1 [ "_$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