From f0aead55848d1074fe83d243c0d3ef36fc2b070f Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Fri, 15 Sep 2023 09:39:06 +0100 Subject: [PATCH] All the things I forgot to commit --- c66.bash | 63 ++++++++++++++++++++++++++++++++++++++++++++ convert_countries.rb | 11 ++++++++ make_site.bash | 1 + obs_mount.bash | 23 ++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100755 c66.bash create mode 100755 convert_countries.rb create mode 100755 obs_mount.bash diff --git a/c66.bash b/c66.bash new file mode 100755 index 0000000..fd40326 --- /dev/null +++ b/c66.bash @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Best practice options +set -o nounset +set -o pipefail +if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi + +if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then + echo 'Usage: + c66 ssh Select and SSH to a server + c66 log file role Select a stack and tail the file “file” on all its servers +' + exit +fi + +pushd ~ + +############################################################ +## Main commands +############################################################ + +cx_ssh() { + set_stack + set_server + cx ssh --stack $APPLICATION --environment $ENVIRONMENT $SERVER +} + +cx_log() { + set_stack + SERVERS=$(cx servers list --stack $APPLICATION --environment $ENVIRONMENT | grep "\[.*$ROLE.*\]" | cut -d ' ' -f1) + for SERVER in ${SERVERS// /} ; do + cx tail --stack $APPLICATION --environment $ENVIRONMENT $SERVER $LOG_FILE & + done +} + +############################################################ +## Helper functions +############################################################ + +set_stack() { + STACK=$(cx stacks list | fzf) + APPLICATION=$(echo $STACK | cut -d ' ' -f1) + ENVIRONMENT=$(echo $STACK | cut -d ' ' -f2) +} + +set_server() { + SERVER=$(cx servers list --stack $APPLICATION --environment $ENVIRONMENT | fzf | cut -d ' ' -f1) +} + +if [[ $# -eq 0 ]] ; then + echo "No arguments given. Use -h for help." + exit +fi + +if [[ $1 = "ssh" ]] ; then + cx_ssh +elif [[ $1 = "log" ]] ; then + LOG_FILE=$2 + ROLE=$3 + cx_log +fi + +popd diff --git a/convert_countries.rb b/convert_countries.rb new file mode 100755 index 0000000..cef60e2 --- /dev/null +++ b/convert_countries.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +require 'active_support/core_ext/string/inflections' + +file = "/home/tsv/foxsoft/directors-uk/clapboard/app/models/concerns/progress_countries.rb" + +File.open(file, "r+") do |f| + while(line = f.gets) != nil + m = line.match /\s\[\"(?[\w\s\:\&\'\-\;\(\)]*)\".*\]/ + puts line.gsub(m[:country], m[:country].titlecase) if m + end +end diff --git a/make_site.bash b/make_site.bash index c10b079..9b3665f 100755 --- a/make_site.bash +++ b/make_site.bash @@ -61,6 +61,7 @@ replace_links() { } setup_files() { + cp -r ~/code/site/assets/ ~/public_html/ cp ~/code/site/style.css ~/public_html } diff --git a/obs_mount.bash b/obs_mount.bash new file mode 100755 index 0000000..776ae59 --- /dev/null +++ b/obs_mount.bash @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Best practice options +set -o errexit +set -o nounset +set -o pipefail +if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi + +if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then + echo 'Usage: +' + exit +fi + +pushd ~ + +[ -d ~/sshfs/obs ] || mkdir -p ~/sshfs/obs +sshfs obs:/srv/salt ~/sshfs/obs +pushd ~/sshfs/obs +nvim +umount ~/sshfs/obs +popd +popd