🍵️

2022-03-31

Not-Always Online Computing

Moving back to my old Asus Netbook also means I have to have a USB network card connected whenever I want to get online. No big deal, except it sticks out quite a bit and I keep worrying that it might break.

To maximize my freedom of movement I decided that whatever I could easily do offline I should. As I've mentioned before I usually mount my servers using autofs+sshfs, which means I always have access to them. Because of this I've gotten into the habit of saving virtually nothing personal or important on my laptop. After all, the servers are just other folders in my filesystem and I've always been online.

This time I've decided not to do that and instead try to keep a habit of editing and producing things on my laptop and intermittently syncing to my file server. Of course because I'm me I hacked together a little script for it and put in ~/.local/bin


#!/bin/bash

function usage() {
	echo "
Usage: ${0} push|pull|edit

Runs hardcoded rsync/scp or similar commands.

	push	supposedly pushes changes from this machine to remote.
	pull	supposedly pulls changes from remote to this machine.
	edit	opens the script file in vim for editing.
"
}

function push() {
	rsync -a Files/keepass.kdb fileserver:.
	rsync -a Documents/spending-tracker.ods fileserver:Documents/
}

function pull() {
	rsync -a fileserver:keepass.kdb Files/
	rsync -a fileserver:Documents/spending-tracker.ods Documents/
}

function edit() {
	vim "${0}"
}

cd "${HOME}"
case "${1}" in
	push|pull|edit) ${1};;
	*) usage;;
esac

I'll make sure to add and remove files and directories there as needed. The edit argument makes that really easy. The usage function isn't really needed because nobody else will ever use this. It's just a habit that I don't want to change.

Links

Mount Your Tilde. How to mount remote servers on local directories using autofs and sshfs (gemini link).

-- CC0 Björn Wärmedal