How to Host a Remote Script

Search IconIcon to open search

There’s a text editor called micro which can be installed with a single line of bash:

1
$ curl https://getmic.ro | bash

The genius of this solution is how easy the installation process is.

With micro as an inspiration, I try to bring the same elegance to my dotfile setup .


All I need is a hosting provider that can host a static file. I chose GitLab Pages because it capable of just that (and it doesn’t cost me anything).

GitLab Pages expects a file named index.html, so I used this name for the script file. Even though its an .html file, curl will treat it as a plain-text file. Whenever this file changes, GitLab CI/CD uploads the latest version of the script.

At this point, the script index.html is being served as a plain-text file at https://andtech.gitlab.io/dotfiles (the free domain provided by GitLab).

1
$ curl https://andtech.gitlab.io/dotfiles | bash

Looks good… but we can do better.

Like with getmic.ro, I configured a custom domain as an alias for the script’s real address. I had to go into the DNS settings for my custom domain. I added the 2 custom DNS records:

Host name Type TTL Data
get.andtech.me A 3600 35.185.44.232
get.andtech.me TXT 3600 "_gitlab-pages-verification-code.get.andtech.me TXT gitlab-pages-verification-code=************"

In addition, I disabled Force HTTPS so that curl doesn’t have to worry about HTTP 301 redirects.

Now, the script can be accessed at either get.andtech.me or https://get.andtech.me:

1
$ curl get.andtech.me | bash

This command is all I need to obtain my dotfiles.

Links