Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 163 lines (120 sloc) 3.91 KB
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC1091
set -Ee -o pipefail
# Install koopa.
# Updated 2019-09-16.
KOOPA_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
# Error on root user.
if [[ "$(id -u)" -eq 0 ]]
then
>&2 printf "Don't install koopa as root.\n"
exit 1
fi
# Usage {{{1
# ==============================================================================
usage() {
cat << EOF
usage: install [-h] [--dotfiles] [--mike] [--shared]
Install koopa.
optional arguments:
-h, --help
Show this help message and exit.
--dotfiles
Clone Mike's dotfiles repo (https://github.com/mjsteinbaugh/dotfiles)
and automatically symlink recommended default configuration files.
--mike
Install Mike-specific configuration.
This flag automatically enables '--dotfiles'.
--shared
Linux only.
Enable shared user configuration via '/etc/profile.d/koopa.sh' file.
EOF
}
# Parse arguments {{{1
# ==============================================================================
while (("$#"))
do
case "$1" in
-h|--help)
usage
exit 0
;;
--mike)
mike=1
shift 1
;;
--dotfiles)
dotfiles=1
shift 1
;;
--shared)
shared=1
shift 1
;;
--)
# End argument parsing.
shift
break
;;
--*|-*)
# Unsupported flags.
>&2 printf "Error: Invalid flag %s\n" "$1"
exit 1
;;
esac
done
# Automatically clone dotfiles in Mike mode.
if [[ "${mike:-0}" -eq 1 ]]
then
dotfiles=1
fi
# Remove legacy cruft {{{1
# ==============================================================================
rm -fr "${KOOPA_HOME}/"{config,include}
rm -fr "${KOOPA_HOME}/bin/"{host,os,sudo}
# Activate koopa {{{1
# ==============================================================================
printf "\nActivating koopa.\n"
force=1 source "${KOOPA_HOME}/activate"
# Shared user configuration {{{1
# ==============================================================================
# Checking for '/usr/local' installation automatically.
# > if echo "$KOOPA_HOME" | grep -qE "^/(opt|usr/local)/"
# > then
# > printf "\nShared installation detected at '%s'.\n" "$KOOPA_HOME"
# > shared=1
# > fi
if [[ "${shared:-0}" -eq 1 ]]
then
_koopa_update_profile
fi
# Dot files {{{1
# ==============================================================================
if [[ "${dotfiles:-0}" -eq 1 ]]
then
printf "\nConfiguring dotfiles.\n"
install-dotfiles
# Remove legacy dotfile cruft.
source "${KOOPA_HOME}/system/uninstall/dotfiles-legacy.sh"
# Always create these dotfiles, even on a shared installation.
source "${KOOPA_HOME}/system/install/dotfiles-shared.sh"
# Create local config files.
if [[ "${shared:-0}" -eq 0 ]]
then
source "${KOOPA_HOME}/system/install/dotfiles-local.sh"
fi
# Configure Mike's dotfiles.
if [[ "${mike:-0}" -eq 1 ]]
then
source "${KOOPA_HOME}/system/install/dotfiles-mike.sh"
fi
fi
# Additional scripts {{{1
# ==============================================================================
# Clone additional Git repos of interest.
if [[ "${mike:-}" -eq 1 ]]
then
source "${KOOPA_HOME}/system/install/docker-mike.sh"
source "${KOOPA_HOME}/system/install/scripts-mike.sh"
fi
printf "Installation was successful.\n"
You can’t perform that action at this time.