Update .local/share/chezmoi/home/dot_local/bin/executable_provision

This commit is contained in:
Brian Zalewski 2022-11-30 09:02:39 +00:00
parent 13906979a6
commit 746371d06d

View file

@ -1,8 +1,9 @@
#!/usr/bin/env bash
set -eo pipefail
set -eox pipefail
### Qubes dom0 specific code at top
### Qubes dom0
if command -v qubesctl > /dev/null; then
# The VM name that will manage the Ansible provisioning (for Qubes dom0)
ANSIBLE_PROVISION_VM="provision"
@ -35,10 +36,6 @@ function configureWizard() {
fi
}
### Update via system package manager and install Homebrew dependencies
if command -v qubesctl > /dev/null; then
# Qubes dom0
### Ensure dom0 is updated
if [ ! -f /root/dom0-updated ]; then
sudo qubesctl --show-output state.sls update.qubes-dom0
@ -82,7 +79,11 @@ if command -v qubesctl > /dev/null; then
fi
qvm-run --pass-io "$ANSIBLE_PROVISION_VM" 'curl -sSL https://install.doctor/start > ~/start.sh && bash ~/start.sh'
exit 0
elif command -v apt-get > /dev/null; then
fi
### System package manager update / Homebrew dependencies
if ! command -v curl > /dev/null || ! command -v git > /dev/null; then
if command -v apt-get > /dev/null; then
# Debian / Ubuntu
sudo apt-get update
sudo apt-get install -y curl git
@ -107,16 +108,21 @@ elif [ -d /Applications ] && [ -d /Library ]; then
sudo xcode-select -p >/dev/null 2>&1 || xcode-select --install
elif command -v nix-env > /dev/null; then
# NixOS
echo "TODO - Add support for NixOS"
elif [[ "$OSTYPE" == 'freebsd'* ]]; then
# FreeBSD
echo "TODO - Add support for FreeBSD"
elif command -v pkg > /dev/null; then
# Termux
echo "TODO - Add support for Termux"
elif command -v xbps-install > /dev/null; then
# Void
echo "TODO - Add support for Void"
elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then
# Windows
choco install -y curl git node
fi
fi
### Install Homebrew
ensurePackageManagerHomebrew() {
@ -144,8 +150,15 @@ ensurePackageManagerHomebrew() {
ensurePackageManagerHomebrew
### Install installer dependencies via Homebrew
installBrewPackage() {
if ! command -v "$1" > /dev/null; then
brew install "$1"
fi
}
if command -v brew > /dev/null; then
brew install chezmoi go-task/tap/go-task jq node yq zx
installBrewPackage chezmoi
installBrewPackage node
installBrewPackage zx
fi
### Ensure source files are present
@ -164,17 +177,23 @@ fi
### Copy folders
find /usr/local/src/hiawatha -maxdepth 1 -mindepth 1 -type d | while read FOLDER; do
BASENAME="$(basename "$FOLDER")"
# Prevent initial-scaffolding of OS-specific files since Chezmoi will handle them
if [[ "$BASENAME" != 'AppData' ]] && [[ "$BASENAME" != 'Library' ]]; then
if [ ! -d "$HOME/$BASENAME" ]; then
mkdir -p "$HOME/$BASENAME"
fi
cp -rf "$FOLDER/"* "$HOME/$BASENAME"
fi
done
### Copy files
find /usr/local/src/hiawatha -maxdepth 1 -mindepth 1 -type f | while read FILE; do
BASENAME="$(basename "$FILE")"
# Prevent repository-specific files from being copied over to user's HOME
if [[ "$BASENAME" != *'.md' ]] && [[ "$BASENAME" != *'.sh' ]] && [ "$BASENAME" != 'logo.png' ] && [ "$BASENAME" != '.gitlab-ci.yml' ]; then
cp "$FILE" "$HOME/$BASENAME"
chmod 600 "$HOME/$BASENAME"
fi
done
### Ensure ~/.local/bin files are executable