Skip to content

Commit 6432216

Browse files
committed
resolve reviewer comments
1 parent 9088b09 commit 6432216

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

install-and-run.sh renamed to install.sh

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,32 @@
1212
# - Creates a Python virtual environment in ./env
1313
# - Installs project dependencies with pip
1414
# - Verifies that data/config.yaml exists
15-
# - Generates a systemd user service at ~/.config/systemd/user/ioibot2025.service
15+
# - Generates a systemd user service at ~/.config/systemd/user/ioibot.service
1616
#
1717
# TO START THE BOT:
18-
# systemctl --user start ioibot2025.service
18+
# systemctl --user start ioibot.service
1919
#
2020
# TO VIEW LOGS:
21-
# journalctl --user -u ioibot2025.service -f
21+
# journalctl --user -u ioibot.service -f
2222
#
2323
# NOTES:
2424
# - You must edit 'data/sample.config.yaml' and save it as 'data/config.yaml'
2525
# before starting the bot.
26-
# - You must set the environment variables VOTING_USERNAME and VOTING_PASSWORD
27-
# in the systemd service file:
28-
# ~/.config/systemd/user/ioibot2025.service
29-
# These are required for the bot to work properly.
26+
# - The systemd service file will be created at:
27+
# ~/.config/systemd/user/ioibot.service
3028

3129
set -euo pipefail
3230

3331
# Variable names
34-
SERVICE_NAME="ioibot2025.service"
32+
SERVICE_NAME="ioibot.service"
3533
SYSTEMD_DIR="$HOME/.config/systemd/user"
3634
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3735
DATA_DIR="$PROJECT_DIR/data"
38-
VENV="$PROJECT_DIR/env"
36+
VENV="$PROJECT_DIR/venv"
3937
BOT="$VENV/bin/ioibot"
4038
CONFIG="$DATA_DIR/config.yaml"
4139
TEMPLATE="$DATA_DIR/sample.config.yaml"
40+
INIT_SQL="$PROJECT_DIR/ioibot/init.sql"
4241

4342
if [ ! -d "$VENV" ]; then
4443
python3 -m venv "$VENV"
@@ -48,9 +47,6 @@ fi
4847
source "$VENV/bin/activate"
4948

5049
# Install Python packages
51-
pip install --upgrade pip
52-
pip install flit
53-
pip install -e ".[postgres]"
5450
pip install -e .
5551

5652
if [ ! -f "$CONFIG" ]; then
@@ -64,10 +60,13 @@ if [ ! -f "$CONFIG" ]; then
6460
fi
6561
fi
6662

67-
68-
# Make sure the bot file is executable
69-
if [ ! -x "$BOT" ]; then
70-
chmod +x "$BOT"
63+
# Initialize database schema if init.sql exists
64+
if [ -f "$INIT_SQL" ]; then
65+
echo "Initializing database schema from $INIT_SQL"
66+
psql -f "$INIT_SQL"
67+
else
68+
echo "$INIT_SQL not found. Skipping database initialization."
69+
echo "Please initialize your database manually."
7170
fi
7271

7372
# Create systemd user directory
@@ -82,8 +81,6 @@ After=network.target
8281
8382
[Service]
8483
Type=simple
85-
Environment=VOTING_USERNAME=
86-
Environment=VOTING_PASSWORD=
8784
WorkingDirectory=$DATA_DIR
8885
ExecStart=$BOT config.yaml
8986
Restart=always
@@ -94,16 +91,4 @@ WantedBy=default.target
9491
EOF
9592

9693
# Reload systemd so it sees the new service
97-
systemctl --user daemon-reexec || true
9894
systemctl --user daemon-reload
99-
100-
echo ""
101-
echo "Please update \"$SYSTEMD_DIR/$SERVICE_NAME\" with your custom configurations if needed."
102-
echo ""
103-
echo "To start the bot run:"
104-
echo " systemctl --user start $SERVICE_NAME"
105-
echo ""
106-
echo "To show logs, run:"
107-
echo " journalctl --user -u $SERVICE_NAME -f"
108-
echo ""
109-

0 commit comments

Comments
 (0)