lbry-sdk/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh

163 lines
4.5 KiB
Bash
Raw Normal View History

2016-02-16 03:31:29 +01:00
#!/bin/sh
2016-02-20 05:26:24 +01:00
if ! which brew &>/dev/null; then
echo "Installing brew..."
sudo -u ${SUDO_USER} ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null &>/dev/null
else
echo "Updating brew..."
sudo -u ${SUDO_USER} brew update &>/dev/null
fi
if ! brew list mpfr &>/dev/null; then
echo "Installing mpfr..."
sudo -u ${SUDO_USER} brew install mpfr &>/dev/null
else
echo "mpfr already installed..."
fi
if ! brew list libmpc &>/dev/null; then
echo "Installing libmpc..."
sudo -u ${SUDO_USER} brew install libmpc &>/dev/null
else
echo "libmpc already installed..."
fi
if ! brew list openssl &>/dev/null; then
echo "Installing openssl..."
sudo -u ${SUDO_USER} brew install openssl &>/dev/null
sudo -u ${SUDO_USER} brew link --force openssl &>/dev/null
else
echo "openssl already installed..."
fi
if ! which pip &>/dev/null; then
echo "Installing pip..."
sudo easy_install pip &>/dev/null
else
echo "pip already installed"
fi
if ! python -c 'import gmpy' &>/dev/null; then
echo "Installing gmpy..."
sudo pip install gmpy &>/dev/null
else
echo "gmpy already installed..."
fi
if ! python -c 'import service_identity' &>/dev/null; then
echo "Installing service_identity..."
sudo pip install service_identity &>/dev/null
else
echo "gmpy already installed..."
fi
if ! python -c 'import rumps' &>/dev/null; then
echo "Installing rumps..."
sudo pip install rumps &>/dev/null
else
echo "rumps already installed..."
fi
2016-02-20 21:30:30 +01:00
if ! python -c "import six; exit(0) if six.__version__ == '1.9.0' else exit(1)" &>/dev/null; then
2016-02-25 23:17:07 +01:00
echo "Installing six 1.9.0 for python..."
2016-02-20 21:30:30 +01:00
curl -O https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz &>/dev/null
tar xf six-1.9.0.tar.gz &>/dev/null
cd six-1.9.0
sudo python setup.py install &>/dev/null
cd ..
rm -rf six-1.9.0
rm six-1.9.0.tar.gz
fi
2016-02-16 03:31:29 +01:00
lbrynet_directory="/Users/${SUDO_USER}/Library/Application Support/lbrynet"
2016-02-25 23:17:07 +01:00
lbryum_current_version=$(git ls-remote https://github.com/lbryio/lbryum.git | grep HEAD | cut -f 1)
2016-02-16 03:31:29 +01:00
if [ -d "$lbrynet_directory" ]; then
2016-02-25 23:17:07 +01:00
if [ -f "${lbrynet_directory}/lbryum_version.txt" ]; then
if grep -Fxq "$lbryum_current_version" "${lbrynet_directory}/lbryum_version.txt"; then
echo "LBRYum version $lbryum_current_version is up to date"
2016-02-20 05:26:24 +01:00
else
tmp=$(mktemp -d)
cd $tmp
2016-02-25 23:17:07 +01:00
echo "Downloading LBRYum update..."
2016-02-20 05:26:24 +01:00
2016-03-03 19:55:03 +01:00
git clone --depth 1 https://github.com/lbryio/lbryum.git &>/dev/null
2016-02-25 23:17:07 +01:00
cd lbryum
2016-02-20 05:26:24 +01:00
2016-02-25 23:17:07 +01:00
echo "Installing update..."
2016-02-20 05:26:24 +01:00
sudo python setup.py install &>/dev/null
mkdir -p "$lbrynet_directory"
2016-02-25 23:17:07 +01:00
echo $lbryum_current_version > "${lbrynet_directory}/lbryum_version.txt"
2016-02-20 05:26:24 +01:00
2016-02-25 23:17:07 +01:00
echo "Cleaning up..."
2016-02-20 05:26:24 +01:00
cd ../../
rm -rf $tmp
2016-02-16 03:31:29 +01:00
fi
2016-02-20 05:26:24 +01:00
else
tmp=$(mktemp -d)
cd $tmp
2016-02-25 23:17:07 +01:00
echo "Downloading LBRYum..."
2016-02-20 05:26:24 +01:00
2016-03-03 19:55:03 +01:00
git clone --depth 1 https://github.com/lbryio/lbryum.git &>/dev/null
2016-02-25 23:17:07 +01:00
cd lbryum
2016-02-20 05:26:24 +01:00
2016-02-25 23:17:07 +01:00
echo "Installing..."
2016-02-20 05:26:24 +01:00
sudo python setup.py install &>/dev/null
mkdir -p "$lbrynet_directory"
2016-02-25 23:17:07 +01:00
echo $lbryum_current_version > "${lbrynet_directory}/lbryum_version.txt"
2016-02-20 05:26:24 +01:00
2016-02-25 23:17:07 +01:00
echo "Cleaning up..."
2016-02-20 05:26:24 +01:00
cd ../../
rm -rf $tmp
2016-02-16 03:31:29 +01:00
fi
fi
2016-02-25 23:17:07 +01:00
lbrynet_current_version=$(git ls-remote https://github.com/lbryio/lbry.git | grep HEAD | cut -f 1)
2016-02-16 03:31:29 +01:00
2016-02-20 05:26:24 +01:00
if [ -d "$lbrynet_directory" ]; then
2016-02-25 23:17:07 +01:00
if [ -f "${lbrynet_directory}/lbrynet_version.txt" ]; then
if grep -Fxq "$lbrynet_current_version" "${lbrynet_directory}/lbrynet_version.txt"; then
echo "LBRYnet version $lbrynet_current_version is up to date"
2016-02-20 05:26:24 +01:00
else
tmp=$(mktemp -d)
cd $tmp
2016-02-16 03:31:29 +01:00
2016-02-25 23:17:07 +01:00
echo "Downloading LBRYnet update"
2016-02-16 03:31:29 +01:00
2016-03-03 19:55:03 +01:00
git clone --depth 1 https://github.com/lbryio/lbry.git &>/dev/null
2016-02-25 23:17:07 +01:00
cd lbry
2016-02-16 03:31:29 +01:00
2016-02-25 23:17:07 +01:00
echo "Installing update..."
2016-02-20 05:26:24 +01:00
sudo python setup.py install &>/dev/null
mkdir -p "$lbrynet_directory"
2016-02-25 23:17:07 +01:00
echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt"
2016-02-16 03:31:29 +01:00
2016-02-25 23:17:07 +01:00
echo "Cleaning up..."
2016-02-20 05:26:24 +01:00
cd ../../
rm -rf $tmp
fi
else
tmp=$(mktemp -d)
cd $tmp
2016-02-25 23:17:07 +01:00
echo "Downloading LBRYnet..."
2016-02-20 05:26:24 +01:00
2016-03-03 19:55:03 +01:00
git clone --depth 1 https://github.com/lbryio/lbry.git &>/dev/null
2016-02-25 23:17:07 +01:00
cd lbry
2016-02-20 05:26:24 +01:00
2016-02-25 23:17:07 +01:00
echo "Installing..."
2016-02-20 05:26:24 +01:00
sudo python setup.py install &>/dev/null
mkdir -p "$lbrynet_directory"
2016-02-25 23:17:07 +01:00
echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt"
2016-02-20 05:26:24 +01:00
2016-02-25 23:17:07 +01:00
echo "Cleaning up..."
2016-02-20 05:26:24 +01:00
cd ../../
rm -rf $tmp
fi
fi