-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
51 lines (43 loc) · 1.28 KB
/
Copy pathsetup.sh
File metadata and controls
51 lines (43 loc) · 1.28 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
#!/bin/bash
# COLORS
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m'
clear
echo -e "${CYAN}=========================================${NC}"
echo -e "${CYAN} MariaDB Auto-Installer & 'startsql' ${NC}"
echo -e "${CYAN}=========================================${NC}"
# 1. Update & Install
echo -e "${GREEN}[1/3] Installing MariaDB...${NC}"
pkg update -y && pkg upgrade -y
pkg install mariadb -y
# 2. Init Database
echo -e "${GREEN}[2/3] Initializing Database...${NC}"
if [ ! -d "$PREFIX/var/lib/mysql/mysql" ]; then
mysql_install_db
else
echo "Database already initialized."
fi
# 3. Create Alias
echo -e "${GREEN}[3/3] Setting up 'startsql' command...${NC}"
BASHRC="$HOME/.bashrc"
# Only add if not already there
if ! grep -q "startsql()" "$BASHRC"; then
cat << 'EOF' >> "$BASHRC"
startsql() {
if pgrep -x "mysqld" >/dev/null; then
echo "✔ Server already running."
else
echo "➤ Starting Server..."
mysqld_safe >/dev/null 2>&1 &
sleep 4
fi
echo "➤ Connecting..."
mysql -u root -p
}
EOF
fi
echo -e "${CYAN}=========================================${NC}"
echo -e "${GREEN}DONE! Restart Termux or type: source ~/.bashrc${NC}"
echo -e "${GREEN}Then type: startsql${NC}"
echo -e "${CYAN}=========================================${NC}"