Skip to content

Instantly share code, notes, and snippets.

@mjkrause
Last active March 18, 2020 19:57
Show Gist options
  • Select an option

  • Save mjkrause/b2c82f506841034c5dbd347bbd9cd89a to your computer and use it in GitHub Desktop.

Select an option

Save mjkrause/b2c82f506841034c5dbd347bbd9cd89a to your computer and use it in GitHub Desktop.

Set up Vagrant (Ubuntu 18.04)

  1. Download and install Virtualbox

  2. Download and install Vagrant

curl -O https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb

Navigate to the directory of that file and execute

sudo apt install ./vagrant_2.2.7_x86_64.deb
vagrant --version

After that pick an operating system you want to install by going to Vagrant's download site and select one. Suppose you selected generic/ubuntu1804, then you execute

vagrant init generic/ubuntu1804

That install a VM. Once done, execute vagrant up and log into the machine with vagrant ssh - et voila...

Set up dependencies

sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
sudo apt install emacs curl jq -y

Create ssh public key and post on GitLab

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Now clone the repo, track the relevant branch, and start the boostrap installer.

git branch --track my-branch origin/my-branch
git checkout my-branch

Create a cron job

Use crontab -e (edit) to create a crontab file as the current user. In that file we set the shell we want cron to use (i.e., bash), the path to executables, and we define the path of the script (my_awesome_script.sh) we want cron to run on a schedule. The installation script needs to run prior to create .env in the project root. We schedule the cron job such that runs every day at midnight:

SHELL=bin/bash
PATH=<paste output of echo $PATH here>
SCRIPT_DIR=/absolute/path/of/my/script

0 0 * * * cd $SCRIPT_DIR && . .env && . ./my_awesome_script.sh $ARG1 $ARG2 > /dev/null 2>&1

Next we enable the cron log file by uncommenting the line cron.* in /etc/rsyslog.d/50-default.conf, followed by sudo systemctl restart rsyslog. Following that we monitor cron jobs by sudo tail -f /var/log/cron.log.

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