Skip to content

Instantly share code, notes, and snippets.

View dhensby's full-sized avatar

Daniel Hensby dhensby

  • London, UK
  • 22:32 (UTC +01:00)
  • X @dhensby
View GitHub Profile
@dhensby
dhensby / .gitconfig
Last active March 24, 2024 00:14
My standard gitconfig
[user]
name = <name>
email = <email>
signingkey = <GPG key>
[alias]
br = checkout -b
ch = cherry-pick
ci = commit
cim = commit --amend --no-edit
co = checkout
@dhensby
dhensby / sendmail-fix.sh
Last active July 12, 2023 12:17
Stop sendmail delivering to localhost when email domain matches hostname, stop sendmail intercepting emails to info@ and others - CentOS, RHEL, Fedora
#!/bin/bash
##
##
## This scipt was inspired by http://serverfault.com/questions/65365/disable-local-delivery-in-sendmail/128450#128450
## It stops webservers sending mail that is addressed to the local hostname to localhost and instead looks remotely for a mail server
##
##
# Install sendmail-cf as this is required to customise the config
@dhensby
dhensby / README.md
Last active October 2, 2022 19:01
Unattended provisioning of CS:GO LinuxGSM cloud server using Cloud Init / User Data

CS:GO LinuxGSM Server with Cloud Init

This cloud-init config will provision a CS:GO server using LinuxGSM without the need for any manual intervention.

Usage

When provisioning a cloud server with providers such as Digital Ocean, you can provide "user data" to help provision cloud servers.

This configuration allows you to make use of the "user data" to automatically provision the CS:GO server.

@dhensby
dhensby / cert-merge.js
Last active March 2, 2022 14:44
Add an intermediate certificate to an Azure Key Vault Certificate (Node CLI)
const { DefaultAzureCredential } = require('@azure/identity');
const { CertificateClient } = require('@azure/keyvault-certificates');
const { SecretClient } = require('@azure/keyvault-secrets');
const { pkcs12, asn1, pki } = require('node-forge');
const { writeFile, readFile } = require('fs').promises;
const [nodePath, scriptPath, vaultName, certName, pathToIntermediate, outFile] = process.argv;
function output(string) {
return new Promise((resolve, reject) => process.stdout.write(`${string}\n`, (err) => err ? reject(err) : resolve()));
@dhensby
dhensby / curl-etag-checker.sh
Created September 6, 2017 22:39
Fetch a resource using curl and use the ETag to check subsequent requests
#!/usr/bin/env bash
ETAG=''
if [ -f /tmp/etag ]; then
ETAG=$(cat /tmp/etag)
fi
head=true
while IFS= read -r line; do
@dhensby
dhensby / az-signed-publickey-auth.js
Created March 25, 2021 10:49
Example of publickey authentication with ssh2-streams and azure key vault
const { CryptographyClient, KeyClient } = require('@azure/keyvault-keys');
const { AzureCliCredential } = require('@azure/identity');
const { SSH2Stream, utils, constants: { ALGORITHMS: { SUPPORTED_SERVER_HOST_KEY } } } = require('ssh2-streams');
const { Socket } = require('net');
const { asn1, pki, md, ssh, jsbn: { BigInteger } } = require('node-forge');
const VAULT_URI = process.env.VAULT_URI;
// this is lifted from node-forge (https://github.com/digitalbazaar/forge/blob/0.10.0/lib/rsa.js#L284-L313)
// unfortunately it's not exported
@dhensby
dhensby / ipupdate.sh
Last active June 7, 2020 16:32
Update a hostname in Route53 with your current IP address
#!/usr/bin/env bash
IP=$(curl -s -L https://checkip.amazonaws.com/)
OLDIP=$(cat /tmp/ip)
DOMAIN_REGEX="\s+example\.com"
DOMAIN="sub.example.com"
if [ "${IP}" != "${OLDIP}" ]; then
echo "IP changed from ${OLDIP} to ${IP}"
echo "`date -u +%F-%T` IP changed from ${OLDIP} to ${IP}" >> /tmp/iplog
@dhensby
dhensby / install-tarsnap.sh
Last active May 19, 2020 02:29
A script to install tarsnap automatically on Fedora/CentOS/RHEL
#!/bin/bash
# To do:
# - Force install (regardless of installed tarsnap version) via flag
# - Set version via flag
# - Set TMP_DIR via flag
# - Skip software insall via flag
# - Check signature automatically
VERSION=1.0.37
TMP_DIR=/tmp/tarsnap
REMOVE_DIR=false
@dhensby
dhensby / selenium.sh
Created April 20, 2016 19:52
Selenium, Firefox and Behat on CentOS 7 RHEL 7 and fedora
#!/usr/bin/env bash
# help from:
# https://gist.github.com/textarcana/5855427
# http://tecadmin.net/install-firefox-on-linux/
# install deps
yum install -y java Xvfb firefox
# This version of FF doesn't actually work with latest selenium (for me) so I remove it again
@dhensby
dhensby / update-authorized-keys.sh
Last active September 17, 2018 12:42
Script to update SSH keys for a user from a github gist - uses jq or python as a fallback
#!/usr/bin/env bash
USER=''
HOME_DIR=''
DEBUG=false
GIST_ID=''
USE_PYTHON=0
function requirejq {
which jq