Update 5 files

- /home/dot_local/bin/executable_install-program
- /home/.chezmoiexternal.toml
- /home/dot_ssh/symlink_authorized_keys.tmpl
- /home/dot_ssh/run_onchanges_after_link-vagrant-authorized-keys.tmpl
- /home/.chezmoiscripts/universal/run_before_1-decrypt-age-key.tmpl
This commit is contained in:
Brian Zalewski 2023-01-05 01:31:03 +00:00
parent c68236c74b
commit 04d0878327
5 changed files with 41 additions and 8 deletions

View file

@ -201,6 +201,12 @@
clone.args = ["--depth", "1"]
pull.args = ["--ff-only"]
### Vagrant
[".ssh/authorized_keys.vagrant"]
type = "file"
url = "https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub"
refreshPeriod = "{{ $refreshPeriod }}"
{{- if and (not .host.headless) (ne .chezmoi.os "windows") }}
### Neovim
[".config/nvim"]

View file

@ -12,6 +12,11 @@ if [ ! -f "${XDG_CONFIG_HOME}/age/chezmoi.txt" ]; then
if [ -n "$EXIT_CODE" ]; then
logg info 'Proceeding without decrypting age encryption key stored at `~/.local/share/chezmoi/home/key.txt.age`'
logg info 'To have Chezmoi handle your encryption (so you can store your private files publicly) take a look at https://shorturl.at/jkpzG'
logg info 'Removing all files that begin with encrypted_ because decryption failed'
find "$HOME/.local/share/chezmoi" -type f -name "encrypted_*" | while read ENCRYPTED_FILE; do
logg info "Removing $ENCRYPTED_FILE"
rm -f "$ENCRYPTED_FILE"
done
fi
fi

View file

@ -883,7 +883,7 @@ async function ensurePackageManager(packageManager) {
}
const flatpakPost = which.sync('flatpak', { nothrow: true })
if (flatpakPost) {
await $`flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo`
await $`sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo`
} else {
log('error', logStage, `\`flatpak\` failed to install!`)
}
@ -1032,13 +1032,13 @@ async function installPackageList(packageManager, packages) {
try {
if (pkg.substring(0, 3) === 'http' && pkg.slice(-8) === 'AppImage') {
log('info', 'AppImage Install', `Installing ${pkg} from its URL`)
await $`zap install --from ${pkg}`
await $`sudo zap install --from ${pkg}`
} else if (pkg.includes('/')) {
log('info', 'AppImage Install', `Installing ${pkg} from a GitHub Release`)
await $`zap install --github --from ${pkg}`
await $`sudo zap install --github --from ${pkg}`
} else {
log('info', 'AppImage Install', `Installing ${pkg} using the AppImage Catalog`)
await $`zap install ${pkg}`
await $`sudo zap install ${pkg}`
}
} catch (e) {
log('error', 'AppImage / Zap Failure', `There was an error using Zap to install ${pkg}`)
@ -1314,11 +1314,20 @@ async function updateSystemd(service) {
}
}
/**
* Filter that resolves when all asynchronous filter actions are done
*/
const asyncFilter = async (arr, predicate) => {
const results = await Promise.all(arr.map(predicate));
return arr.filter((_v, index) => results[index]);
}
async function pruneInstallOrders(installOrders) {
const newOrders = Object.assign({}, installOrders)
for (const pkgManager of installOrders) {
if (pkgManager === 'apt') {
newOrders[pkgManager] = newOrders[pkgManager].filter(async x => {
newOrders[pkgManager] = await asyncFilter(newOrders[pkgManager], async (x) => {
try {
await $`dpkg -l ${pkg} | grep -E '^ii' > /dev/null`
return true
@ -1331,6 +1340,7 @@ async function pruneInstallOrders(installOrders) {
for (const pkg in newOrders[pkgManager]) {
try {
await $`brew list ${pkg}`
newVal = newVal.filter(x => x === pkg)
} catch (e) {
// Do nothing
}
@ -1338,7 +1348,7 @@ async function pruneInstallOrders(installOrders) {
newOrders[pkgManager] = newVal
} else if (pkgManager === 'dnf') {
const dnf = which.sync('dnf', { nothrow: true })
newOrders[pkgManager] = newOrders[pkgManager].filter(async x => {
newOrders[pkgManager] = await asyncFilter(newOrders[pkgManager], async (x) => {
try {
if (dnf) {
await $`rpm -qa | grep ${pkg} > /dev/null > /dev/null`
@ -1364,7 +1374,7 @@ async function pruneInstallOrders(installOrders) {
}
})
} else if (pkgManager === 'pacman') {
newOrders[pkgManager] = newOrders[pkgManager].filter(async x => {
newOrders[pkgManager] = await asyncFilter(newOrders[pkgManager], async (x) => {
try {
await $`pacman -Qs ${pkg} > /dev/null > /dev/null`
return true

View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
### Link authorized_keys to authorized_keys.vagrant if username is vagrant
if [ "$USER" == 'vagrant' ]; then
logg info 'Linking authorized_keys.vagrant to authorized_keys in the .ssh folder'
ln -s "$HOME/.ssh/authorized_keys.vagrant" "$HOME/.ssh/authorized_keys"
fi

View file

@ -1,3 +1,5 @@
{{- if true -}}
{{- if eq (output "echo" "$USER") "vagrant" -}}
{{ .host.home }}/.ssh/authorized_keys.vagrant
{{- else -}}
{{ .host.home }}/.ssh/authorized_keys.github
{{- end -}}