Commit 21cdbd0a authored by oct8l's avatar oct8l

Change centering

parent b6a1b93c
......@@ -29,7 +29,7 @@ If you don't already have a GitHub account, you'll want to go and set one up. Af
After being authenticated, click the **New gist** button in the top right to be taken to the form for posting a new Gist. Fill out your description (if you'd like), the filename, and then you can enter your script into the main form. Below, I have a script that says hello, and a friendly warning meant for if you have piped it straight to BASH (which can be very dangerous!). Afterwards, you can choose to post it either publicly or create a "secret" Gist. Creating a secret Gist will only make it accessible from those who have a link, but it won't make it visible on your profile or to search engines.
<center>![Gist screenshot](/img/posts/2019-77-hosting-a-curlable-script-with-github-gists/1.png)</center>
![Gist screenshot](/img/posts/2019-77-hosting-a-curlable-script-with-github-gists/1.png#center)
# Getting the link
After you have your Gist posted, you'll be taken to your Gist's page. It will have a comment section just like a GitHub repo, and you will have a few buttons. What you'll want to do next is click the **Raw** button in the top right of your Gist, and that will take you to a `cURL` friendly version of your Gist.
......@@ -41,12 +41,12 @@ What we're doing is taking off the file name of `hello.sh` and the commit hash o
# Shortening the link
Now once you have derived the link to the "master" of your Gist, head on over to a service like [Bitly](https://bitly.com) or [TinyURL](http://tinyurl.com/) and get a shortened version. This is much nicer to type in at a terminal than the full Gist URL. For this, I'll use TinyURL, and enter my Gist URL of `https://gist.githubusercontent.com/oct8l/99e3366923697a491afb9931fbb3e504/raw`. I'm given the output of `http://tinyurl.com/y4zwnz7b` which I can then use from a terminal and pull down the script using `cURL`.
<center>![TunyURL created](/img/posts/2019-77-hosting-a-curlable-script-with-github-gists/2.png)</center>
![TunyURL created](/img/posts/2019-77-hosting-a-curlable-script-with-github-gists/2.png#center)
# Using with `cURL`
The easiest way to do this is one that I've stolen from the [Pi-hole project](https://pi-hole.net/). We'll use `cURL` with the [-s](https://curl.haxx.se/docs/manpage.html#-s), [-S](https://curl.haxx.se/docs/manpage.html#-S) and [-L](https://curl.haxx.se/docs/manpage.html#-L) flags, which will make `cURL` run silently (with no progress bar), follow redirects (since we're using a URL shortening service), and to show errors if there are any when executing `cURL`. With all of these flags together, we currently have `curl -sSL`, and with our new shortened link, we have `curl -sSL http://tinyurl.com/y4zwnz7b`. Now to get that into BASH, we will use the pipe (|) character, and altogether, we can enter this into our terminal: `curl -sSL http://tinyurl.com/y4zwnz7b | bash`.
<center>![Running the script](/img/posts/2019-77-hosting-a-curlable-script-with-github-gists/3.gif)</center>
![Running the script](/img/posts/2019-77-hosting-a-curlable-script-with-github-gists/3.gif#center)
Depending on our script, it might be required to pipe to `sudo bash` instead of just `bash`. If you'll be performing any administrative tasks as a user who has `sudo` permissions, but not root, you'll need to use `sudo bash`.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment