View Single Post
Old 07-31-2017, 11:01 PM   #39
timelord
Junior Member
timelord began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Aug 2016
Location: Sydney, Australia
Device: Kobo Glo HD
The script at https://github.com/eli-schwartz/calibre-installer relies on this page to do the update check:
http://code.calibre-ebook.com/latest

But for the last week or so that page or site was sometimes down (404 error) and it still has an invalid certificate which causes exceptions. I've written a slightly altered script which uses Github's REST API to check the version, since github.com is less likely to go down than the above

Code:
## Downloads and installs the latest version of Calibre from the Calibre website if not already installed
    # From https://www.mobileread.com/forums/sh...93#post2691093 and https://github.com/eli-schwartz/calibre-installer and modifications by me to support the fact that the original site that had the latest Calibre version info is now offline as of July 2017
    LATESTCALIBREVERS=`curl --silent --max-time 10 https://api.github.com/repos/kovidgo...eleases/latest | jq --raw-output '.tag_name' | cut -c2-6 -`
    calibre-debug -c "from calibre.constants import numeric_version; raise SystemExit(int(numeric_version  < (tuple(map(int, '$LATESTCALIBREVERS'.split('.'))))))"
    UP_TO_DATE=$?

    if [ $UP_TO_DATE = 0 ]; then
            echo "Calibre is up-to-date"
    else
            killall --quiet calibre-server
            ORIGUMASK=`umask`
            umask 0022 # Calibre installer needs umask 0022
            python -c "import sys; py3 = sys.version_info[0] > 2; u = __import__('urllib.request' if py3 else 'urllib', fromlist=1); exec(u.urlopen('https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py').read()); main(install_dir='/opt')"
            umask $ORIGUMASK # restore original umask value
    fi
timelord is offline   Reply With Quote