Skip to content

Instantly share code, notes, and snippets.

@stvhay
stvhay / synology_chroot.md
Last active January 10, 2025 01:31
Setup Synology Account with a chroot

Setup a Synology Chroot

Motivation

There's definitely an argument to be made that you should never have to ssh into your nice Synology NAS and just use the provided web interface.... Right?

Seriously, do you need to do this? Synology Tech Support won't help you if you accidentally try to install grub on top of the existing bootloader or something. That said, as long as you are just a little bit careful, creating a chroot is a decently safe way to get a fuller featureset of linux tools and also somewhat protect the synology system itself.

For me, I use the chroot mostly for general NAS file management.

Experiment Running Davis CalDAV / CardDAV

Setup Davis

alias php=php8.0
cd davis/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
auto eth0
allow-hotplug eth0
iface eth0 inet static
    address 192.168.1.42/24
    gateway 192.168.1.1
    up   ip addr add 192.168.1.43/24 dev $IFACE label $IFACE:0
    down ip addr del 192.168.1.43/24 dev $IFACE label $IFACE:0
    up   ip addr add 2600:3c03:e000:0381:0000:0000:0000:0002/64 dev $IFACE label $IFACE::2
@stvhay
stvhay / backup.sh
Last active November 11, 2022 01:20 — forked from skrajewski/backup.sh
Automate your macOS backup to Backblaze B2 using Restic and launchd.
#!/bin/bash
log () { echo "$(date +"%Y-%m-%d %T") " "$@"; }
home_dir='' # FILL THIS OUT
name='remote'
restic_path='/opt/homebrew/bin' # ADJUST AS NEEDED
pid_file="${home_dir}/.restic/${name}.pid"
timestamp_file="${home_dir}/.restic/${name}.timestamp"
hc_ping="https://hc-ping.com/uuid_here" # REPLACE WITH YOUR UUID
@stvhay
stvhay / autossh.plist
Last active November 24, 2020 11:12 — forked from swinton/autossh.plist
launchd plist for keeping a tunnel alive
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- https://www.launchd.info/ -->
<plist version="1.0">
<dict>
<key>Label</key>
<string>tunnel.autossh</string>
<key>KeepAlive</key>
<dict>
@stvhay
stvhay / autossh.service
Last active November 24, 2020 10:38 — forked from thomasfr/autossh.service
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network-online.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@stvhay
stvhay / attrcattr.py
Last active April 21, 2020 19:35
Use of cattr
import attr
import cattr
import json
@attr.s
class FooClass:
x = attr.ib()
y = attr.ib()
@stvhay
stvhay / safe_shelve.py
Created April 18, 2020 02:29
Shelve has inconsistent file naming, causing weirdness sometimes when you try to use it.
"""safe_shelve.py"""
import os
import shelve
DATA_DIR = 'data'
def open(db_name: str):
"""Opens and returns a shelve in an unambiguous place."""
directory = os.path.join(DATA_DIR, db_name)
@stvhay
stvhay / asdf_upgrades.sh
Created April 15, 2020 03:50
upgrade all local pythons and rubies using asdf
#!/bin/bash
#set -x
function find_latest {
# find latest version
local PROGRAM=$1
local VERSION=$2
asdf list all "${PROGRAM}" | \
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | \