Created
December 2, 2021 15:56
-
-
Save lazerl0rd/441e9a662821ba724bed3699ce89dd45 to your computer and use it in GitHub Desktop.
Automatic eCryptFS Mounting for systemd.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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