The Campion's Blog

A former sysadmin now cloud engineer's blog

Checkout master for all repositories in a folder

When dealing with microservices, sometimes I’ve found myself needing to go through all the repositories for a project in a folder and checkout the most recent master so it can be deployed.

Again the other day I had to do this so I finally wrote a script to make it go a bit faster. If there are changes in your working tree, it will notify at the end so you don’t have to worry about losing changes in any repos. Below is the result:

#!/bin/bash

REPOSITORIES=${PWD}
RED='\033[0;31m'
NC='\033[0m' # No Color
IFS=$'\n'
MANUAL_UPDATE_REPOS=()

for REPO in `ls "$REPOSITORIES/"`
do
  if [ -d "$REPOSITORIES/$REPO" ]
  then
    echo "Updating $REPOSITORIES/$REPO at `date`"
    if [ -d "$REPOSITORIES/$REPO/.git" ]
    then
      cd "$REPOSITORIES/$REPO"
      repo_status=$(git status)
      if [[ $repo_status != *"nothing to commit, working tree clean"* ]] 
      then
        echo -e "You need to stash or commit your code before this repository ${RED}$REPO${NC} can be set to master"
        MANUAL_UPDATE_REPOS+=($REPO)
      else
        echo "Fetching from remote"
        git fetch
        echo "Checking out master"
        git checkout master
        echo "Pulling"
        git pull
      fi
    else
      echo "Skipping because it doesn't look like it has a .git folder."
    fi
    echo "Done at `date`"
  fi
done
echo "these repos:"
printf "${RED}%s${NC}\n" ${MANUAL_UPDATE_REPOS[@]}
echo "do not have clean working trees and msater cannot be checked out."

Default Git Commit Message

If you want to have a sentence or reminder pop-up in every commit subject it’s pretty easy to do. I was typing this by hand for most of my commits and got sick of it and found an easy way to solve the issue.

These directions will make it so that each time you commit to every repository some text will pop up in the subject of your commit but it’s also possible to do per repository.

First create a file in your home directory

touch ~/.commit-template

Then add the text you want to be added to the subject of every commit

[ci-skip] MYTICKET-

Once you have that you just have to run a simple command to set this as your template for each commit globally

git config --global commit.template ~/.gitmessage.txt

Beta version of Brew Wizard available

After two years of work, we’ve finally released Brew Wizard! With the software you can create recipes, mash schedules, custom ingredients and custom fermentation schedules. Once you have, you can get detailed directions on how to brew your brew! Go check it out!

brew-wizard.com

Powershell script for installing node-red with chocolatey

So if you want to run node-red on a windows machine on a secondary drive and have it start automatically with a scheduled task, you can use this script to install it!

Continue reading

Monitorama!

TL:DR – This conference is really great as it’s put together by a group of people who aren’t tied to any company or beholden to any set of ideals, they just love monitoring 🙂 . There was a lot of opendiscourse not only about monitoring in the technical sense but also about the human side of monitoring which isn’t something that gets a lot of press.

The main thing I learned: We need to shift our focus about what we monitor.

Overview

The conference was in the Compagnietheater which was a beautiful venue.  There were only 400 people in attendance but from the many discussions that I had, they were the upper echelon of the monitoring community. I met and talked with quite a few people, including some of the top people who run monitoring operations for Apple, Yahoo, the BBC and Standard Chartered Bank.  Through these discussions that I had, I learned a lot about what companies are looking for and what the future of monitoring will likely look like.  These are the guys that are investing time and money into the open source projects that are used by millions of people like graphite, grafana, prometheus, icinga and are shaping the future of monitoring through those initiatives.

Continue reading

Well now I’ve done it….

I’ve been wanting to set up a blog / personal website to start documenting some of the things that I do at work and at home so others can benefit and this is the start.  I guess this will be something of a review since I wanted to write about how unbelievably easy it was to set up a wordpress server / site with AWS Lightsail.  I’ve accomplished registering a domain, getting a mail server up and running for said domain and a functioning wordpress server set up all whilst watching France and it looks like now England progress into the finals of the world cup.  Well hopefully I will keep this up and give something back to my tech community!

© 2020 The Campion's Blog

Theme by Anders NorenUp ↑