zulip/tools/install-phantomjs

30 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python2.7
from __future__ import print_function
import os
import sys
import platform
import subprocess
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from zulip_tools import run
if platform.architecture()[0] == '64bit':
phantomjs_arch = 'x86_64'
elif platform.architecture()[0] == '32bit':
phantomjs_arch = 'i686'
PHANTOMJS_PATH = "/srv/phantomjs"
PHANTOMJS_BASENAME = "phantomjs-1.9.8-linux-%s" % (phantomjs_arch,)
PHANTOMJS_TARBALL_BASENAME = PHANTOMJS_BASENAME + ".tar.bz2"
PHANTOMJS_TARBALL = os.path.join(PHANTOMJS_PATH, PHANTOMJS_TARBALL_BASENAME)
PHANTOMJS_URL = "https://github.com/zulip/zulip-dist-phantomjs/blob/master/%s?raw=true" % (PHANTOMJS_TARBALL_BASENAME,)
run(["sudo", "mkdir", "-p", PHANTOMJS_PATH])
if not os.path.exists(PHANTOMJS_TARBALL):
run(["sudo", "curl", '-J', '-L', PHANTOMJS_URL, "-o", PHANTOMJS_TARBALL])
run(["sudo", "tar", "-xj", "--directory", PHANTOMJS_PATH,
"--file", PHANTOMJS_TARBALL])
run(["sudo", "ln", "-sf", os.path.join(PHANTOMJS_PATH, PHANTOMJS_BASENAME,
"bin", "phantomjs"),
"/usr/local/bin/phantomjs"])