install: Add simple dotter install
This commit is contained in:
parent
0a5d62909b
commit
5e53105a62
5 changed files with 189 additions and 82 deletions
6
.dotter/dots-with-systemwide.toml
Normal file
6
.dotter/dots-with-systemwide.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
includes = [".dotter/incl-systemwide.toml"]
|
||||||
|
packages = ["system", "workstation"]
|
||||||
|
|
||||||
|
[files]
|
||||||
|
|
||||||
|
[variables]
|
6
.dotter/dots.toml
Normal file
6
.dotter/dots.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
includes = []
|
||||||
|
packages = ["workstation"]
|
||||||
|
|
||||||
|
[files]
|
||||||
|
|
||||||
|
[variables]
|
81
.dotter/global.toml
Normal file
81
.dotter/global.toml
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
[helpers]
|
||||||
|
|
||||||
|
[base]
|
||||||
|
depends = ["shell", "git", "nvim", "scripts", "ssh", "terminal"]
|
||||||
|
|
||||||
|
[linux]
|
||||||
|
depends = [
|
||||||
|
"base",
|
||||||
|
"disks",
|
||||||
|
"pass",
|
||||||
|
"office",
|
||||||
|
"services",
|
||||||
|
"social",
|
||||||
|
"writing",
|
||||||
|
]
|
||||||
|
|
||||||
|
[system]
|
||||||
|
|
||||||
|
[workstation]
|
||||||
|
depends = ["linux", "desktop", "multimedia", "qutebrowser"]
|
||||||
|
|
||||||
|
[shell.files]
|
||||||
|
"sh/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
sh = "~"
|
||||||
|
|
||||||
|
[desktop.files]
|
||||||
|
"desktop/.config/flavours/templates" = { target = "~/.config/flavours/templates", type = "symbolic" }
|
||||||
|
"desktop/.config/waybar/config" = { target = "~/.config/waybar/config", type = "symbolic" }
|
||||||
|
"desktop/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
desktop = "~"
|
||||||
|
|
||||||
|
[disks.files]
|
||||||
|
"disks/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
disks = "~"
|
||||||
|
|
||||||
|
[git.files]
|
||||||
|
"git/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
git = "~"
|
||||||
|
|
||||||
|
[multimedia.files]
|
||||||
|
"multimedia/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
"multimedia/.config/mpv/scripts" = { target = "~/.config/mpv/scripts", type = "symbolic" }
|
||||||
|
"multimedia/.config/ncmpcpp/config" = { target = "~/.config/ncmpcpp/config", type = "symbolic" }
|
||||||
|
multimedia = "~"
|
||||||
|
|
||||||
|
[nvim.files]
|
||||||
|
nvim = "~"
|
||||||
|
|
||||||
|
[office.files]
|
||||||
|
"office/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
"office/.config/glow/email.json" = { target = "~/.config/glow/email.json", type = "symbolic" }
|
||||||
|
office = "~"
|
||||||
|
|
||||||
|
[pass.files]
|
||||||
|
"pass/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
pass = "~"
|
||||||
|
|
||||||
|
[qutebrowser.files]
|
||||||
|
qutebrowser = "~"
|
||||||
|
|
||||||
|
[scripts.files]
|
||||||
|
"scripts/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
scripts = "~"
|
||||||
|
|
||||||
|
[services.files]
|
||||||
|
"services/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
services = "~"
|
||||||
|
|
||||||
|
[social.files]
|
||||||
|
social = "~"
|
||||||
|
|
||||||
|
[ssh.files]
|
||||||
|
ssh = "~"
|
||||||
|
|
||||||
|
[terminal.files]
|
||||||
|
"terminal/.config/vifm" = { target = "~/.config/vifm", type = "symbolic" }
|
||||||
|
terminal = "~"
|
||||||
|
|
||||||
|
[writing.files]
|
||||||
|
"writing/README.md" = { target = "~/README.md", type = "symbolic", if = "false" }
|
||||||
|
writing = "~"
|
7
.dotter/incl-systemwide.toml
Normal file
7
.dotter/incl-systemwide.toml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[system]
|
||||||
|
|
||||||
|
[system.files]
|
||||||
|
"bootstrap/system-packages" = { target = "/", type = "symbolic", owner = "root" }
|
||||||
|
|
||||||
|
[system.variables]
|
||||||
|
|
171
install.sh
171
install.sh
|
@ -9,27 +9,33 @@
|
||||||
#
|
#
|
||||||
# Finally, symlinks all dotfiles into their correct locations using stow
|
# Finally, symlinks all dotfiles into their correct locations using stow
|
||||||
|
|
||||||
bootstrap_dir="${BOOTSTRAP_DIRECTORY:-./bootstrap}"
|
bootstrap_dir="${DOT_BOOTSTRAP_DIR:-./bootstrap}"
|
||||||
|
unattended_install="${DOT_UNATTENDED_INSTALL:-false}"
|
||||||
|
link_systemfiles="${DOT_LINK_SYSTEMFILES:-true}"
|
||||||
|
|
||||||
|
help() {
|
||||||
|
printf "Usage: install [-f|--force][-v|--version][-h|--help]\n\n-f Do not ask for any confirmations but force update and installation.\n"
|
||||||
|
exit "${1:-0}"
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local cmd=""
|
local cmd=""
|
||||||
local ret=0
|
local ret=0
|
||||||
|
case "$1" in
|
||||||
case "$1" in
|
-v | --version)
|
||||||
-v | --version)
|
printf "Personal system bootstrap script.\n\nby Marty Oehme\n\nv0.2\n"
|
||||||
printf "Personal system bootstrap script.\n\nby Marty Oehme\n\nv0.2\n"
|
;;
|
||||||
;;
|
-h | --help)
|
||||||
-h | --help)
|
help 0
|
||||||
printf "Usage: install [-f|--force][-v|--version][-h|--help]\n\n-f Do not ask for any confirmations but force update and installation.\n"
|
;;
|
||||||
;;
|
-f | --force)
|
||||||
-f | --force)
|
unattended_install=true
|
||||||
install true
|
;;
|
||||||
;;
|
*)
|
||||||
*)
|
install
|
||||||
install false
|
;;
|
||||||
;;
|
esac
|
||||||
esac
|
shift
|
||||||
shift
|
|
||||||
|
|
||||||
$cmd "$@"
|
$cmd "$@"
|
||||||
ret=$((ret + $?))
|
ret=$((ret + $?))
|
||||||
|
@ -39,93 +45,94 @@ main() {
|
||||||
# takes default value (y/n), question, abort message as arguments
|
# takes default value (y/n), question, abort message as arguments
|
||||||
# automatically answers yes if unattended install
|
# automatically answers yes if unattended install
|
||||||
check_consent() {
|
check_consent() {
|
||||||
if [ "$UNATTENDED" == "true" ]; then
|
if [ "$unattended_install" == "true" ]; then
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
[[ "$1" == "y" ]] && default_consent="[Y/n]" || default_consent="[y/N]"
|
[[ "$1" == "y" ]] && default_consent="[Y/n]" || default_consent="[y/N]"
|
||||||
printf "%b %b " "$2" "$default_consent"
|
printf "%b %b " "$2" "$default_consent"
|
||||||
read -r answer
|
read -r answer
|
||||||
if [[ "$1" == "n" ]] && [[ "$answer" != y* ]]; then
|
if [[ "$1" == "n" ]] && [[ "$answer" != y* ]]; then
|
||||||
printf "%s\n" "$3"
|
printf "%s\n" "$3"
|
||||||
false
|
false
|
||||||
elif [[ "$1" == "y" ]] && [[ "$answer" == n* ]]; then
|
elif [[ "$1" == "y" ]] && [[ "$answer" == n* ]]; then
|
||||||
printf "%s\n" "$3"
|
printf "%s\n" "$3"
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_question() {
|
entry_question() {
|
||||||
check_consent n "This will take a while and install many packages and link dotfiles all over the place depending on your selections.\nYou need to be in the base directory of the dotfiles repository.\nProceed?" "Aborting." || exit
|
check_consent n "This will take a while and install many packages and link dotfiles all over the place depending on your selections.\nYou need to be in the base directory of the dotfiles repository.\nProceed?" "Aborting." || exit
|
||||||
}
|
}
|
||||||
|
|
||||||
enable_git_hooks() {
|
enable_git_hooks() {
|
||||||
check_consent y "Should we enable git hooks for this repository, so that installed packages are automatically compared when committing?" "Not changing repository settings." || return
|
check_consent y "Should we enable git hooks for this repository, so that missing or additionally installed packages are automatically compared to the repository when committing?" "Not changing repository settings." || return
|
||||||
git config --local core.hooksPath .githooks/
|
git config --local core.hooksPath .githooks/
|
||||||
echo "Changed repository settings."
|
echo "Changed repository settings."
|
||||||
}
|
}
|
||||||
|
|
||||||
stow_dotfiles() {
|
manage_dotfiles() {
|
||||||
check_consent y "Link home directory dot files?" "Not linking dotfiles." || return
|
check_consent y "Link dot files?" "Not linking dotfiles." || return
|
||||||
# get all top level directories, remove their slashes and dots
|
check_consent n "Link system settings files? This will require sudo access but will not overwrite existing files." "Not touching system files." || link_systemfiles=false
|
||||||
# finally get rid of .dot-directories, since they are for the repo not for my homedir
|
if [ "$link_systemfiles" == "false" ]; then
|
||||||
targets="$(find . -maxdepth 1 -type d | sed -e 's/^\.\/\(.*\)$/\1/' | sed -e '/^\./d')"
|
dotter deploy -l .dotter/dots.toml
|
||||||
|
echo "Linked dotfiles."
|
||||||
# shellcheck disable=2086
|
else
|
||||||
# -- for some reason stow only works with unqoted var expansion
|
if [ -e "/etc/pacman.conf" ]; then
|
||||||
stow -R ${targets} 2> >(grep -v 'Absolute/relative mismatch between Stow dir' 1>&2)
|
check_consent n "Found an existing pacman.conf file, installation will error if it exists. Remove file?" && run_elevated rm "/etc/pacman.conf"
|
||||||
echo "Linked dotfiles."
|
fi
|
||||||
|
dotter deploy -l .dotter/dots-with-systemwide.toml
|
||||||
|
echo "Linked dotfiles and system files."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
run_elevated() {
|
run_elevated() {
|
||||||
if command -v doas >/dev/null 2>&1; then
|
if command -v doas >/dev/null 2>&1; then
|
||||||
doas "$@"
|
doas "$@"
|
||||||
elif command -v sudo >/dev/null 2>&1; then
|
elif command -v sudo >/dev/null 2>&1; then
|
||||||
sudo "$@"
|
sudo "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stow_system_packages() {
|
|
||||||
check_consent n "Link system settings files? This will require sudo access and may overwrite existing files." "Not touching system files." || return
|
|
||||||
if [ -e "/etc/pacman.conf" ]; then
|
|
||||||
check_consent n "Found an existing pacman.conf file, installation will error if it exists. Remove file?" && run_elevated rm "/etc/pacman.conf"
|
|
||||||
fi
|
|
||||||
run_elevated stow --dir="$bootstrap_dir" --target="/" -R system-packages/
|
|
||||||
echo "Linked system files."
|
|
||||||
}
|
|
||||||
|
|
||||||
install_packages() {
|
install_packages() {
|
||||||
check_consent n "Install pre-designated packages? This will take a while, install a lot of packages and require super user privileges." "Not installing packages." || return
|
check_consent n "Install pre-designated packages? This will take a while, install a lot of packages and require super user privileges." "Not installing packages." || return
|
||||||
if ! "$UNATTENDED"; then
|
if [ "$unattended_install" == "true" ]; then
|
||||||
"$bootstrap_dir"/install_packages.sh
|
"$bootstrap_dir"/install_packages.sh -f
|
||||||
else
|
else
|
||||||
"$bootstrap_dir"/install_packages.sh -f
|
"$bootstrap_dir"/install_packages.sh
|
||||||
fi
|
fi
|
||||||
echo "Installed packages."
|
echo "Installed packages."
|
||||||
|
}
|
||||||
|
|
||||||
|
headline() {
|
||||||
|
len="${#1}"
|
||||||
|
target_len=85
|
||||||
|
side_len=$(((target_len - len) / 2))
|
||||||
|
for ((i = 1; i <= side_len; i++)); do printf '='; done
|
||||||
|
printf " %s " "$1"
|
||||||
|
for ((i = 1; i <= side_len; i++)); do printf '='; done
|
||||||
|
printf "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
UNATTENDED=$1
|
if [ "$unattended_install" == false ] ; then
|
||||||
if ! "$UNATTENDED"; then
|
entry_question
|
||||||
entry_question
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
echo "====================== BEGINNING SYSTEM FILE MANAGEMENT ============================="
|
headline "BEGINNING PACKAGE INSTALLATION"
|
||||||
stow_system_packages
|
install_packages
|
||||||
|
|
||||||
echo "====================== BEGINNING PACKAGE INSTALLATION ============================="
|
headline "BEGINNING DOTFILE MANAGEMENT"
|
||||||
install_packages
|
manage_dotfiles
|
||||||
|
|
||||||
echo "=================== BEGINNING DOTFILE MANAGEMENT =========================="
|
headline "ENABLING GIT REPOSITORY HOOKS"
|
||||||
stow_dotfiles
|
enable_git_hooks
|
||||||
|
|
||||||
echo "================== ENABLING GIT REPOSITORY HOOKS =========================="
|
echo "INSTALLATION FINISHED"
|
||||||
enable_git_hooks
|
exit 0
|
||||||
|
|
||||||
echo "====================== INSTALLATION FINISHED =============================="
|
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
Loading…
Reference in a new issue