Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package discovery-engine as a systemd service #524

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 54 additions & 10 deletions src/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,71 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
project_name: knoxAutoPolicy

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

builds:
- env:
- CGO_ENABLED=1
- binary: "opt/knoxAutoPolicy/src/knoxAutoPolicy"
id: knoxAutoPolicy
goos:
- linux
#- windows
#- darwin
goarch:
- amd64
nyrahul marked this conversation as resolved.
Show resolved Hide resolved

archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
- id: "knoxAutoPolicy"
builds:
- "knoxAutoPolicy"
name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}-{{.Arch}}"
files:
- src: ./conf/local-file.yaml
dst: /opt/knoxAutoPolicy
strip_parent: true
- src: ./packaging/knoxAutoPolicy.service
dst: /usr/lib/systemd/system
strip_parent: true

nfpms:
- id: "knoxAutoPolicy"
builds:
- "knoxAutoPolicy"
formats:
- deb
- rpm
replaces:
- knoxAutoPolicy
maintainer: "Ankur Kothiwal <ankur.kothiwal@accuknox.com>"
description: |
Auto policy discovery engine
file_name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}-{{.Arch}}"
bindir: /
contents:
- dst: /opt/knoxAutoPolicy
type: dir
- src: ./conf/local-file.yaml
dst: /opt/knoxAutoPolicy/conf/local-file.yaml
type: config
- src: ./packaging/knoxAutoPolicy.service
dst: /usr/lib/systemd/system/knoxAutoPolicy.service
type: config
- src: /opt/knoxAutoPolicy/src/knoxAutoPolicy
dst: /usr/local/bin/knoxAutoPolicy
type: symlink
scripts:
postinstall: packaging/post-install.sh
overrides:
deb:
dependencies:
- make
rpm:
dependencies:
- make

checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
10 changes: 10 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ clean:
.PHONY: image
image:
cd $(CURDIR)/build; $(MAKE)

.PHONY: local-release
local-release: build
ifeq (, $(shell which goreleaser))
@{ \
set -e ;\
go install github.com/goreleaser/goreleaser@latest ;\
}
endif
cd $(CURDIR); VERSION=$(shell git describe --tags --always --dirty) goreleaser release --rm-dist --skip-publish --skip-sign --skip-validate --snapshot
11 changes: 11 additions & 0 deletions src/packaging/knoxAutoPolicy.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=knoxAutoPolicy

[Service]
KillMode=process
EnvironmentFile=/opt/knoxAutoPolicy/local-file.yaml
WorkingDirectory=/opt/knoxAutoPolicy/
ExecStart=/opt/knoxAutoPolicy/src/knoxAutoPolicy

[Install]
WantedBy=multi-user.target
4 changes: 4 additions & 0 deletions src/packaging/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set -e

/bin/systemctl daemon-reload
/bin/systemctl start knoxAutoPolicy.service
nyrahul marked this conversation as resolved.
Show resolved Hide resolved