Created
February 15, 2018 08:51
-
-
Save lmlsna/2ba6559d7a80998d8791908deabee323 to your computer and use it in GitHub Desktop.
Shell script to bootstrap Bootstrap 4
This file contains hidden or 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 | |
# Shell script to bootstrap Bootstrap... | |
# JS Extra files w/ integrity hashes | |
JQ_URL="https://code.jquery.com/jquery-3.2.1.slim.min.js" | |
JQ_SHA384="KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" | |
POP_URL="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" | |
POP_SHA384="ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" | |
# Find latest release version | |
BS_VER="$(curl -sLo /dev/null -w %{url_effective} https://github.com/twbs/bootstrap/releases/latest | grep -Eo '[^/]+$' | sed 's/^v//g' )" | |
BS_ZIP="https://github.com/twbs/bootstrap/releases/download/v${BS_VER}/bootstrap-${BS_VER}-dist.zip" | |
# No curl or gunzip? Try wget and unzip. | |
tmpzip="$(mktemp --suffix=.zip)" | |
wget "$BS_ZIP" -qO "$tmpzip" | |
unzip "$tmpzip" -d ./ | |
rm -f "$tmpzip" | |
# Get js files | |
wget "$JQ_URL" -qO ./js/jquery.slim.min.js | |
wget "$POP_URL" -qO ./js/popper.min.js | |
echo -e "\njQuery:\n$(cat ./js/jquery.slim.min.js | openssl dgst -sha384 -binary | openssl base64 -A)\n$JQ_SHA384\n" | |
echo -e "Popper.js\n$(cat ./js/popper.min.js | openssl dgst -sha384 -binary | openssl base64 -A)\n$POP_SHA384\n" | |
cat > ./index.html << __STARTER__ | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="css/bootstrap.min.css"> | |
<title>Hello, world!</title> | |
</head> | |
<body> | |
<h1>Hello, world!</h1> | |
<!-- Optional JavaScript --> | |
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | |
<script src="js/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> | |
<script src="js/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> | |
<script src="js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> | |
</body> | |
</html> | |
__STARTER__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment