mirror of
https://github.com/shouptech/tempgopher.git
synced 2026-02-03 08:39:43 +00:00
Add an installation script
Script will download the latest binary from master and create a systemd unit file to start it.
This commit is contained in:
parent
345d308f85
commit
66051179fc
1 changed files with 35 additions and 0 deletions
35
install.sh
Normal file
35
install.sh
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
INSTALLDIR=/opt/tempgopher
|
||||
INSTALLBIN=$INSTALLDIR/tempgopher
|
||||
INSTALLUSER=pi
|
||||
BINURL='https://gitlab.com/shouptech/tempgopher/-/jobs/artifacts/master/raw/tempgopher?job=build'
|
||||
CONFIGFILE=$INSTALLDIR/config.yml
|
||||
|
||||
# Download binary
|
||||
sudo mkdir -p $INSTALLDIR
|
||||
sudo curl -L $BINURL -o $INSTALLBIN
|
||||
sudo chmod +x $INSTALLBIN
|
||||
sudo chown -R $INSTALLUSER: $INSTALLDIR
|
||||
|
||||
# Create unit file
|
||||
sudo sh -c "cat > /etc/systemd/system/tempgopher.service" << EOM
|
||||
[Unit]
|
||||
Description=Temp Gopher
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=$INSTALLDIR
|
||||
ExecStart=$INSTALLBIN -c $CONFIGFILE run
|
||||
ExecReload=/bin/kill -HUP \$MAINPID
|
||||
User=$INSTALLUSER
|
||||
Group=$INSTALLUSER
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOM
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable tempgopher.service
|
||||
sudo systemctl start tempgopher.service
|
||||
Loading…
Add table
Reference in a new issue