Skip to content

Instantly share code, notes, and snippets.

@mbentley
mbentley / debian_8.sh
Last active August 8, 2022 22:05
Enable ttyS0 (Ubuntu 14.04 and Debian 8 (jessie)
### debian 8 (jessie)
mkdir /etc/systemd/system/serial-getty@ttyS0.service.d &&\
echo '[Service]
Environment="TERM=xterm"' > /etc/systemd/system/serial-getty@ttyS0.service.d/xterm.conf
systemctl daemon-reload &&\
systemctl enable serial-getty@ttyS0.service &&\
systemctl start serial-getty@ttyS0.service &&\
systemctl status serial-getty@ttyS0.service
@mbentley
mbentley / docker-compose.yml
Last active August 19, 2016 02:46
Docker Network Example
version: "2"
services:
app1:
image: alpine:latest
command: ping app2
networks:
- discovery-demo
app2:
image: alpine:latest
@mbentley
mbentley / get_volume_mounts.sh
Created August 31, 2016 12:11
Get docker volume mounts via `docker inspect`
for i in $(docker ps -aq)
do
echo -n "Volumes for ${i}: "
docker inspect --format '{{ range .Mounts }}{{ .Name }} {{ end }}' ${i}
done
@mbentley
mbentley / container_root_check.sh
Last active September 9, 2016 16:14
Check running containers for root processes
#!/bin/bash
# get a list of all running containers by name
for CONTAINER_NAME in $(docker ps --filter status=running --format '{{ .Names }}')
do
# get a list of the processes running in the container where the process is running as root
ROOT_PROCESSES="$(docker top ${CONTAINER_NAME} -o user,pid,ppid,command -U root -u root)"
# check and see if there are processes running as root; if not, do not display anything
if [ "$(echo "${ROOT_PROCESSES}" | grep ^root &>/dev/null; echo $?)" -eq "0" ]
@mbentley
mbentley / 1_create_client_bundle.sh
Created December 9, 2016 14:46
CI Automation with UCP
#!/bin/bash
# create directory for bundle in persistent storage
cd /var/lib/jenkins
mkdir ucp-bundle
cd ucp-bundle
set -e
# set variables for getting client bundle
@mbentley
mbentley / get_logs.ps1
Last active December 13, 2016 13:42
Windows Server 2016 Docker Daemon Logs
# from https://github.com/Microsoft/Virtualization-Documentation/blob/live/windows-server-container-tools/Debug-ContainerHost/Debug-ContainerHost.ps1#L175
Write-Output "Warnings & errors from the last 24 hours"
$logStartTime = (Get-Date).AddHours(-24)
$logNames = "Microsoft-Windows-Containers-Wcifs/Operational",
"Microsoft-Windows-Containers-Wcnfs/Operational",
"Microsoft-Windows-Hyper-V-Compute-Admin",
"Microsoft-Windows-Hyper-V-Compute-Operational",
"Application"
$levels = 3,2,1,0
@mbentley
mbentley / 0_dct_demo.sh
Last active August 24, 2021 20:02
Docker Content Trust Demo (January 2017)
### set environment variables
DTR_URL="ddcbeta.mac"
# Make sure you have downloaded DTR's CA (if the certs are not trusted by valid root CA on your client already) and are placed in the path specified by --tlscacert
# The DTR's CA cert can be downloaded from https://${DTR_URL}/ca
# If it is already trusted, you can leave of the --tlscacert argument
alias notary="notary -s https://${DTR_URL} -d ~/.docker/trust --tlscacert ~/.docker/tls/${DTR_URL}/ca.crt"
REPO="admin/signtest"
USERNAME="admin"
### admin
@mbentley
mbentley / nginx.conf
Created February 23, 2017 18:03
nginx load balancer for UCP
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@mbentley
mbentley / check_for_deferred_deletion.sh
Created March 10, 2017 21:22
Check to see if deferred deletion is supported
#!/bin/bash
PIPE1=/run/dss-$$-fifo1
PIPE2=/run/dss-$$-fifo2
TEMPDIR=$(mktemp --tmpdir -d)
platform_supports_deferred_deletion() {
local deferred_deletion_supported=1
trap cleanup_pipes EXIT
if [ ! -x "./dss-child-read-write.sh" ];then
@mbentley
mbentley / notary_easy_button.sh
Last active November 18, 2021 12:54
Docker Content Trust Delegation Script
#!/bin/bash
# check to see if a cert.pem exists in the current directory
if [ ! -f "cert.pem" ]
then
echo "ERROR - cert.pem not found (are you in the right directory?)"
exit 1
fi
# check to see if CA cert exists for your DTR