Skip to content

Instantly share code, notes, and snippets.

Peter Willis peterwwillis

View GitHub Profile
@peterwwillis
peterwwillis / cp_src_dir_symlink_weirdness.md
Created Jul 21, 2020
Copying a source directory into a symlinked target directory
View cp_src_dir_symlink_weirdness.md
@peterwwillis
peterwwillis / LINUX_ACTIVE_DIRECTORY_SSSD_HOWTO.md
Created Jul 13, 2020
How to set up an Ubuntu 18.04 Linux system to use sssd to authenticate users using Active Directory without joining a domain
View LINUX_ACTIVE_DIRECTORY_SSSD_HOWTO.md

Set up Ubuntu Linux to use Active Directory for user authentication + authorization

This guide will step you through setting up an Ubuntu 18.04 Linux system so that you can login to it using an Active Directory server for authentication and authorization. NOTE: You do not need to join a domain to use this method!!

The net effect of this guide is that you do not need to ever set up a user on your Linux host. Its home directory will be automatically created at log-in time, and its password is checked (along with account expiration) against the Active Directory server.

@peterwwillis
peterwwillis / C_Tips_Best_Practices.md
Last active May 15, 2020
C Tips and Best Practices
View C_Tips_Best_Practices.md

Tips and Best Practices for programming in C

Syntax

Tips

  • You can explain a complicated declaration in English using cdelc.

Data Structures / Types

View Docker cheat sheet.md

Run commands

Use Docker to build a Jenkins plugin

  1. Check out a Jenkins plugin from GitHub
    $ git clone git@github.com:jenkinsci/configuration-as-code-secret-ssm-plugin.git
    $ cd configuration-as-code-secret-ssm-plugin
  2. Build the plugin. Change the maven tag to something like 3-jdk-8 or 3-jdk-11 if you run into errors, as some plugins only build with one JDK version.
    • Run as a non-root user
View print-jenkins-plugins.groovy
// from https://stackoverflow.com/questions/9815273/how-to-get-a-list-of-installed-jenkins-plugins-with-name-and-version-pair#12730830
// the sort version doesn't seem to work on my jenkins install
Jenkins.instance.pluginManager.plugins.each{
plugin ->
println ("${plugin.getDisplayName()} (${plugin.getShortName()}): ${plugin.getVersion()}")
}
@peterwwillis
peterwwillis / using-unix-pass.md
Created Dec 3, 2019
Using the Unix tool `pass` to manage passwords
View using-unix-pass.md

About

This document explains how to use the Unix tool pass to manage passwords.

Using pass

Initial set-up

  1. Install software
@peterwwillis
peterwwillis / extract_jenkins_credentials.groovy
Last active Nov 27, 2019
If you can't find a Jenkins credential's value any other way, use the Script Console to extract the values
View extract_jenkins_credentials.groovy
// To support more types of credentials, look up the credentials plugin code and write
// additional groovy to parse those credential types.
//
// From Mohamed Saeed: https://medium.com/@eng.mohamed.m.saeed/show-all-credentials-value-in-jenkins-using-script-console-83784e95b857
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
Jenkins.instance,
null,
null
@peterwwillis
peterwwillis / download-tls-cert.sh
Created May 29, 2019
Download a TLS certificate
View download-tls-cert.sh
#!/bin/sh
set -e
_get_cert () {
openssl s_client -showcerts -connect "$1":"$2" </dev/null 2>/dev/null | openssl x509 -outform PEM
}
if [ $# -lt 2 ] ; then
echo "Usage: $0 HOST PORT [OUTFILE]"
echo ""
echo "Connects to TCP PORT on HOST and downloads TLS certificates."
echo "Saves to OUTFILE if it is specified, otherwise outputs to standard out."
@peterwwillis
peterwwillis / defaultenv.sh
Created May 29, 2019
Load environment variables from a file with key=value pairs and optionally execute a program
View defaultenv.sh
#!/bin/sh
# defaultenv.sh - Load environment variable defaults and run programs
set -e
[ x"$DEBUG" = "x1" ] && set -x
_load_envrc () {
local file="$1"; shift
if [ -r "$file" ] ; then
# Bourne shell limits how we can test and set env vars, so here I'm
@peterwwillis
peterwwillis / sample.sh
Created May 8, 2019
Changing linux terminal screen window and tab titles
View sample.sh
echo -ne "\033]0;This changes the window title\007"
echo -ne "\ekThis changes the tab title\e\\"
You can’t perform that action at this time.