Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
#
# Copyright (c) Citrix Systems 2007-2011
# Author: Gianni Tedesco and Dave Scott
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; version 2.1 only. with the special
# exception on linking described in file LICENSE.
#
@pkutzner
pkutzner / gist:744ca34c4aab4b9c6d5872fa0bf9135a
Created April 25, 2018 20:27
Create ISO from AppStore download of macOS installer
Open Terminal, then run the following commands one at a time:
hdiutil attach /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
hdiutil detach /Volumes/install_app
@pkutzner
pkutzner / restic.env
Created February 10, 2018 05:01
Environment file for resticbackup.sh
# API credentials
#
# Amazon S3:
#AWS_ACCESS_KEY=<MY_ACCESS_KEY>
#AWS_SECRET_ACCESS_KEY=<MY_SECRET_ACCESS_KEY>
#
# Backblaze B2:
B2_ACCOUNT_ID=<B2_ACCOUNT_ID>
B2_ACCOUNT_KEY=<B2_ACCOUNT_KEY>
#
@pkutzner
pkutzner / resticbackup.sh
Created February 10, 2018 04:55
Script for cron-able backups via restic
#!/usr/bin/env bash
# Fail early if we weren't given enough parameters
if [[ $# -lt 2 ]]; then
echo "Usage: $0 <path_to_env_vars> <action> [debug]"
exit 1
fi
## === DEFAULTS === ##
RESTICPATH="/opt/restic"
@pkutzner
pkutzner / socat-pipe
Created February 10, 2018 04:35
Script for connecting to VirtualBox host pipe file in terminal
#!/bin/bash
[ "$1" ] || { echo "usage: $0 PIPE"; exit 1; }
echo "Press Ctrl+Q to quit..."
trap "stty sane" 0 1 2 3 15
sudo -u vbox socat unix-connect:$1 stdio,raw,echo=0,escape=0x11,icanon=0
@pkutzner
pkutzner / attachiso.sh
Created February 10, 2018 04:30
Attach ISO image to VirtualBox headless guest
#!/bin/bash
if [[ $# -lt 2 ]]; then
echo "Usage $0 'VM_NAME' /path/to/image.iso"
exit 1
fi
VMNAME="$1"
ISOIMAGE="$2"
@pkutzner
pkutzner / override.conf
Created February 10, 2018 04:15
Drop this in /etc/systemd/system/[email protected]/ to start htop on tty1 instead of login screen
[Service]
ExecStart=
ExecStart=-/usr/bin/htop
StandardInput=tty
StandardOutput=tty
@pkutzner
pkutzner / [email protected]
Last active February 10, 2018 04:14
systemd service for starting headless VirtualBox guests on boot
[Unit]
Description=VirtualBox Virtual Machine %i Service
Requires=systemd-modules-load.service
After=systemd-modules-load.service vboxdrv.service
[Service]
User=vbox
Group=vboxusers
ExecStart=/usr/bin/VBoxHeadless -s %i
ExecStop=/usr/bin/VBoxManage controlvm %i acpipowerbutton
@pkutzner
pkutzner / ubuntu_samba_backup.sh
Created February 6, 2018 22:30
Samba4 Backup Script for Ubuntu package installations.
#!/bin/bash
#
# Copyright (C) Matthieu Patou <[email protected]> 2010-2011
# Copyright (C) Preston Kutzner <[email protected]> 2018
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
#!/bin/bash
set -u
THELIST=( 'one' 'two' 'three' 'four' 'five' 'six' 'seven' 'eight' 'nine' 'ten' )
THEITEM='twelve'
declare -a EXTLIST=()
EXTLIST=( 'eleven' 'twelve' )
if [[ ${#EXTLIST[@]} -gt 0 ]]; then
THELIST+=( "${EXTLIST[@]}" )