Fixed broken fields when packaging rpm and deb files. (#2153)

* Fixed broken fields when packaging rpm and deb files.

* Update systemd unit files, package them into RPM's.

* Fix config file path for packages.

* Changed unit and binary paths to conform to standard locations for each vendor.

* Added featurebase owned directories.

* Create featrebase user/group and chown the right dirs

* Automate turning on featurebase

* Updated the .gitignore to include .vscode files.

* Changed RPM name to better conform to naming standards.

* Pass GOARCH when building RPM's.

* Avoid using recursive to remove files in this dir.
This commit is contained in:
Julio Martinez 2022-07-27 10:54:46 -07:00 committed by GitHub
parent d627ee46cb
commit 94a5721d05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 71 additions and 19 deletions

1
.gitignore vendored
View file

@ -22,3 +22,4 @@ report.xml
outputs.json
builds/
*.tfstate.backup
.vscode

View file

@ -36,7 +36,8 @@ default: test build
# Remove build directories
clean:
rm -rf vendor build
rm -f *.rpm *.deb
# Set up vendor directory using `go mod vendor`
vendor: go.mod
$(GO) mod vendor
@ -134,10 +135,9 @@ release-sans-ui: check-clean
package:
go build -o featurebase ./cmd/featurebase
nfpm package --packager deb --target featurebase_$(VERSION_ID).deb
nfpm package --packager rpm --target featurebase_$(VERSION_ID).rpm
GOARCH=$(GOARCH) VERSION=$(VERSION) nfpm package --packager deb --target featurebase.$(VERSION).$(GOARCH).deb
GOARCH=$(GOARCH) VERSION=$(VERSION) nfpm package --packager rpm --target featurebase.$(VERSION).$(GOARCH).rpm
# We allow setting a custom docker-compose "project". Multiple of the
# same docker-compose environment can exist simultaneously as long as
# they use different projects (the project name is prepended to

View file

@ -38,11 +38,8 @@
#
# bind-grpc = "0.0.0.0:20101"
# Directory to store Featurebase data files
data-dir = "/var/lib/molecula"
data-dir = "/var/lib/featurebase"
# ==============================================================================
# CORS (Cross-Origin Resource Sharing) Allowed Origins

View file

@ -7,7 +7,7 @@ RestartSec=30
Restart=on-failure
EnvironmentFile=
User=molecula
ExecStart=/usr/local/bin/featurebase server -c /etc/featurebase.conf
ExecStart=/usr/bin/featurebase server -c /etc/featurebase/featurebase.conf
[Install]
WantedBy=multi-user.target

View file

@ -1,12 +1,18 @@
[Unit]
Description="Service for FeatureBase"
After=network.target
Description=Service for FeatureBase
Documentation=https://docs.molecula.cloud/
DefaultDependencies=no
ConditionPathExists=/etc/featurebase/featurebase.conf
[Service]
RestartSec=30
Restart=on-failure
User=featurebase
Group=featurebase
WorkingDirectory=/var/lib/featurebase
EnvironmentFile=
User=molecula
ExecStart=/usr/local/bin/featurebase server -c /etc/featurebase.conf
ExecStart=/usr/bin/featurebase server -c /etc/featurebase/featurebase.conf
Restart=on-failure
RestartSec=30
[Install]
WantedBy=multi-user.target

2
install/postinstall.sh Normal file
View file

@ -0,0 +1,2 @@
systemctl enable featurebase
systemctl start featurebase

12
install/preinstall.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/sh
USERNAME=featurebase
GROUPNAME=featurebase
HOMEDIR=/var/lib/molecula
getent group $GROUPNAME >/dev/null || groupadd -r $GROUPNAME
getent passwd $USERNAME >/dev/null || \
useradd -r -g $GROUPNAME -d $HOMEDIR -s /sbin/nologin \
-c "Featurebase Service Account" $USERNAME
exit 0

2
install/preremove.sh Executable file
View file

@ -0,0 +1,2 @@
systemctl stop featurebase
systemctl disable featurebase

View file

@ -1,6 +1,5 @@
name: "featurebase"
arch: "${GOARCH}"
platform: "${GOOS}"
version: "${VERSION}"
section: "default"
priority: "extra"
@ -10,6 +9,39 @@ vendor: "Molecula"
homepage: "https://molecula.com"
contents:
- src: ./featurebase
dst: /usr/local/bin/featurebase
- dst: /etc/featurebase.conf
type: ghost
dst: /usr/bin/featurebase
- src: ./install/featurebase.conf
dst: /etc/featurebase/featurebase.conf
type: config|noreplace
file_info:
owner: featurebase
group: featurebase
- src: ./install/featurebase.redhat.service
dst: /usr/lib/systemd/system/featurebase.service
packager: rpm
- src: ./install/featurebase.debian.service
dst: /lib/systemd/system/featurebase.service
packager: deb
- dst: /var/log/molecula # We use vendor name on log directory in case other molecula components need it.
type: dir
file_info:
mode: 0755
owner: featurebase
group: featurebase
- dst: /var/lib/featurebase
type: dir
file_info:
mode: 0755
owner: featurebase
group: featurebase
- dst: /etc/featurebase # Keeping the config writable by the featurebase user is necessary for the agent.
type: dir
file_info:
mode: 0755
owner: featurebase
group: featurebase
scripts:
preinstall: ./install/preinstall.sh
postinstall: ./install/postinstall.sh
preremove: ./install/preremove.sh