Skip to content

Commit 0bdf33b

Browse files
committed
update postinstall script
1 parent 2bea8a8 commit 0bdf33b

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

scripts/postinstall.sh

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LOG_DIR="/var/log/vilesql"
99
LOG_FILE="$LOG_DIR/vilesql.log"
1010
BIN_PATH="/usr/bin/vilesql"
1111
SERVICE_PATH="/etc/systemd/system/vilesql.service"
12-
ENV_FILE="/var/lib/vilesql/.env"
12+
ENV_FILE="/etc/vilesql/.env"
1313
USER="vilesql"
1414
GROUP="vilesql"
1515

@@ -36,6 +36,11 @@ if ! id "$USER" &>/dev/null; then
3636
}
3737
fi
3838

39+
# Ensure correct ownership for binary
40+
log "🔧 Fixing ownership for VileSQL binary"
41+
chown "$USER:$GROUP" "$BIN_PATH"
42+
chmod 755 "$BIN_PATH"
43+
3944
# Create necessary directories with correct ownership
4045
for dir in "$DATA_DIR" "$CONFIG_DIR" "$LOG_DIR"; do
4146
if [[ ! -d "$dir" ]]; then
@@ -62,7 +67,7 @@ if [[ ! -f "$ENV_FILE" ]]; then
6267
echo "HOST=0.0.0.0" | sudo tee "$ENV_FILE"
6368
fi
6469

65-
# Fix permissions to allow VileSQL access
70+
# Fix permissions for environment file
6671
log "🔧 Setting correct permissions for environment file"
6772
chown "$USER:$GROUP" "$ENV_FILE"
6873
chmod 600 "$ENV_FILE"
@@ -71,13 +76,6 @@ chmod 600 "$ENV_FILE"
7176
chmod 755 "$DATA_DIR"
7277
chmod 700 "$CONFIG_DIR"
7378
chmod 755 "$LOG_DIR"
74-
chmod 644 "$LOG_FILE"
75-
76-
# Ensure binary exists
77-
if [[ ! -x "$BIN_PATH" ]]; then
78-
log "❌ VileSQL binary not found at $BIN_PATH"
79-
exit 1
80-
fi
8179

8280
# Install systemd service file (if missing)
8381
if [[ ! -f "$SERVICE_PATH" ]]; then
@@ -103,22 +101,17 @@ if ldd "$BIN_PATH" | grep -q "not found"; then
103101
exit 1
104102
fi
105103

106-
# Prompt user to start service immediately
107-
read -p "▶️ Start VileSQL now? (y/n): " choice
108-
if [[ "$choice" == "y" ]]; then
109-
systemctl start vilesql || {
110-
log "❌ Failed to start VileSQL service."
111-
exit 1
112-
}
113-
log "✅ VileSQL service started!"
114-
115-
# Check if service stays running
116-
sleep 2
117-
if ! systemctl is-active --quiet vilesql; then
118-
log "❌ VileSQL stopped unexpectedly! Run: journalctl -u vilesql --no-pager | tail -n 20"
119-
fi
120-
else
121-
log "⚠️ You can start it manually using: sudo systemctl start vilesql"
104+
# Start the service
105+
log "▶️ Starting VileSQL service as user: $USER"
106+
systemctl start vilesql || {
107+
log "❌ Failed to start VileSQL service."
108+
exit 1
109+
}
110+
111+
# Check if service stays running
112+
sleep 2
113+
if ! systemctl is-active --quiet vilesql; then
114+
log "❌ VileSQL stopped unexpectedly! Run: journalctl -u vilesql --no-pager | tail -n 20"
122115
fi
123116

124117
log "✅ VileSQL installation completed successfully!"
@@ -132,5 +125,5 @@ echo "🚀 Next steps:"
132125
echo " 1️⃣ Edit config: sudo nano $ENV_FILE"
133126
echo " 2️⃣ Check status: sudo systemctl status vilesql"
134127
echo " 3️⃣ View logs: sudo tail -f $LOG_FILE"
135-
echo " 4️⃣ Run manually: vilesql --help"
128+
echo " 4️⃣ Run manually: sudo -u vilesql /usr/bin/vilesql --help"
136129
echo ""

0 commit comments

Comments
 (0)