111 lines
2.3 KiB
Bash
Executable file
111 lines
2.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Check for Git
|
|
if ! command -v git &> /dev/null; then
|
|
echo "Git is not installed. Aborting." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Make sure we have pulled in and updated any submodules
|
|
git submodule init
|
|
git submodule update
|
|
|
|
# What directories should be installable by all users including the root user
|
|
base=(
|
|
zsh
|
|
vim
|
|
nvim
|
|
tmux
|
|
git
|
|
)
|
|
|
|
# Folders that should, or only need to be installed for a local user on macOS
|
|
useronly_macos=(
|
|
yabai
|
|
skhd
|
|
)
|
|
|
|
# Folders that should, or only need to be installed for a local user
|
|
useronly=(
|
|
conda
|
|
dask
|
|
gh
|
|
jupyter
|
|
parallel
|
|
tox
|
|
firefox
|
|
)
|
|
|
|
# Files to ignore during stow
|
|
ignore_files=(
|
|
".DS_Store"
|
|
"__setup"
|
|
"bin"
|
|
"git"
|
|
"setup.sh"
|
|
)
|
|
|
|
# Function to run the stow command for the passed-in directory ($2) in location $1
|
|
stowit() {
|
|
usr=$1
|
|
app=$2
|
|
# -v verbose
|
|
# -R recursive
|
|
# -t target
|
|
# --ignore files to ignore
|
|
stow -v -R -t "${usr}" --ignore "$(IFS="|"; echo "${ignore_files[*]}")" "${app}"
|
|
}
|
|
|
|
# Function to check if the OS is macOS
|
|
is_macos() {
|
|
[[ "$(uname)" == "Darwin" ]]
|
|
}
|
|
|
|
# Function to automate firefox profile updater with expect
|
|
expect_yes() {
|
|
profile_dir=$(find ~/Library/Application\ Support/Firefox/Profiles -type d -name '*.default-release' -print -quit)
|
|
|
|
if [ -z "$profile_dir" ]; then
|
|
echo "Error: Firefox profile directory not found."
|
|
exit 1
|
|
fi
|
|
|
|
expect -c "
|
|
set timeout 3
|
|
spawn bash -c \"cd '$profile_dir' && $1\"
|
|
expect {
|
|
\"This script will update to the latest user.js file and append any custom configurations from user-overrides.js. Continue Y/N?\" { send \"y\r\"; exp_continue }
|
|
eof { exit }
|
|
}
|
|
"
|
|
}
|
|
|
|
echo ""
|
|
echo "Stowing apps for user: ${USER}"
|
|
|
|
# Install apps available to local users and root
|
|
for app in "${base[@]}"; do
|
|
stowit "${HOME}" "${app}"
|
|
done
|
|
|
|
# Install useronly_macos folders only for macOS
|
|
if is_macos; then
|
|
for app in "${useronly_macos[@]}"; do
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
stowit "${HOME}" "${app}"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Install useronly folders
|
|
for app in "${useronly[@]}"; do
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
stowit "${HOME}" "${app}"
|
|
if [[ "${app}" = "firefox" ]]; then
|
|
expect_yes "./updater.sh"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo "##### ALL DONE"
|