Fix and automate systemd deployment

main
gravel 4 months ago
parent 558898b949
commit b8c9fe390d
Signed by: gravel
GPG Key ID: C0538F3C906B308F

@ -18,6 +18,11 @@ sco: fetch html
all:
/bin/php php/update-all.php $(FLAGS)
# Refresh listing, but via systemd, and follow logs.
sysd:
/bin/systemctl start sessioncommunities.service
/bin/journalctl --follow --unit=sessioncommunities.service
# Fetch room listing.
fetch:
/bin/php php/fetch-servers.php $(FLAGS)
@ -95,6 +100,10 @@ test-noninteractive: clean all
test-ci: FLAGS = --verbose --no-color
test-ci: clean all
# Install systemd service and timer.
install-systemd:
sudo etc/systemd/systemd-install.sh
# -- Aliases --
serve: server

@ -1,8 +1,8 @@
# /etc/systemd/system/sessioncommunities.service
[Unit]
Description=Scrape every known source for Session Communities and put the data to a NGINX accessible folder
Description=Session Communities aggregator
[Service]
WorkingDirectory=/home/session/sessioncommunities.online
User=session
### User=$USER
### WorkingDirectory=$PROJECT
ExecStart=/usr/bin/sh -c "/usr/bin/php php/update-all.php --verbose --archive --no-color 2>&1 | /usr/bin/tee sessioncommunities.log"

@ -0,0 +1,13 @@
#!/bin/sh
cd "$(dirname "$0")" || exit 1
mydir="$(pwd)"
while ! [ -f ".phpenv.php" ]; do cd ..; done
project="$(pwd)"
/bin/cp "$mydir/sessioncommunities.timer" "/etc/systemd/system/" || exit 1
/bin/sed \
-e "/^### /s/\$USER/$USER/g" \
-e "/^### /s,\$PROJECT,$project,g" \
-e "s/^### //g" \
etc/systemd/sessioncommunities.service \
> /etc/systemd/system/sessioncommunities.service
/bin/systemctl daemon-reload
Loading…
Cancel
Save