init + binary
This commit is contained in:
parent
9e3aefc525
commit
926bc33e3b
3 changed files with 49 additions and 0 deletions
24
README.md
24
README.md
|
|
@ -8,3 +8,27 @@ It expects the following environment variables to be set:
|
||||||
- `API_TOKEN` - Forgejo API authorization token
|
- `API_TOKEN` - Forgejo API authorization token
|
||||||
- `REDIRECT_URL` - Redirect url when access fails or files do not exist (ex. `https://git.brut.systems`)
|
- `REDIRECT_URL` - Redirect url when access fails or files do not exist (ex. `https://git.brut.systems`)
|
||||||
- `PORT` - Port to listen on
|
- `PORT` - Port to listen on
|
||||||
|
|
||||||
|
## Usage w/ systemd
|
||||||
|
|
||||||
|
Create a file at `/etc/systemd/system/docs.brut.service` with the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=Serves files from Git repositories
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=<path/to/respository>/start.sh
|
||||||
|
ExecStop=/usr/bin/pkill docs.brut.systems
|
||||||
|
Restart=always
|
||||||
|
User=<user to run as>
|
||||||
|
Environment="API_URL=<url>"
|
||||||
|
Environment="API_TOKEN=<token>"
|
||||||
|
Environment="REDIRECT_URL=<url>"
|
||||||
|
Environment="PORT=<port>"
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
|
||||||
BIN
docs.brut.systems
Executable file
BIN
docs.brut.systems
Executable file
Binary file not shown.
25
start.sh
Executable file
25
start.sh
Executable file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
EXECUTABLE="./docs.brut.systems"
|
||||||
|
|
||||||
|
git pull
|
||||||
|
|
||||||
|
if command -v go &> /dev/null; then
|
||||||
|
echo "Recompiling latest version..."
|
||||||
|
|
||||||
|
go build -o "$EXECUTABLE" .
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Compilation failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Compilation successful."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x "$EXECUTABLE" ]; then
|
||||||
|
echo "Starting $EXECUTABLE..."
|
||||||
|
"$EXECUTABLE" "$@"
|
||||||
|
else
|
||||||
|
echo "Error: Executable not found and Go is not installed to compile it."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Loading…
Reference in a new issue