-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make gpg-restore work on macOS
- Loading branch information
1 parent
ccc6ac0
commit a8cbd55
Showing
1 changed file
with
25 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
function gpg-restore | ||
mkdir -p --mode 700 $HOME/.gnupg | ||
gpgconf --kill gpg-agent | ||
gpg --import --batch /run/user/(id -u)/secrets/gpg_private | ||
gpg --import /run/user/(id -u)/secrets/gpg_public | ||
gpg --list-secret-keys | ||
gpg --list-keys | ||
gpg --import-ownertrust /run/user/(id -u)/secrets/gpg_ownertrust | ||
|
||
if test (uname) = "Darwin" | ||
set base_temp_dir (getconf DARWIN_USER_TEMP_DIR)/secrets.d/ | ||
|
||
if test -d $base_temp_dir | ||
set temp_dir (find $base_temp_dir -type d -maxdepth 1 -exec basename {} \; | sort -n | tail -n 1) | ||
set temp_dir $base_temp_dir$temp_dir | ||
else | ||
echo "Directory $base_temp_dir does not exist." | ||
return 1 | ||
end | ||
else | ||
set temp_dir /run/user/(id -u)/secrets | ||
end | ||
|
||
if test -d $temp_dir | ||
gpg --import --batch $temp_dir/gpg_private | ||
gpg --import $temp_dir/gpg_public | ||
gpg --list-secret-keys | ||
gpg --list-keys | ||
gpg --import-ownertrust $temp_dir/gpg_ownertrust | ||
else | ||
echo "Secrets directory $temp_dir does not exist." | ||
return 1 | ||
end | ||
end |