Skip to content

Instantly share code, notes, and snippets.

@catchdave
catchdave / replace_certs_protect.sh
Last active June 20, 2023 16:32
Renews SSL certificates on a "Unifi Protect Cloud Key+ Gen 2" that have already been copied over # from my "create_ssl_certs.sh" script.
#!/bin/bash
# This file renews SSL certificates on a "Unifi Protect Cloud Key+ Gen 2" that have already been copied over
# from my "create_ssl_certs.sh" script.
#
# Caveat: You will need to run this again if you upgrade software. I have noticed changes to
# file structures when Unifi updates minor versions, so no guarantee this will work above
# OS 3.1.x.
# Prep: Add sudo perms to run this script for the user that executes this script, via visudo:
# your_user_name ALL=NOPASSWD:/root/replace_certs_protect.sh
# This is a anonymized version of the script I use to renew all my SSL certs
# across my servers. This will not work out of the box for anyone as your network will be
# different. But may be useful starting place for others.
#
# I use a cronjob that runs this every week. It only replaces certificates when a certificate has been renewed.
# Renews/creates cert from letsencrypt & places it where it needs to be.
# Currently, that is:
# * Nginx (local for plex)
# * Plex Media Server
@catchdave
catchdave / install_check_mk_osx.sh
Last active October 22, 2023 13:07
Install check_mk agent on OSX
# Clone Repo
git clone https://github.com/ThomasKaiser/Check_MK.git
cd Check_MK
# Remove less common plugins
rm -f agents/plugins/monitor-jss-and-macos-updates agents/plugins/city-temperatures agents/plugins/monitor-kerio agents/plugins/smart*
# Install dependencies
brew install smartmontools osx-cpu-temp
@catchdave
catchdave / replace_synology_ssl_certs.sh
Last active April 10, 2024 08:53
CLI script to programmatically replace SSL certs on Synology NAS
#!/bin/bash
#
# *** For DSM v7.x ***
#
# How to use this script:
# 1. Get your 3 PEM files ready to copy over from your local machine/update server (privkey.pem, fullchain.pem, cert.pem)
# and put into a directory (this will be $CERT_DIRECTORY).
# Personally, I use this script (https://gist.github.com/catchdave/3f6f412bbf0f0cec32469fb0c9747295) to automate steps 1 & 4.
# 2. Ensure you have a user setup on synology that has ssh access (and ssh access is setup).
# This user will need to be able to sudo as root (i.e. add this line to sudoers, <USER> is the user you create):
@catchdave
catchdave / pico_light_switch_std.py
Created July 7, 2019 00:29
Home Assistant Python Script to generalize pico remotes for any non-lutron light
#
# Script to manage a light using standard controls from a Lutron Pico Remote
# This will translate the standard button meanings on a Pico to any light controlled
# by Home Assistant.
# The "favourite" button is presumed to be 50% brightness (but can be overriden).
# Expected data packet is: { new_state: X, entity_id: entity_id, fav_brightness: [0-100] }
# new_state: REQUIRED. The pico value that triggered the event.
# entity_id: REQUIRED. The entity_id of the light to control
# fav_brightness: OPTIONAL. What brightness percentage to set when the favourite button is pressed (int 1 - 100).
#
@catchdave
catchdave / install_pia_vpn.sh
Last active December 28, 2022 03:21
CLI script to install Private Internet Access VPN on a ubuntu server
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
set -o nounset
set -o errexit
error_exit()