Skip to content

Instantly share code, notes, and snippets.

@snevas
snevas / ring.service
Created February 18, 2023 15:42
UDR led blinker on doorbell ring
[Unit]
Description=LEDs on doorbell ring
After=unifi-protect.service
#Install tmux and multitail from apt
#Replace sleep with aplay on UDM if you want it to play sound
[Service]
ExecStart=tmux new-session -d -s multitail multitail -D -ex "EventRingButtonPressed" "uled-ctrl blink 500 008000 FF0000 && sleep 10 && uled-ctrl fw idle" -iw "/ssd1/.data/unifi-protect/logs/cameras/*.log" 30
ExecStop=tmux kill-session -t multitail
User=root
@snevas
snevas / gist:9dc151dea0dc2cdcbe5032bd6026a1b4
Last active October 8, 2022 09:36
RTSP offshore unifi protect cam stream backup with systemd
Made into systemd service with https://northernlightlabs.se/2014-07-05/systemd-status-mail-on-unit-failure.html and added:
ExecStartPre=-/usr/bin/docker stop unifi-cam1
ExecStop=/usr/bin/docker stop unifi-cam1
ExecStopPost=/bin/sleep 20
Cleanup with cron:
ls -1t /path/cam1-*.mp4 | tail -n +672 | xargs rm -f
#!/bin/bash
@snevas
snevas / gist:c34d738576cfcb0a7178ad95c4877b66
Created August 19, 2020 14:13
Ubuntu 20.04 alternate gdm-login (screensaver unlock password)
# apt install db5.3-util whois
# mkdir /var/local/screenpass
# chown root:shadow /var/local/screenpass
# chmod 2750 /var/local/screenpass
$ mkpasswd -m des
# db5.3_load -h /var/local/screenpass -t hash -T passwd.db
[user]
[despass]
^D
# cp /etc/pam.d/gdm-password /etc/pam.d/_gdm-password
@snevas
snevas / veeam-backup-cron
Last active December 8, 2019 17:58
The fixed time shedule does not work great with inregularly used laptops, that's why I made this conditional script that I run from a cronjob every hour. When not at home, it cannot mount the CIFS location, so it will also not backup. To be able to use notifications: add local user to veeam group and run the script with the cron of that user.
#!/bin/bash
# Cron every hour
backupname=full
timeago='1 day ago'
echo "Starting backup checks at $(date)"
# Check if not on battery
if [ $(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep state | awk '{print $2}') != "discharging" ] ; then
echo "[1/2] Not discharging, continuing"
datetime=$(veeamconfig session list | grep Success | tail -1 | awk '{print $7 "T" $8}')
@snevas
snevas / keybase.md
Created February 9, 2017 13:28
keybase.md

Keybase proof

I hereby claim:

  • I am snevas on github.
  • I am snevas (https://keybase.io/snevas) on keybase.
  • I have a public key ASAJjxPvOTvXnddwrUQ7Tym57EEwIIqr0QqlfSZef3FDwQo

To claim this, I am signing this object: