Skip to content

Instantly share code, notes, and snippets.

@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/getty@tty1.service.d/ to start htop on tty1 instead of login screen
[Service]
ExecStart=
ExecStart=-/usr/bin/htop
StandardInput=tty
StandardOutput=tty
@pkutzner
pkutzner / vboxvmservice@.service
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 <mat@matws.net> 2010-2011
# Copyright (C) Preston Kutzner <pkutzner@gmail.com> 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[@]}" )
@pkutzner
pkutzner / chromeosvpn.md
Last active November 13, 2022 05:55
Create ChromeOS VPN connection.

Creating an OpenVPN Configuration for ChromeOS

This assumes you already have an OpenVPN server set up that you'll be connecting to. OpenVPN server setup is not covered in this document.

NOTE: ChromeOS is VERY picky about adherance to the ONC filespec (second ref. link). If an option is marked as an integer, and you surround it in quotes, import of the file will fail silently. Booleans (true and false) seem to be an exception wherein you can either wrap, or not, the boolean value in quotes without it failing ¯\_(ツ)_/¯.

References:

ChromeOS supports both L2TP and OpenVPN VPN connections. However, adding an OpenVPN connection, other than a really basic one, is non-trivial, as many options are missing from the GUI; things such as setting the Cipher or the Auth types, setting CompLZO, or any myriad nonstandard

@pkutzner
pkutzner / gist:eea2533f43f02138c7d114f16f66d315
Created May 22, 2017 02:32
Command to trace nic in Virtualbox
vboxmanage modifyvm "[VM NAME]" --nictrace# on --nictracefile# /path/to/file.pcap
Where '#' is the interface number you want to capture.