34 lines
1.2 KiB
Bash
Executable File
34 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Run as root from the project directory on Debian/Ubuntu-like Linux hosts.
|
|
set -euo pipefail
|
|
|
|
APP_DIR=/opt/fetch-x
|
|
CONFIG_DIR=/etc/fetch-x
|
|
SERVICE_USER=fetchx
|
|
|
|
if [[ ${EUID} -ne 0 ]]; then
|
|
echo "Run with sudo: sudo bash deploy/install-linux.sh" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f fetch_x_posts.py || ! -f deploy/fetch-x.service ]]; then
|
|
echo "Run this from the fetch_x project directory." >&2
|
|
exit 1
|
|
fi
|
|
|
|
id -u "$SERVICE_USER" >/dev/null 2>&1 || useradd --system --create-home --shell /usr/sbin/nologin "$SERVICE_USER"
|
|
install -d -o "$SERVICE_USER" -g "$SERVICE_USER" -m 0750 "$APP_DIR"
|
|
install -o "$SERVICE_USER" -g "$SERVICE_USER" -m 0640 fetch_x_posts.py "$APP_DIR/fetch_x_posts.py"
|
|
install -d -m 0750 "$CONFIG_DIR"
|
|
|
|
if [[ ! -f "$CONFIG_DIR/fetch-x.env" ]]; then
|
|
install -m 0600 /dev/null "$CONFIG_DIR/fetch-x.env"
|
|
echo "Created $CONFIG_DIR/fetch-x.env. Add X_BEARER_TOKEN=... before starting the service."
|
|
fi
|
|
|
|
install -m 0644 deploy/fetch-x.service /etc/systemd/system/fetch-x.service
|
|
install -m 0644 deploy/fetch-x.timer /etc/systemd/system/fetch-x.timer
|
|
systemctl daemon-reload
|
|
systemctl enable --now fetch-x.timer
|
|
systemctl list-timers fetch-x.timer --no-pager
|