Skip to content

Instantly share code, notes, and snippets.

@o0-o
o0-o / mirror.sh
Last active January 24, 2024 04:56
Sync a mirror to a local directory using wget, optionally assisted by rsync.
#!/usr/bin/env sh
#
# Sync a mirror to a local directory using wget, optionally assisted by
# rsync.
#
# If the source mirror supports rsync, or an alternative rsync mirror
# is supplied via $MIRROR_RSYNC_URL, wget is only used to download
# files (directories, hard and symbolic links, file list and deletions
# are generated with rsync).
#
@o0-o
o0-o / iana_services.yml
Created January 24, 2022 15:44
IANA Service Name and Transport Protocol Port Number Registry in YAML Format
---
# https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
# Converted on 2022/01/23
# NOTE: services that don't specify a transport protocol are excluded
1ci-smcs:
tcp:
- 3091
udp:
- 3091
@o0-o
o0-o / gpg_add_key.sh
Last active October 28, 2021 07:00
Unattended/Automated GPG Key Scripts for Yubikey
#!/usr/bin/env sh
# Run this on an air-gapped computer with an encrypted hard drive to set up GPG keys on your yubikey.
# Derived from https://github.com/drduh/YubiKey-Guide
# Assumes OS has already been prepared (packages, services, etc) -- see dr duh guide.
# Does not configure PINs on the yubikey. If no admin pin is provided, the default 12345678 is used.
#
# Usage: gpg_add_yubi.sh gpg-backup.tar.gz gpg_passhrase [yubikey_admin_pin]
########################################################################
# Safety and portability
@o0-o
o0-o / arch-install.sh
Last active May 20, 2022 09:10
Install Arch Linux on MD/LUKS/LVM (Including /boot) + AppArmor or SELinux + Stock AwesomeWM
#!/usr/bin/env zsh
# WARNING: THIS SCRIPT WILL AGGRESSIVELY DESTROY ALL DATA ON ALL DRIVES
# ON THIS SYSTEM!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
# This script assumes 3 drives (sda sdb and sdc) are present and the
# first 2 are identical in size. The majority of the operating system
# is installed onto a mirror of sda and sdb. Home is installed on sdc.
########################################################################
declare adm_user='o0-o'
@o0-o
o0-o / tape-cloud-bu.sh
Last active March 4, 2020 19:53
Backup to Tape and Cloud with Email Alert
#!/usr/bin/env bash
#
# Archive data to tape and cloud storage with log and email alert.
#
# Usage: tape-cloud-bu.sh /mnt/data /mnt/ltotape/path rclone_remote:/path
#
################################################################################
# safety first
set -euo pipefail
@o0-o
o0-o / raspi.sh
Last active January 6, 2020 00:43
[Onboard a Raspberry Pi] WIP
#/usr/bin/env bash
#raspberry pi config WIP
set -euxo pipefail
declare EMAIL= #no-reply@domain.tld
declare SMTP_PW=
declare RECIPIENT=
################################################################################
@o0-o
o0-o / onboard_edgemax.sh
Last active November 15, 2019 08:35
[Onboard a Ubiquiti Edgemax Network] Deploy a baseline Edgemax environment with one router and many switches.
### WORK IN PROGRESS ###
#!/usr/bin/env bash
set -euo pipefail
################################################################################
### DEFINE THE NETWORK #########################################################
@o0-o
o0-o / onboard_rhel.sh
Last active January 31, 2020 16:55
[Onboard CentOS or Fedora Server] Configure a CentOS or Fedora server with generally secure settings, including email alerts, no ipv6, firewall open to specified administrative subnet, antivirus, auditing, cockpit, netdata, aide and selinux.
#!/usr/bin/env bash
#
# We assume the system is installed with:
#
# 1. Minimal software
# 2. No root user login
# 3. The following partitions:
# /
# /boot
# /home
@o0-o
o0-o / set_firmware_edgeswitch.exp
Last active November 9, 2019 18:20
[Update the Firmware on a Ubiquiti Edgeswitch vi SSH] Non-interactive installation of firmware on a Ubiqiuti EdgeSwitch #ubiquiti #edgemax #switch #expect
#!/usr/bin/env expect
set timeout 720
set host [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
set url [lindex $argv 3]
set ftp_pw [lindex $argv 4]
@o0-o
o0-o / enable_ssh_on_edgeos_via_https.sh
Last active June 11, 2022 22:50
[Enable SSH on a Ubiquiti EdgeRouter via HTTPS] Non-interactively Enable SSH on an EdgeOS Device with cURL #bash #edgemax #edgerouter #edgeos #ubiquit
#!/usr/bin/env bash
ROUTER_IP="192.168.1.1"
COOKIES="$(curl -v "https://${ROUTER_IP}/" \
-H 'Connection: keep-alive' \
-H 'Cache-Control: max-age=0' \
-H "Origin: https://${ROUTER_IP}" \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'DNT: 1' \