Skip to content

Instantly share code, notes, and snippets.

@lazerl0rd
Created December 2, 2021 15:56
Show Gist options
  • Save lazerl0rd/441e9a662821ba724bed3699ce89dd45 to your computer and use it in GitHub Desktop.
Save lazerl0rd/441e9a662821ba724bed3699ce89dd45 to your computer and use it in GitHub Desktop.
Automatic eCryptFS Mounting for systemd.
[Unit]
After = etc-ecryptfs.mount
Description = Mount eCryptFS Directories
[Service]
ExecStart = /usr/local/bin/mountecryptfs.sh
KeyringMode = shared
Type = oneshot
User = root
[Install]
WantedBy = local-fs.target
#! /usr/bin/env bash
for fekKey in "/etc/ecryptfs/"*".key"; do
if [[ $fekKey != *.fnek.key ]]; then
cat "$fekKey" | ecryptfs-add-passphrase -
fnekKey="$(dirname "$fekKey")/$(basename "$fekKey" .key).fnek.key"
if [[ -f $fnekKey ]]; then
cat "$fnekKey" | ecryptfs-add-passphrase -
fi
mount -i "/$(systemd-escape -u "$(basename "$fekKey" .key)")"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment