Skip to content

Instantly share code, notes, and snippets.

View cjemorton's full-sized avatar

Clement Morton cjemorton

View GitHub Profile
#!/bin/sh
# Check if the URL environment variable is set
if [ -z "$URL" ]; then
# URL environment variable is not set, check if url.txt file exists
if [ -f "url.txt" ]; then
# url.txt file exists, check if it contains a valid URL
url=$(cat url.txt)
if echo "$url" | grep -Eq '^https?://'; then
# url.txt contains a valid URL, set the URL environment variable
@cjemorton
cjemorton / base64
Created December 20, 2021 17:12 — forked from iAnatoly/base64
One-liners encoding and decoding Base64 in powershell
[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("SecretMessage"))
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("U2VjcmV0TWVzc2FnZQ=="))

Keybase proof

I hereby claim:

  • I am cjemorton on github.
  • I am cmorton (https://keybase.io/cmorton) on keybase.
  • I have a public key ASBTe3h0Wj5rnbQpxZuLyUvh7C99N0iak-KytpTK6W5C3Ao

To claim this, I am signing this object:

@cjemorton
cjemorton / prowlarr-services
Last active December 15, 2021 08:34
services file for freebsd
#!/bin/sh
#
# Author: Clem Morton <CLEM@cpan.org>
# PROVIDE: prowlarr
# REQUIRE: LOGIN
# KEYWORD: shutdown
# Add the following lines to /etc/rc.conf to enable prowlarr:
# prowlarr_enable="YES"
if [ "$update_available" == 'true' ]
then
# Makefile Changes
if [ -e $ports_dir/Makefile ]
then
echo "Makefile exists, creating backup."
cp $ports_dir/Makefile $ports_dir/Makefile.orig
sed -e "s/Created by.*/Created by: $name <$email>/g" \
@cjemorton
cjemorton / par2calc
Last active September 26, 2021 04:52
PAR2 Disc Space Calculation
#!/usr/bin/perl
# SOURCE: https://www.sanitarium.net/unix_stuff/par2calc.txt
# CHANGES:
# Added calculations for bluray 25GB media (-bdr25)
#H# This script calculates how much space would be left on a disc and it generates
#H# PAR2 blocks to fill whatever space is left.
#H# Then it makes an md5 file of everything including the par2 files.
#H# It gets the basename of the par2 and md5 files from the current directory name.
#H# The only parameter is what type of disc is to be used. -cd, -dvd, -dvd2, or -dds3
#H# Note that unlike the -cd and -dvd params the -dds3 param is intended for data
DAHDI Seems to be broken in ports: Notes on Installation from Source.
(Loose Guide used & Useful Notes: https://zewaren.net/ipbx-2.html)
- Install FreeBSD, Version used: 12.2-RELEASE
- pkg update && pkg upgrade.
- pkg install nano git cbsd
- freebsd-update fetch install
- Install FreeBSD Sources. (https://docs.freebsd.org/en/books/handbook/cutting-edge/#makeworld)
- uname -a -> 12.2
@cjemorton
cjemorton / client.conf
Created July 30, 2020 07:15
Wireguard on FreeBSD with pf
[Interface]
PrivateKey = ***********************
Address = 192.168.10.2/32, fc::2/128
DNS = 1.1.1.1, 2606:4700:4700::1111
[Peer]
PublicKey = ***********************
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = endpoint.domain.tld:51820
@cjemorton
cjemorton / client.conf
Created July 30, 2020 07:15
Wireguard on FreeBSD with pf
[Interface]
PrivateKey = ***********************
Address = 192.168.10.2/32, fc::2/128
DNS = 1.1.1.1, 2606:4700:4700::1111
[Peer]
PublicKey = ***********************
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = endpoint.domain.tld:51820
#!/usr/bin/env sh
DEVLIST=$(camcontrol devlist | cut -d',' -f 2 | sed 's/.$//' |xargs )
echo $DEVLIST
for x in $DEVLIST
do
#Get Serial for device.
SERIAL=$(/usr/local/sbin/smartctl -a /dev/$x | grep "Serial Number")
MODEL=$(/usr/local/sbin/smartctl -a /dev/$x | grep "Device Model")
echo "DEVICE:" $x $SERIAL $MODEL