So you want to use semaphore and shocked because the installer has no any startup script?
Yes, I know the feeling.
After a copy-paste of a existing unit file I realized it is outdated and fundamentally silly, so I have to make my own anyway.
Also wanted to play with some github actions, so ended up with a automatically updated public repo.
#!/bin/bash
DEFCONFIG="/etc/default/ansible-semaphore"
ETCFILE="/etc/ansible-semaphore/semaphore_config.json"
if [ "$(hostname)" != "semaphore0" ]
then
echo "Run on semaphore0 as root."
exit 1
fi
if [ ! -f "${ETCFILE}" ]
then
echo "No config file deployed, fix it please."
fi
if [ ! -f "${DEFCONFIG}" ]
then
echo '#Ansible Semaphore Defaults' > "${DEFCONFIG}"
echo "SEMAPHORE_CONFIG=${ETCFILE}" >> "${DEFCONFIG}"
fi
cat > /etc/systemd/system/semaphore.service <<'EOF'
[Unit]
Description=Ansible Semaphore
[Service]
Type=forking
EnvironmentFile=-/etc/default/ansible-semaphore
ExecStart=/bin/sh -c "/usr/bin/semaphore server --config ${SEMAPHORE_CONFIG}&"
Restart=always
RestartSec=10s
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now semaphore
#!/bin/bash
systemctl disable --now semaphore
rm /etc/systemd/system/semaphore.service
systemctl daemon-reload