Skip to content

Instantly share code, notes, and snippets.

@plombardi89
Last active April 26, 2016 15:25
Show Gist options
  • Save plombardi89/26eefbc55ffa4e2618b7e91a24732f9a to your computer and use it in GitHub Desktop.
Save plombardi89/26eefbc55ffa4e2618b7e91a24732f9a to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
set -e
python_version="python2.7"
q3k_install_root="${HOME}/datawire"
is_python_installed () {
amsg " Checking if python is installed: "
if command -v python > /dev/null 2>&1; then
msgln "OK"
else
msgln "Not Installed. Please install python on your system."
exit 1
fi
}
is_pip_installed () {
amsg " Checking if pip is installed: "
if command -v pip > /dev/null 2>&1; then
msgln "OK"
else
msgln "Not Installed. Please install python pip on your system."
exit 1
fi
}
is_virtualenv_installed () {
amsg " Checking if virtualenv is installed: "
if command -v virtualenv > /dev/null 2>&1; then
msgln "OK"
else
msgln "Not Installed. Please install virtualenv on your system."
exit 1
fi
}
msgln () {
printf "%s\n" "$1"
}
amsg () {
printf "%s" "--> $1"
}
amsgln () {
printf "%s\n" "--> $1"
}
amsgln "Performing installation environment sanity checks..."
is_python_installed
is_pip_installed
is_virtualenv_installed
amsgln "Creating Datawire Quark installation directory..."
mkdir -p ${q3k_install_root}
virtualenv -q --python ${python_version} ${q3k_install_root}/quark/virtualenv
amsgln "Installing Datawire Quark..."
. ${q3k_install_root}/quark/virtualenv/bin/activate
pip --quiet install datawire-quark
deactivate
cat <<- EOF > ./q3kc
#!/usr/bin/env sh
set -e
. ${q3k_install_root}/quark/virtualenv/bin/activate
quark \${@:1}
deactivate
EOF
amsgln "Done!"
@richarddli
Copy link

Looks great! Some suggestions are to write it so it works in sh not bash (for example on Ubuntu, bash is the default for terminal windows but not for shell scripts since /bin/sh is dash on Ubuntu). Take a look at what I wrote here https://github.com/datawire/datawire-connect/blob/installer/install.sh for an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment