Introducing .init.me.sh for multi-machine-architecture support
This commit is contained in:
parent
53c62408d8
commit
5e26df3f9b
15 changed files with 76 additions and 0 deletions
22
.chezmoiscripts/run_init.sh.tmpl
Executable file
22
.chezmoiscripts/run_init.sh.tmpl
Executable file
|
@ -0,0 +1,22 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
#env | grep -E 'chezmoi|^CZ'
|
||||
cd "$CHEZMOI_SOURCE_DIR"
|
||||
CZ_MODEL="$(ioreg -l | grep "product-name" | sed -Ee 's/^.*\<"(.*)\"\>.*$/\1/')"
|
||||
set | grep '^CZ_'
|
||||
printf 'System detected as %s/%s, setting up .chezmoiroot and initializing...\n' "$CZ_SYS" "$CZ_CHASSIS"
|
||||
if [ -r "base.chezmoiroot.$CZ_SYS.$CZ_CHASSIS" ]; then
|
||||
ln -s "base.chezmoiroot.$CZ_SYS.$CZ_CHASSIS" .chezmoiroot
|
||||
elif [ -r "base.chezmoiroot.$CZ_SYS" ]; then
|
||||
ln -s "base.chezmoiroot.$CZ_SYS" .chezmoiroot
|
||||
elif [ -r "base.chezmoiroot.$CZ_CHASSIS" ]; then
|
||||
ln -s "base.chezmoiroot.$CZ_CHASSIS" .chezmoiroot
|
||||
else
|
||||
printf 'Failed to find a matching .chezmoiroot. Aborting!\n'
|
||||
false
|
||||
fi
|
||||
|
||||
# Brute force remove chezmoistate lock and restart init --apply
|
||||
exec sh -c 'rm ~/.config/chezmoi/chezmoistate.boltdb && chezmoi init --apply'
|
Loading…
Add table
Add a link
Reference in a new issue