-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·87 lines (71 loc) · 1.9 KB
/
setup.sh
File metadata and controls
executable file
·87 lines (71 loc) · 1.9 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
#!/bin/bash
# Written with Gemini because I'm lazy and don't want to write it myself.
check_env() {
local env_file=".env"
local keys=(
"DISCORD_TOKEN"
"GUILD_ID"
"PUG_STAFF_ROLE_ID"
"PUG_BANNED_ROLE_ID"
"PUG_NOTES_CHANNEL_ID"
)
local keys_added=()
if ([ ! -f "$env_file" ] || [ ! -s "$env_file" ]); then
echo "⚠️ $env_file not found. Creating it..."
touch "$env_file"
fi
for key in "${keys[@]}"; do
if ! grep -q "^$key=" "$env_file"; then
echo "Adding $key to $env_file"
echo "$key=" >> "$env_file"
keys_added+=("$key")
else
echo "$key already exists in $env_file"
fi
done
if [ ${#keys_added[@]} -eq 0 ]; then
echo "✅ All required keys are already present in $ENV_FILE."
else
echo "➕ Added missing keys to $ENV_FILE:"
for key in "${keys_added[@]}"; do
echo " - $key"
done
fi
}
check_data_dir() {
local data_dir="${1:-data}" # Default to 'data' if no argument passed
if [ -d "$data_dir" ]; then
echo "✅ Data directory '$data_dir' already exists."
else
echo "📁 Data directory '$data_dir' not found. Creating it..."
mkdir -p "$data_dir"
if [ $? -eq 0 ]; then
echo "✅ Created '$data_dir' successfully."
else
echo "❌ Failed to create '$data_dir'. Check permissions."
return 1
fi
fi
}
check_sqlite_db() {
local db_file="${1:-data/db.sqlite}"
if [ -f "$db_file" ]; then
echo "✅ SQLite database file '$db_file' already exists."
else
echo "📁 SQLite database file '$db_file' not found. Creating it..."
touch "$db_file"
if [ $? -eq 0 ]; then
echo "✅ Created '$db_file' successfully."
else
echo "❌ Failed to create '$db_file'. Check permissions."
return 1
fi
fi
}
check_env
check_data_dir
check_sqlite_db
echo "Installing dependencies..."
bun install
echo "Installing Lefthook..."
bun run lefthook install