Skip to content

Commit

Permalink
added nfpm package
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFireMike committed Apr 12, 2021
1 parent 2cda710 commit 1140071
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
18 changes: 17 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,27 @@ builds:
env:
- CGO_ENABLED=0

nfpms:
- id: "thola"
homepage: https://thola.io
maintainer: team@thola.io
description: Network Monitoring and Provisioning Tool.
license: BSD-2-clause
formats:
- deb
contents:
- src: scripts/thola.service
dst: /lib/systemd/system/thola.service
scripts:
preinstall: "scripts/pre-install.sh"
postinstall: "scripts/post-install.sh"
postremove: "scripts/post-uninstall.sh"

archives:
- builds:
- thola
- thola-client

replacements:
amd64: 64-bit
darwin: macOS
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func initConfig() {
} else {
viper.AddConfigPath(os.ExpandEnv("$HOME/.thola"))
viper.AddConfigPath("./config")
viper.AddConfigPath("/var/opt/thola")
viper.AddConfigPath("/var/lib/thola")
viper.SetConfigName("config")
viper.SetConfigType("yaml")
}
Expand Down
10 changes: 10 additions & 0 deletions scripts/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

DATA_DIR=/var/lib/thola

if [ ! -f $DATA_DIR/config.yaml ]; then
echo "loglevel: info" > $DATA_DIR/config.yaml
fi

systemctl enable thola
systemctl restart thola
7 changes: 7 additions & 0 deletions scripts/post-uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [[ "$1" != "upgrade" ]]; then
systemctl stop thola
systemctl disable thola
rm -f /lib/systemd/system/thola.service
fi
13 changes: 13 additions & 0 deletions scripts/pre-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

DATA_DIR=/var/lib/thola
USER=thola

if ! id thola &>/dev/null; then
useradd --system -U -M thola -s /bin/false -d $DATA_DIR
fi

if [ ! -d $DATA_DIR ]; then
mkdir -p $DATA_DIR
chown $USER:$USER $DATA_DIR
fi
12 changes: 12 additions & 0 deletions scripts/thola.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Thola
After=network-online.target

[Service]
User=thola
Group=thola
ExecStart=/usr/local/bin/thola api
Restart=on-failure

[Install]
WantedBy=multi-user.target

0 comments on commit 1140071

Please sign in to comment.