2022-09-02 19:22:31 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-11-19 05:27:47 -08:00
|
|
|
# Alias logg function to true if it is not available
|
|
|
|
if ! command -v logg > /dev/null; then
|
|
|
|
alias logg='true'
|
|
|
|
fi
|
|
|
|
|
2022-11-21 07:39:27 -08:00
|
|
|
# Clear ZSH cached stuff
|
|
|
|
if [ -f "$HOME/.zshrc.zwc" ]; then
|
|
|
|
rm -f "$HOME/.zshrc.zwc"
|
|
|
|
fi
|
|
|
|
if [ -d "$HOME/.local/antigen" ]; then
|
|
|
|
rm -rf "$HOME/.local/antigen"
|
|
|
|
fi
|
|
|
|
if [ -d "$HOME/.zsh_sessions" ]; then
|
|
|
|
rm -rf "$HOME/.zsh_sessions"
|
|
|
|
fi
|
|
|
|
|
2022-09-02 19:22:31 -07:00
|
|
|
if [ -f '/etc/qubes-release' ]; then
|
|
|
|
# Qubes dom0
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Ensuring provision VM is present'
|
2022-09-22 03:45:01 -07:00
|
|
|
qvm-create --label red --template debian-11 provision &> /dev/null || EXIT_CODE=$?
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Downloading dotfile assets with provision VM'
|
2022-11-19 05:33:28 -08:00
|
|
|
qvm-run --pass-io provision 'if [ -d ~/Downloads/professor-dotfiles ]; then cd ~/Downloads/professor-dotfiles && git config pull.rebase false && rm -rf dotfiles/.local/asdf && rm -rf dotfiles/.local/common/shared && git pull origin master && git clone https://github.com/asdf-vm/asdf.git dotfiles/.local/asdf --branch v0.10.2 && mkdir -p dotfiles/.local/common/shared && git clone https://gitlab.com/megabyte-labs/common/shared.git dotfiles/.local/common/shared; else git clone https://gitlab.com/megabyte-labs/dotfiles.git ~/Downloads/professor-dotfiles; cd ~/Downloads/professor-dotfiles/dotfiles/.local && git clone https://github.com/asdf-vm/asdf.git asdf --branch v0.10.2 && mkdir common && git clone https://gitlab.com/megabyte-labs/common/shared.git common/shared; fi; cd ~/Downloads; tar -zcvf /tmp/professor-dotfiles.tar.gz professor-dotfiles'
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Transferring dotfiles to dom0 from provision VM'
|
2022-09-26 22:57:29 -07:00
|
|
|
qvm-run --pass-io provision "cat /tmp/professor-dotfiles.tar.gz" > "/tmp/dotfiles.tar.gz"
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Unpacking dotfile assets to /usr/local/src/professor-dotfiles'
|
2022-09-26 22:57:29 -07:00
|
|
|
tar -xzf "/tmp/dotfiles.tar.gz" -C "$HOME"
|
|
|
|
rm -f "/tmp/dotfiles.tar.gz"
|
|
|
|
sudo rm -rf /usr/local/src/professor-dotfiles
|
|
|
|
sudo mv "$HOME/professor-dotfiles" /usr/local/src/professor-dotfiles
|
2022-09-02 19:22:31 -07:00
|
|
|
else
|
2022-10-30 19:30:36 -07:00
|
|
|
if [ ! -w /usr/local/src/professor-dotfiles ]; then
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Using sudo because /usr/local/src/professor-dotfiles is not writable'
|
2022-10-30 19:35:49 -07:00
|
|
|
SUDO_PREFIX="sudo"
|
2022-10-30 19:30:36 -07:00
|
|
|
fi
|
2022-09-26 22:57:29 -07:00
|
|
|
if [ -d /usr/local/src/professor-dotfiles/.git ]; then
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Updating dotfiles already present in /usr/local/src/professor-dotfiles'
|
2022-09-26 22:57:29 -07:00
|
|
|
cd /usr/local/src/professor-dotfiles
|
2022-10-30 19:37:31 -07:00
|
|
|
${SUDO_PREFIX} git config pull.rebase false
|
2022-10-31 23:35:01 -07:00
|
|
|
${SUDO_PREFIX} rm -rf dotfiles/.local/asdf
|
2022-11-19 05:33:28 -08:00
|
|
|
${SUDO_PREFIX} rm -rf dotfiles/.local/common/shared
|
2022-10-30 19:37:31 -07:00
|
|
|
${SUDO_PREFIX} git pull origin master
|
2022-11-01 21:56:26 -07:00
|
|
|
${SUDO_PREFIX} git clone https://github.com/asdf-vm/asdf.git dotfiles/.local/asdf --branch v0.10.2
|
2022-11-19 05:33:28 -08:00
|
|
|
${SUDO_PREFIX} git clone https://gitlab.com/megabyte-labs/common/shared.git dotfiles/.local/common/shared
|
2022-10-30 19:37:31 -07:00
|
|
|
${SUDO_PREFIX} chown -Rf "$USER":"$(id -g -n)" /usr/local/src/professor-dotfiles
|
2022-09-02 19:22:31 -07:00
|
|
|
cd ~/
|
|
|
|
else
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Cloning new dotfiles to /usr/local/src/professor-dotfiles'
|
2022-10-30 19:37:31 -07:00
|
|
|
${SUDO_PREFIX} rm -rf /usr/local/src/professor-dotfiles
|
|
|
|
${SUDO_PREFIX} git clone https://gitlab.com/megabyte-labs/dotfiles.git /usr/local/src/professor-dotfiles
|
2022-10-31 23:35:01 -07:00
|
|
|
${SUDO_PREFIX} git clone https://github.com/asdf-vm/asdf.git /usr/local/src/professor-dotfiles/dotfiles/.local/asdf --branch v0.10.2
|
2022-11-19 05:33:28 -08:00
|
|
|
${SUDO_PREFIX} mkdir -p /usr/local/src/professor-dotfiles/dotfiles/.local/common/shared
|
|
|
|
${SUDO_PREFIX} git clone https://gitlab.com/megabyte-labs/common/shared.git /usr/local/src/professor-dotfiles/dotfiles/.local/common/shared
|
2022-10-30 19:37:31 -07:00
|
|
|
${SUDO_PREFIX} chown -Rf "$USER":"$(id -g -n)" /usr/local/src/professor-dotfiles
|
2022-09-02 19:22:31 -07:00
|
|
|
fi
|
2022-11-01 02:32:27 -07:00
|
|
|
if [ -n "$CREATE_PACKAGE" ]; then
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Creating /tmp/professor-dotfiles.tar.gz'
|
2022-11-01 01:26:41 -07:00
|
|
|
cd /usr/local/src
|
|
|
|
${SUDO_PREFIX} tar -zcvf /tmp/professor-dotfiles.tar.gz professor-dotfiles
|
|
|
|
cd ~/
|
|
|
|
fi
|
2022-09-02 19:22:31 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Copy dotfile folders
|
2022-11-19 05:58:31 -08:00
|
|
|
logg info 'Copying dotfiles folders to user $HOME directory'
|
2022-09-02 19:22:31 -07:00
|
|
|
while read DOTFILE_FOLDER; do
|
|
|
|
BASENAME_FOLDER="$(basename "$DOTFILE_FOLDER")"
|
2022-09-03 00:38:09 -07:00
|
|
|
if [ ! -d "$HOME/$BASENAME_FOLDER" ]; then
|
|
|
|
mkdir -p "$HOME/$BASENAME_FOLDER"
|
|
|
|
fi
|
2022-09-03 00:39:26 -07:00
|
|
|
cp -rf "$DOTFILE_FOLDER/"* "$HOME/$BASENAME_FOLDER"
|
2022-11-19 04:33:51 -08:00
|
|
|
done < <(find /usr/local/src/professor-dotfiles/dotfiles -maxdepth 1 -mindepth 1 -type d)
|
2022-09-02 19:22:31 -07:00
|
|
|
|
|
|
|
# Copy dotfile files
|
2022-11-19 05:58:31 -08:00
|
|
|
logg info 'Copying dotfiles files to user $HOME directory'
|
2022-09-02 19:22:31 -07:00
|
|
|
while read DOTFILE_FILE; do
|
|
|
|
BASENAME_FILE="$(basename "$DOTFILE_FILE")"
|
|
|
|
cp "$DOTFILE_FILE" "$HOME/$BASENAME_FILE"
|
|
|
|
chmod 600 "$HOME/$BASENAME_FILE"
|
2022-09-26 22:57:29 -07:00
|
|
|
done < <(find /usr/local/src/professor-dotfiles/dotfiles -maxdepth 1 -mindepth 1 -type f)
|
2022-09-02 19:22:31 -07:00
|
|
|
|
|
|
|
# Ensure .local/bin contents are executable
|
2022-11-19 05:58:31 -08:00
|
|
|
logg info 'Ensuring programs in ~/.local/bin are executable'
|
2022-09-02 19:22:31 -07:00
|
|
|
while read LOCAL_BIN; do
|
|
|
|
chmod +x "${LOCAL_BIN}"
|
2022-09-03 00:33:54 -07:00
|
|
|
done < <(find "$HOME/.local/bin" -maxdepth 1 -mindepth 1 -type f)
|
2022-11-19 04:47:53 -08:00
|
|
|
|
2022-10-29 04:51:19 -07:00
|
|
|
if [ -d /Applications ] && [ -d /System ]; then
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Adding Hack font to ~/Library/Fonts'
|
2022-10-29 05:41:39 -07:00
|
|
|
mkdir -p "$HOME/Library/Fonts"
|
|
|
|
cp "$HOME/.local/share/fonts/Hack Bold Nerd Font Complete.ttf" "$HOME/Library/Fonts/Hack Bold Nerd Font Complete.ttf"
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Configuring the Terminal.app'
|
2022-10-29 05:18:52 -07:00
|
|
|
theme=$(<$HOME/.local/theme/Betelgeuse.macOS.terminal)
|
|
|
|
plutil -replace Window\ Settings.Betelgeuse -xml "$theme" ~/Library/Preferences/com.apple.Terminal.plist
|
|
|
|
defaults write com.apple.Terminal "Default Window Settings" -string "Betelgeuse"
|
|
|
|
defaults write com.apple.Terminal "Startup Window Settings" -string "Betelgeuse"
|
2022-10-31 23:35:01 -07:00
|
|
|
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Betelgeuse:columnCount integer 124" ~/Library/Preferences/com.apple.Terminal.plist
|
|
|
|
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Betelgeuse:rowCount integer 35" ~/Library/Preferences/com.apple.Terminal.plist
|
2022-11-01 02:14:02 -07:00
|
|
|
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Betel-Bash:columnCount integer 124" ~/Library/Preferences/com.apple.Terminal.plist
|
|
|
|
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Betel-Bash:rowCount integer 35" ~/Library/Preferences/com.apple.Terminal.plist
|
2022-10-29 10:47:46 -07:00
|
|
|
|
2022-11-19 04:47:53 -08:00
|
|
|
# macOS desktop background
|
|
|
|
if command -v m > /dev/null; then
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Updating desktop wallpaper'
|
2022-11-19 04:47:53 -08:00
|
|
|
m wallpaper "/Users/$(whoami)/.local/theme/background.jpg"
|
|
|
|
fi
|
2022-10-29 04:51:19 -07:00
|
|
|
fi
|
|
|
|
|
2022-11-19 05:08:32 -08:00
|
|
|
# Update local Betelgeuse theme files (if not on macOS system)
|
|
|
|
if [ ! -d /Applications ] && [ ! -d /Library ]; then
|
2022-11-19 05:27:47 -08:00
|
|
|
logg info 'Updating Betelgeuse theme files'
|
2022-11-19 05:08:32 -08:00
|
|
|
if [ -f '/etc/qubes-release' ]; then
|
|
|
|
# Qubes dom0
|
|
|
|
qvm-create --label red --template debian-11 provision &> /dev/null || EXIT_CODE=$?
|
|
|
|
qvm-run --pass-io provision 'rm -f ~/Downloads/betelgeuse-master.tar.gz && curl -sSL https://gitlab.com/megabyte-labs/misc/betelgeuse/-/archive/master/betelgeuse-master.tar.gz > /tmp/betelgeuse-master.tar.gz'
|
|
|
|
qvm-run --pass-io provision "cat /tmp/betelgeuse-master.tar.gz" > "/tmp/betelgeuse-master.tar.gz"
|
|
|
|
cd /tmp
|
|
|
|
tar -xvf betelgeuse-master.tar.gz > /dev/null
|
|
|
|
rm betelgeuse-master.tar.gz
|
|
|
|
cp -rf betelgeuse-master/share/ "$HOME/.local/share"
|
|
|
|
rm -rf betelgeuse-master
|
|
|
|
else
|
|
|
|
curl -sSL https://gitlab.com/megabyte-labs/misc/betelgeuse/-/archive/master/betelgeuse-master.tar.gz > betelgeuse-master.tar.gz
|
|
|
|
tar -xzf betelgeuse-master.tar.gz > /dev/null
|
|
|
|
rm betelgeuse-master.tar.gz
|
|
|
|
cp -rf betelgeuse-master/share/ "$HOME/.local/share"
|
|
|
|
rm -rf betelgeuse-master
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-09-02 19:22:31 -07:00
|
|
|
# grep -q QT_QPA_PLATFORMTHEME=qt5ct /etc/environment || echo QT_QPA_PLATFORMTHEME=qt5ct | sudo tee -a /etc/environment
|
|
|
|
# sudo cp -rv "$HOME/.local/share/qt5ct" /usr/share
|