-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller
More file actions
115 lines (94 loc) · 2.87 KB
/
installer
File metadata and controls
115 lines (94 loc) · 2.87 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
#!/usr/bin/env bash
set -euo pipefail
export DOTFILES_PATH="$HOME/_dotfiles"
# Pretty print function
pp() {
local symbol=$1
local message=$2
printf "\033[1m%s\033[0m %s\n" "$symbol" "$message"
}
# pp "→" "checking internal git connection..."
# echo y | ssh-keygen -t ecdsa -N '' -f ~/.ssh/id_ecdsa &>/dev/null
# if [ ! -f ~/.ssh/known_hosts ] || ! grep -q "^git.amazon.com" ~/.ssh/known_hosts; then
# pp "!" "git not figured.. adding git.amazon.com to known hosts"
# ssh-keyscan git.amazon.com >> ~/.ssh/known_hosts
# if [ $? -eq 0 ]; then
# pp "✓" "Successfully added git.amazon.com to known hosts."
# else
# pp "×" "Failed to add git.amazon.com to known hosts. Exiting."
# exit 1
# fi
# pp "✓" "git.amazon.com is present in known hosts"
# fi
pp "→" "Starting setup..."
handle_kinit() {
if command -v kinit &>/dev/null; then
if klist -s ; then
pp "✓" "Kerberos ticket is valid."
else
set +e
kinit -f
local status=$?
set -e
if [ $status -ne 0 ]; then
pp "×" "Kinit failed"
exit 1
fi
fi
fi
}
handle_midway_auth() {
set +e
mwinit -o
local status=$?
set -e
if [ $status -ne 0 ]; then
pp "×" "Authentication failed"
exit 1
fi
}
if command -v mwinit &>/dev/null; then
pp "!" "Refreshing Kinit credentials..."
handle_kinit
pp "!" "Refreshing Midway credentials..."
handle_midway_auth
fi
pp "→" "Preparing installation"
# Check for git
if ! command -v git &>/dev/null; then
pp "×" "Git is required but not installed"
exit 1
fi
if ! command -v brew &>/dev/null; then
pp "!" "Hombrew Not found, installing..."
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" &>/dev/null;
# Add Homebrew to PATH for this session
if [[ -f /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)" &>/dev/null
elif [[ -f /home/linuxbrew/.linuxbrew/bin/brew ]]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" &>/dev/null
elif [[ -f /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)" &>/dev/null
fi
pp "✓" "Homebrew installed"
fi
if ! command -v gum &>/dev/null; then
pp "!" "Gum not found. Installing via Homebrew..."
eval "(brew install gum)" &>/dev/null
pp "✓" "gum is installed"
fi
if [ -d "$DOTFILES_PATH" ]; then
pp "!" "${DOTFILES_PATH} exists..Deleting"
sudo rm -rf "$DOTFILES_PATH"
fi
# Clone repository
pp "→" "Cloning dotfiles..."
git clone --quiet --no-progress --depth 1 https://github.com/vinodismyname/dotfiles-v.git "$DOTFILES_PATH" &>/dev/null || {
pp "×" "Failed to clone repository"
exit 1
}
# Make scripts executable
find "$DOTFILES_PATH" -type f \( -name "*.sh" -o -name "*.bash" -o -name "*.zsh" \) -exec chmod +x {} +
# Run installer
pp "→" "Running installer..."
"$DOTFILES_PATH/main/install"