Created
November 14, 2020 21:56
-
-
Save espoelstra/036a2fff616e87fccf8a1b7cd66fb6d4 to your computer and use it in GitHub Desktop.
[WIP] Quick script for local grab of chrx dist.tar.gz to install into /usr/local
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Can execute if this is only being run once, or source it to keep the Python server around | |
cleanup() { pkill python3 2>/dev/null; unset CHRX_WEB_ROOT; } | |
# Don't want previous `pkill -P $$` which would kill parent session if sourced? | |
# trap cleanup EXIT | |
# Set to Web Server for Chrome and will attempt to fallback to Python or fail | |
# Use Web Server for Chrome if user doesn't pass a custom host | |
: ${CHRX_WEB_ROOT:="http://localhost:8887/"} | |
check_webserver() { | |
# Check if Web Server for Chrome is already running | |
CHECK_WEB=(curl $CHRX_WEB_ROOT) | |
# TODO: Return exit code of curl/wget if status isn't 200 | |
return $(($CHECK_WEB)) | |
} | |
check_python() { | |
hash python3 >/dev/null 2>&1 || echo where is python3 #{echo "No python, try Web Server for Chrome, https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb/"; return 1 || exit 1; } | |
echo $? | |
CHRX_WEB_ROOT="http://localhost:8000/" | |
nohup python3 -m http.server | |
} | |
# Set to Web Server for Chrome and will attempt to fallback to Python or fail | |
check_webserver | |
echo $? | |
# || check_python | |
sleep 3 # Lets the webserver start | |
curl $CHRX_WEB_ROOT/dist.tar.gz | sudo tar xzfC - /usr/local \ | |
&& sudo chmod +x /usr/local/bin/chrx* | |
# Only necessary when using a branch/master zip since unzip doesn't preserve permissions | |
chrx -h | |
chrx -h | grep -E 'installer.*version' | |
cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment