-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
ยท155 lines (132 loc) ยท 3.7 KB
/
install.sh
File metadata and controls
executable file
ยท155 lines (132 loc) ยท 3.7 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash
set -euo pipefail
DIR="$(dirname -- "$(readlink -f -- "$0")")"
source "$DIR/scripts/common/main.sh"
DEFAULT_PROFILE="full"
OS="$(detect_os)"
main() {
run_profile "$DEFAULT_PROFILE"
}
profile_modules() {
local profile="$1"
case "$profile" in
full)
printf "%s\n" "system_base user_core desktop_env dev_tools optional_extras"
;;
minimal-server)
printf "%s\n" "system_base user_core"
;;
desktop)
printf "%s\n" "system_base user_core desktop_env optional_extras"
;;
dev-workstation)
printf "%s\n" "system_base user_core dev_tools"
;;
*)
return 1
;;
esac
}
print_banner() {
print_in_blue "โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ"
print_in_blue "โ System setup โ"
print_in_blue "โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ"
}
print_section_title() {
local title="$1"
print_in_blue "โบ $title"
}
print_command_row() {
local label="$1"
local description="$2"
printf " %-28s %s\n" "$label" "$description"
}
prepare_install() {
if [[ $OS != "unknown" ]]; then
source "$DIR/scripts/$OS/main.sh"
else
print_in_red "โ Operating system not recognized, aborting"
exit 1
fi
print_in_blue "Current dotfiles directory: $DIR"
print_in_blue "Detected operating system: $OS"
ask_for_sudo
}
run_profile() {
local profile="$1"
local modules
if ! modules="$(profile_modules $profile)"; then
list_profiles "โ Unknown profile: $profile"
exit 1
fi
prepare_install
print_in_blue "โ Running profile: $profile"
for module in $modules; do
print_in_blue "โ Executing $module"
"$module"
done
}
list_profiles() {
local message="${1-}"
print_banner
if [[ -n $message ]]; then
print_in_red "$message"
printf "\n"
fi
print_section_title "Available profiles"
printf "\n"
printf " %-17s %s\n" "Name" "Description"
printf " %-17s %s\n" "-----------------" "----------------------------------"
print_profile "full" "Complete workstation setup"
print_profile "minimal-server" "Bare essentials for servers"
print_profile "desktop" "Desktop essentials without dev tools"
print_profile "dev-workstation" "Full desktop plus dev tooling"
}
print_profile() {
local name="$1"
local description="$2"
printf " %-17s %s\n" "$name" "$description"
printf " %-17s %s\n" "" "Modules: $(profile_modules $name)"
printf "\n"
}
print_usage() {
print_banner
print_section_title "Usage"
print_command_row "./install.sh [profile <name>|list-profiles|help|<function>]" ""
printf "\n"
print_section_title "Commands"
print_command_row "profile <name>" "Run a named profile"
print_command_row "list-profiles" "Show available profiles"
print_command_row "help | -h | --help" "Show this help"
print_command_row "<function>" "Run an individual module"
printf "\n"
print_section_title "Examples"
print_command_row "./install.sh" "Full installation (default profile)"
print_command_row "./install.sh profile desktop" "Run the desktop profile"
print_command_row "./install.sh dev_tools" "Call an individual module"
print_command_row "./install.sh setup_bins" "Call an individual setup sub-module"
}
if [[ $# -eq 0 ]]; then
main
exit 0
fi
case "$1" in
profile)
shift
if [[ $# -eq 0 ]]; then
list_profiles "โ Missing profile name"
exit 1
fi
run_profile "$1"
;;
list-profiles)
list_profiles
;;
help | -h | --help)
print_usage
;;
*)
prepare_install
"$@"
;;
esac