-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·176 lines (144 loc) · 4.36 KB
/
install.sh
File metadata and controls
executable file
·176 lines (144 loc) · 4.36 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/bash
set -e
# Config
REPO_URL="https://github.com/trapplus/deb_scripts.git"
UV_INSTALL_URL="https://astral.sh/uv/install.sh"
INSTALL_DIR="$HOME/deb_scripts"
REPO_NAME="deb_scripts"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m'
BOLD='\033[1m'
print_header() {
echo -e "${CYAN}${BOLD}"
echo " ╔════════════════════════════════════════╗"
echo " ║ deb_scripts Installer ║"
echo " ╚════════════════════════════════════════╝"
echo -e "${NC}"
}
print_step() {
echo -e "${BLUE}▶${NC} ${BOLD}$1${NC}"
}
print_success() {
echo -e "${GREEN}✔${NC} $1"
}
print_error() {
echo -e "${RED}✖${NC} $1"
}
print_info() {
echo -e "${YELLOW}ℹ${NC} $1"
}
check_command() {
if command -v "$1" &> /dev/null; then
return 0
else
return 1
fi
}
install_uv() {
print_step "Checking uv installation..."
if check_command uv; then
print_success "uv already installed"
return 0
fi
print_step "Installing uv..."
if curl -fsSL "$UV_INSTALL_URL" | sh < /dev/null; then
print_success "uv successfully installed"
export PATH="$HOME/.cargo/bin:$PATH"
return 0
else
print_error "Failed to install uv"
return 1
fi
}
setup_repository() {
if [ -d "$INSTALL_DIR" ]; then
print_info "Repository already exists at $INSTALL_DIR"
# Redirect stdin to /dev/tty for read
if [ ! -t 0 ]; then
exec < /dev/tty
fi
read -p "$(echo -e ${YELLOW}Update scripts? [Y/n]:${NC} )" -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
print_info "Skipping update, using existing version"
return 0
fi
print_step "Updating repository..."
cd "$INSTALL_DIR"
if git pull origin master < /dev/null; then
print_success "Repository updated successfully"
return 0
else
print_error "Failed to update repository"
return 1
fi
else
print_step "Cloning repository..."
if ! check_command git; then
print_error "Git is not installed. Please install git and try again"
exit 1
fi
if git clone "$REPO_URL" "$INSTALL_DIR" < /dev/null; then
print_success "Repository cloned to $INSTALL_DIR"
return 0
else
print_error "Failed to clone repository"
return 1
fi
fi
}
install_dependencies() {
print_step "Installing dependencies..."
cd "$INSTALL_DIR"
if uv sync < /dev/null; then
print_success "Dependencies installed successfully"
return 0
else
print_error "Failed to install dependencies"
return 1
fi
}
print_final_message() {
echo
echo -e "${CYAN}${BOLD}════════════════════════════════════════${NC}"
echo -e "${GREEN}${BOLD} Installation completed!${NC}"
echo -e "${CYAN}${BOLD}════════════════════════════════════════${NC}"
echo
echo -e "${BOLD}To run the script execute:${NC}"
echo
echo -e " ${MAGENTA}cd $INSTALL_DIR && uv run main.py${NC}"
echo
echo -e "${YELLOW}Tip:${NC} Add alias to ~/.bashrc or ~/.zshrc:"
echo
echo -e " ${CYAN}alias deb='cd $INSTALL_DIR && uv run main.py'${NC}"
echo
echo -e "${CYAN}${BOLD}════════════════════════════════════════${NC}"
}
main() {
clear
print_header
if ! install_uv; then
exit 1
fi
echo
if ! setup_repository; then
exit 1
fi
echo
if ! install_dependencies; then
exit 1
fi
print_final_message
if [[ ! ":$PATH:" == *":$HOME/.cargo/bin:"* ]]; then
echo
print_info "You may need to reload shell or run:"
echo -e " ${CYAN}source ~/.bashrc${NC} ${YELLOW}or${NC} ${CYAN}source ~/.zshrc${NC}"
echo
fi
}
main