mirror of
https://github.com/shokinn/.files.git
synced 2025-10-14 02:08:31 +00:00
add functions to easily encrypt & decrypt age encrypted dotfiles
This commit is contained in:
parent
d99efa3a28
commit
641b71513d
2 changed files with 58 additions and 17 deletions
|
@ -3,7 +3,8 @@ config:
|
||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
variables:
|
variables:
|
||||||
ageidentity: ${{HOME}}/.age/phg-age-dotfiles
|
ageidentity: "{{@@ env['HOME'] @@}}/.age/phg-age-dotfiles"
|
||||||
|
ageidentity_pub: "{{@@ ageidentity@@}}.pub"
|
||||||
SHELL_ERR_MESSAGE: \033[41;30m
|
SHELL_ERR_MESSAGE: \033[41;30m
|
||||||
SHELL_RESET_COLOR: \033[0m
|
SHELL_RESET_COLOR: \033[0m
|
||||||
trans_install:
|
trans_install:
|
||||||
|
@ -11,7 +12,7 @@ trans_install:
|
||||||
[[ -f {{@@ ageidentity @@}} ]] && age --decrypt -i {{@@ ageidentity @@}} -o {1} {0} || ([[ ! -f {{@@ _dotfile_abs_dst @@}} ]] && (echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity @@}}, cannot decrypt {0}, creating empty file instead{{@@ SHELL_RESET_COLOR @@}}"; echo "" > {1}) || (echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity @@}}, cannot decrypt {0}{{@@ SHELL_RESET_COLOR @@}}"; cp {{@@ _dotfile_abs_dst @@}} {1}))
|
[[ -f {{@@ ageidentity @@}} ]] && age --decrypt -i {{@@ ageidentity @@}} -o {1} {0} || ([[ ! -f {{@@ _dotfile_abs_dst @@}} ]] && (echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity @@}}, cannot decrypt {0}, creating empty file instead{{@@ SHELL_RESET_COLOR @@}}"; echo "" > {1}) || (echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity @@}}, cannot decrypt {0}{{@@ SHELL_RESET_COLOR @@}}"; cp {{@@ _dotfile_abs_dst @@}} {1}))
|
||||||
trans_update:
|
trans_update:
|
||||||
_encrypt: |
|
_encrypt: |
|
||||||
[[ -f {{@@ ageidentity @@}}.pub ]] && cat {0} | age -a -R {{@@ ageidentity @@}}.pub > {1} || echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity @@}}.pub, cannot encrypt {0}{{@@ SHELL_RESET_COLOR @@}}"
|
[[ -f {{@@ ageidentity_pub @@}} ]] && cat {0} | age -a -R {{@@ ageidentity_pub @@}} > {1} || echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity_pub @@}}, cannot encrypt {0}{{@@ SHELL_RESET_COLOR @@}}"
|
||||||
actions:
|
actions:
|
||||||
oh-my-zsh: |
|
oh-my-zsh: |
|
||||||
[[ ! -d ${{HOME}}/.oh-my-zsh ]] && sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended || echo "do nothing" >/dev/null
|
[[ ! -d ${{HOME}}/.oh-my-zsh ]] && sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended || echo "do nothing" >/dev/null
|
||||||
|
|
|
@ -148,6 +148,61 @@ zi () {
|
||||||
__zoxide_zi "$@"
|
__zoxide_zi "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Runs dotdrop installed by uv with the cfg option set to my dotdrop config file in my .files repo
|
||||||
|
# Globals:
|
||||||
|
# None
|
||||||
|
# Arguments:
|
||||||
|
# n arguments for using / configuring dotdrop
|
||||||
|
# Outputs:
|
||||||
|
# None
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
#######################################
|
||||||
|
dotdrop() {
|
||||||
|
{{@@ env['HOME'] @@}}/.local/bin/dotdrop --cfg={{@@ env['HOME'] @@}}/.files/config.yaml ${@}
|
||||||
|
}
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Age encryption for my dotfiles.
|
||||||
|
# Globals:
|
||||||
|
# None
|
||||||
|
# Arguments:
|
||||||
|
# - source file (unencrypted)
|
||||||
|
# - target file (encrypted)
|
||||||
|
# Outputs:
|
||||||
|
# age encrypted file
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
#######################################
|
||||||
|
adenc() {
|
||||||
|
if [ -z "${1}" ] || [ -z "${2}" ]; then
|
||||||
|
echo "Usage: adencrypt <source file> <target file>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
age -a -R {{@@ ageidentity_pub @@}} -o "${2}" "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Age decryption for my dotfiles.
|
||||||
|
# Globals:
|
||||||
|
# None
|
||||||
|
# Arguments:
|
||||||
|
# - source file (encrypted)
|
||||||
|
# - target file (unencrypted)
|
||||||
|
# Outputs:
|
||||||
|
# age decrypted file
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
#######################################
|
||||||
|
addec() {
|
||||||
|
if [ -z "${1}" ] || [ -z "${2}" ]; then
|
||||||
|
echo "Usage: addecrypt <source file> <target file>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
age -d -i {{@@ ageidentity @@}} -o "${2}" "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
{%@@ if distro == 'macos' @@%}
|
{%@@ if distro == 'macos' @@%}
|
||||||
#######################################
|
#######################################
|
||||||
# Shows a netstat -tulpn styled output on mac.
|
# Shows a netstat -tulpn styled output on mac.
|
||||||
|
@ -360,21 +415,6 @@ confv6() {
|
||||||
return 5
|
return 5
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Runs dotdrop installed by uv with the cfg option set to my dotdrop config file in my .files repo
|
|
||||||
# Globals:
|
|
||||||
# None
|
|
||||||
# Arguments:
|
|
||||||
# n arguments for using / configuring dotdrop
|
|
||||||
# Outputs:
|
|
||||||
# None
|
|
||||||
# Returns:
|
|
||||||
# None
|
|
||||||
#######################################
|
|
||||||
dotdrop() {
|
|
||||||
{{@@ env['HOME'] @@}}/.local/bin/dotdrop --cfg={{@@ env['HOME'] @@}}/.files/config.yaml ${@}
|
|
||||||
}
|
|
||||||
|
|
||||||
{%@@ endif @@%}{%@@ if vw == true @@%}
|
{%@@ endif @@%}{%@@ if vw == true @@%}
|
||||||
setProxyEnv() {
|
setProxyEnv() {
|
||||||
local HIGHLIGHT='\033[36;1m'
|
local HIGHLIGHT='\033[36;1m'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue