diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 22e55acca..678282da7 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -192,9 +192,29 @@ class LBRYDaemon(xmlrpc.XMLRPC): return defer.succeed(None) + def _update_lbryum(): + git_version = subprocess.check_output( + "git ls-remote https://github.com/lbryio/lbryum.git | grep HEAD | cut -f 1", + shell=True) + if os.path.isfile(os.path.join(self.db_dir, "lbryum_version.txt")): + f = open(os.path.join(self.db_dir, "lbryum_version.txt"), 'r') + current_version = f.read() + f.close() + if git_version == current_version: + print "LBRYum installation version " + current_version[:-1] + " is up to date" + return defer.succeed(None) + print "Update LBRYum version " + current_version[:-1] + " --> " + git_version[:-1] + self.restart_message = "Updates available" + else: + print "Update LBRYum to version " + git_version[:-1] + self.restart_message = "Updates available" + + return defer.succeed(None) + d = _check_for_updater() d.addCallback(lambda _: _update_lbrynet()) d.addCallback(lambda _: _update_lbrycrdd()) + d.addCallback(lambda _: _update_lbryum()) d.addCallback(lambda _: os.system("open /Applications/LBRY\ Updater.app &>/dev/null") if self.restart_message else defer.succeed(None)) d.addCallbacks(lambda _: self._restart() if self.restart_message else defer.succeed(None)) diff --git a/lbrynet/lbrynet_daemon/scripts/update_lbry.sh b/lbrynet/lbrynet_daemon/scripts/update_lbry.sh old mode 100644 new mode 100755 index b7a0b2a14..291dfb3ba --- a/lbrynet/lbrynet_daemon/scripts/update_lbry.sh +++ b/lbrynet/lbrynet_daemon/scripts/update_lbry.sh @@ -1,63 +1,5 @@ #!/bin/sh -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 - lbrycrd_directory="/Users/${SUDO_USER}/Library/Application Support/lbrycrd" current_version=$(git ls-remote https://github.com/jackrobison/lbrynet-app.git | grep HEAD | cut -f 1) diff --git a/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh b/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh old mode 100644 new mode 100755 index 90e87f079..f1672b093 --- a/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh +++ b/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh @@ -1,32 +1,153 @@ #!/bin/sh +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 + lbrynet_directory="/Users/${SUDO_USER}/Library/Application Support/lbrynet" -current_version=$(git ls-remote https://github.com/lbryio/lbry.git | grep HEAD | cut -f 1) +lbrynet_current_version=$(git ls-remote https://github.com/lbryio/lbry.git | grep HEAD | cut -f 1) if [ -d "$lbrynet_directory" ]; then if [ -f "${lbrynet_directory}/lbrynet_version.txt" ]; then - if grep -Fxq "$current_version" "${lbrynet_directory}/lbrynet_version.txt"; then - echo "LBRYnet version $current_version is up to date" - exit + if grep -Fxq "$lbrynet_current_version" "${lbrynet_directory}/lbrynet_version.txt"; then + echo "LBRYnet version $lbrynet_current_version is up to date" + else + tmp=$(mktemp -d) + cd $tmp + + echo "Downloading LBRYnet update" + + git clone --depth 1 https://github.com/lbryio/lbry.git &>/dev/null + cd lbry + + echo "Installing update" + sudo python setup.py install &>/dev/null + mkdir -p "$lbrynet_directory" + echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt" + + echo "Cleaning up" + + cd ../../ + rm -rf $tmp fi + else + tmp=$(mktemp -d) + cd $tmp + + echo "Downloading LBRYnet update" + + git clone --depth 1 https://github.com/lbryio/lbry.git &>/dev/null + cd lbry + + echo "Installing update" + sudo python setup.py install &>/dev/null + mkdir -p "$lbrynet_directory" + echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt" + + echo "Cleaning up" + + cd ../../ + rm -rf $tmp fi fi -tmp=$(mktemp -d) -cd $tmp +lbryum_current_version=$(git ls-remote https://github.com/lbryio/lbryum.git | grep HEAD | cut -f 1) -echo "Downloading LBRYnet update" +if [ -d "$lbrynet_directory" ]; then + 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" + else + tmp=$(mktemp -d) + cd $tmp -git clone --depth 1 https://github.com/lbryio/lbry.git &>/dev/null -cd lbry + echo "Downloading LBRYum update" -echo "Installing update" -sudo python setup.py install &>/dev/null -mkdir -p "$lbrynet_directory" -echo $current_version > "${lbrynet_directory}/lbrynet_version.txt" + git clone --depth 1 https://github.com/lbryio/lbryum.git &>/dev/null + cd lbryum -echo "Cleaning up" + echo "Installing update" + sudo python setup.py install &>/dev/null + mkdir -p "$lbrynet_directory" + echo $lbryum_current_version > "${lbrynet_directory}/lbryum_version.txt" -cd ../../ -rm -rf $tmp \ No newline at end of file + echo "Cleaning up" + + cd ../../ + rm -rf $tmp + fi + else + tmp=$(mktemp -d) + cd $tmp + + echo "Downloading LBRYum update" + + git clone --depth 1 https://github.com/lbryio/lbryum.git &>/dev/null + cd lbryum + + echo "Installing update" + sudo python setup.py install &>/dev/null + mkdir -p "$lbrynet_directory" + echo $lbryum_current_version > "${lbrynet_directory}/lbryum_version.txt" + + echo "Cleaning up" + + cd ../../ + rm -rf $tmp + fi +fi \ No newline at end of file