sane-private-unlock: init
this presents a simpler unlock mechanism than my previous unl0kr script
This commit is contained in:
@@ -21,6 +21,7 @@ in
|
|||||||
"sane-scripts.find-dotfiles"
|
"sane-scripts.find-dotfiles"
|
||||||
"sane-scripts.ip-check"
|
"sane-scripts.ip-check"
|
||||||
"sane-scripts.private-do"
|
"sane-scripts.private-do"
|
||||||
|
"sane-scripts.private-unlock"
|
||||||
"sane-scripts.rcp"
|
"sane-scripts.rcp"
|
||||||
"sane-scripts.reboot"
|
"sane-scripts.reboot"
|
||||||
"sane-scripts.reclaim-boot-space"
|
"sane-scripts.reclaim-boot-space"
|
||||||
@@ -115,6 +116,15 @@ in
|
|||||||
extraPaths = [ "/" ];
|
extraPaths = [ "/" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
"sane-scripts.private-unlock" = {
|
||||||
|
suggestedPrograms = [ "systemctl" ];
|
||||||
|
sandbox.extraPaths = [ "/run/gocryptfs" ];
|
||||||
|
sandbox.whitelistSystemctl = true;
|
||||||
|
fs.".profile".symlink.text = ''
|
||||||
|
sane-private-unlock
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
"sane-scripts.reclaim-boot-space".sandbox = {
|
"sane-scripts.reclaim-boot-space".sandbox = {
|
||||||
method = "bunpen";
|
method = "bunpen";
|
||||||
extraPaths = [ "/boot" ];
|
extraPaths = [ "/boot" ];
|
||||||
|
@@ -113,6 +113,11 @@ let
|
|||||||
srcRoot = ./src;
|
srcRoot = ./src;
|
||||||
pkgs = [ "util-linux" ];
|
pkgs = [ "util-linux" ];
|
||||||
};
|
};
|
||||||
|
private-unlock = static-nix-shell.mkBash {
|
||||||
|
pname = "sane-private-unlock";
|
||||||
|
srcRoot = ./src;
|
||||||
|
pkgs = [ "coreutils" "systemdMinimal" ];
|
||||||
|
};
|
||||||
private-unlock-remote = static-nix-shell.mkBash {
|
private-unlock-remote = static-nix-shell.mkBash {
|
||||||
pname = "sane-private-unlock-remote";
|
pname = "sane-private-unlock-remote";
|
||||||
srcRoot = ./src;
|
srcRoot = ./src;
|
||||||
|
19
pkgs/by-name/sane-scripts/src/sane-private-unlock
Executable file
19
pkgs/by-name/sane-scripts/src/sane-private-unlock
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash -p bash -p coreutils -p systemdMinimal
|
||||||
|
|
||||||
|
if ! systemctl is-active private-storage.target > /dev/null; then
|
||||||
|
echo "unable to access encrypted data store."
|
||||||
|
echo "unlock it now or cancel with Ctrl+C."
|
||||||
|
fi
|
||||||
|
|
||||||
|
while ! systemctl is-active private-storage.target > /dev/null; do
|
||||||
|
# see: <https://stackoverflow.com/a/2654096>
|
||||||
|
IFS= read -s -r -p "password: " line
|
||||||
|
echo
|
||||||
|
if [[ "$?" -eq 0 ]]; then
|
||||||
|
echo -n "$line" > /run/gocryptfs/private.key
|
||||||
|
# give time for the store to be unlocked
|
||||||
|
timeout 3s systemctl start private-storage.target
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
Reference in New Issue
Block a user