-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotfiles.sh
More file actions
executable file
·45 lines (40 loc) · 953 Bytes
/
dotfiles.sh
File metadata and controls
executable file
·45 lines (40 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# shellcheck disable=SC1090
DOT_FILES_DIR="$(dirname "$(realpath "$0")")"
declare -xr DOT_FILES_DIR
for src in "${DOT_FILES_DIR}/scripts"/*.sh; do
source "${src}" || exit 1
done
export info warn require_system_executable read_input_args
export get_default_user_name get_default_user_mail
install_package() {
local name="$1"; shift
local root="${DOT_FILES_DIR}/packages/${name}"
if [[ -z "${name}" || ! -d "${root}" ]]; then
warn "The package %s does not exists" "${name}"
return
fi
# install script is no executable
if [[ ! -x "${root}/install.sh" ]]; then
chmod u+x "${root}/install.sh"
fi
info "Installing %s" "${name}"
"${root}/install.sh"
}
run() {
local args
while [[ $# -gt 0 ]]; do
args="$1"; shift
case "${args}" in
install)
local package
while [[ $# -gt 0 ]]; do
package="$1"; shift
install_package "${package}"
done
;;
esac
done
}
# shellcheck disable=SC2068
run $@