Skip to content

Instantly share code, notes, and snippets.

View brettbeeson's full-sized avatar

Brett Beeson brettbeeson

View GitHub Profile
@brettbeeson
brettbeeson / sync-to-rtc.service
Created February 16, 2020 08:58
A systemd service to sync to (PiJuice Zero's) a Real Time Clock upon boot.
[Unit]
Description=Sync pi to PjJuice hardware RTC
[Service]
ExecStart=/sbin/hwclock -s
# This might be optional, as default user is root(?)
User=root
Group=root
[Install]
#!/usr/bin/env python3
import sys
import logging
from systemd import journal
log = logging.getLogger("pijuice")
log.setLevel(logging.INFO)
handler = journal.JournaldLogHandler()
@brettbeeson
brettbeeson / gist:31926fac53a9a259d8e97e63b7b848cc
Created February 17, 2020 13:57
Manage wakeup time on a pijuice using local times
#!/usr/bin/python3
import datetime
import os
import time
from datetime import time
import dateutil.parser
from pijuice import PiJuice
import argparse
@brettbeeson
brettbeeson / pyjuice-led.py
Created February 18, 2020 01:53
Control pijuice LEDs from the command line
#!/usr/bin/env python3
import sys
from time import sleep
from pijuice import PiJuice
import argparse
argparser = argparse.ArgumentParser("Blink the user LED on a pijuice")
argparser.add_argument("element",choices=['photo','upload','wifi'])
argparser.add_argument("status", choices=['ok','fail'])
@brettbeeson
brettbeeson / autossh.service
Last active May 5, 2021 06:44
autossh systemd service
[Unit]
Description=Auto Reverse SSH
# No - can fail on dependancy. No sure best way to do this.
# Requires=systemd-networkd-wait-online.service
After=systemd-networkd-wait-online.service
# Try to restart forever!
StartLimitIntervalSec=0
StartLimitInterval=0
@brettbeeson
brettbeeson / wifi_functions.php.patch
Created June 1, 2020 10:25
Hacky patches for RaspAP
--- /tmp/wifi_functions.php 2020-06-01 20:04:41.178166241 +1000
+++ includes/wifi_functions.php 2020-06-01 19:12:34.424035192 +1000
@@ -5,10 +5,12 @@
function knownWifiStations(&$networks)
{
// Find currently configured networks
+ $index = 0;
exec(' sudo cat ' . RASPI_WPA_SUPPLICANT_CONFIG, $known_return);
foreach ($known_return as $line) {
if (preg_match('/network\s*=/', $line)) {
- install Ubuntu Desktop 20
-- minimal install
-- LVM
- install ssh
sudo apt install openssh-server
- now can remote in
scp -r .ssh server-name
ssh server-name
@brettbeeson
brettbeeson / write-pi-sd.sh
Last active December 16, 2020 23:05
Write a basic Raspberry Pi distro to an SD card from a linux box
#!/bin/sh
if [ $# -ne 1 ]
then
echo "Wrong args"
echo "write-pi-sd.sh <device>
echo <device> such as "/dev/sdc" for a SD card
exit 1
fi
@brettbeeson
brettbeeson / raspi-config-auto.sh
Last active December 30, 2020 15:46
Basic raspberry setup
#!/bin/sh
## non-interactive config
sudo raspi-config nonint do_wifi_country au
## software
sudo apt update && sudo apt dist-upgrade -y
sudo apt install vim git -y
sudo apt install -y autossh
@brettbeeson
brettbeeson / heartbeat.py
Created March 1, 2021 04:39
Flash LED depending on 'net connection. Reboot after 1 hour disconnected. PiZero only.
#!/usr/bin/env python3
#
# PiZero : flash LED depending on 'net connection. Reboot after 1 hour disconnected.
#
from subprocess import run
from time import sleep
import socket
from datetime import datetime as dt