-
Notifications
You must be signed in to change notification settings - Fork 15
/
install
executable file
·122 lines (110 loc) · 2.67 KB
/
install
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
ROOT_DIR=$(dirname "${BASH_SOURCE[0]:-$0}")
cd "${ROOT_DIR}" || exit 127
# shellcheck source=./packages.sh
. packages.sh
# shellcheck source=../scripts/distro.sh
. scripts/distro.sh
# shellcheck source=scripts/execs.sh
. scripts/execs.sh
# shellcheck source=scripts/helpers.sh
. scripts/helpers.sh
# shellcheck source=scripts/logging.sh
. scripts/logging.sh
# shellcheck source=scripts/utils.sh
. scripts/utils.sh
PROGRAM=$(basename "${BASH_SOURCE[0]:-$0}")
VERSION=0.14.0
function display_help() {
cat <<EOF
$(help_title_section Usage)
${PROGRAM} [options] [<command>]
$(help_title_section Commands)
check
packages [--repo | --aur]
modules
update
clean
$(help_title_section Options)
-h --help Show this screen.
-v --version Show version.
EOF
}
function install_packages() {
case ${1:-all} in
--repo | repo)
# ===============================================
# Install packages from repo (--repo)
# ===============================================
for pkg in "${REPO[@]}"; do
install_package "$pkg"
done
;;
--aur | aur)
# ===============================================
# Install packages from aur (--aur)
# ===============================================
for pkg in "${AUR[@]}"; do
install_package "$pkg"
done
;;
all)
install_packages repo
install_packages aur
;;
esac
}
function install_modules() {
# ===============================================
# Run all sub folders install script
# ===============================================
local dirs=$(find . -maxdepth 1 -mindepth 1 -type d -print | sed -e 's/.\///')
for dir in $dirs; do
if [ ! -f "$dir/install.sh" ]; then
continue
fi
log_section "${dir}"
./"${dir}"/install.sh
done
}
dotfiles_setup() {
case ${1:-all} in
-h | --help)
display_help
;;
-v | --version)
display_version "${VERSION}" "${PROGRAM}"
;;
check)
yay -Ps
;;
packages)
ask_for_sudo
install_packages "${2:-all}"
;;
modules)
ask_for_sudo
install_modules
;;
update)
ask_for_sudo
execute "yay -Syyu --needed --noconfirm" "Updating all system packages..."
xdg-mime default pcmanfm.desktop inode/directory
;;
clean)
ask_for_sudo
execute "yay --noconfirm -Rns $(yay -Qdtq); yay -Yc" "Uninstalling unecessary packages..."
;;
all)
dotfiles_setup packages
dotfiles_setup modules
dotfiles_setup update
dotfiles_setup clean
;;
*)
display_help >&2
exit 1
;;
esac
}
dotfiles_setup "$@"