27 lines
925 B
Bash
Executable File
27 lines
925 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [[ "$(id -u)" == 0 ]]; then
|
|
echo "run this installer as the non-root gateway user" >&2
|
|
exit 1
|
|
fi
|
|
|
|
project_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
env_file="${HOME}/.config/creatorhub/browser-gateway.env"
|
|
unit_dir="${HOME}/.config/systemd/user"
|
|
unit_file="${unit_dir}/creatorhub-browser-gateway.service"
|
|
|
|
if [[ ! -f "${env_file}" ]]; then
|
|
echo "missing ${env_file}; copy deploy/browser-gateway.env.example and set GATEWAY_TOKEN and BROWSER_PATH" >&2
|
|
exit 1
|
|
fi
|
|
|
|
install -d -m 0700 "${unit_dir}"
|
|
sed "s|@PROJECT_DIR@|${project_dir}|g" \
|
|
"${project_dir}/deploy/creatorhub-browser-gateway.service.in" > "${unit_file}.tmp"
|
|
chmod 0600 "${unit_file}.tmp"
|
|
mv -f "${unit_file}.tmp" "${unit_file}"
|
|
systemctl --user daemon-reload
|
|
systemctl --user enable --now creatorhub-browser-gateway.service
|
|
systemctl --user --no-pager --full status creatorhub-browser-gateway.service
|