Skip to content

Commit

Permalink
Fix deb packaging (#82)
Browse files Browse the repository at this point in the history
* Add systemd and default config files
* Update deb package instructions

---------

Co-authored-by: yrizhkov <[email protected]>
  • Loading branch information
davi17g and reugn authored Dec 20, 2023
1 parent fdbc9f8 commit dc4b56f
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

.idea
.vscode
.DS_Store

lib/
target/
Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,30 @@ install-jansson:

.PHONY: install-go
install-go:
ifdef GOBIN_VERSION
else
curl -L "https://go.dev/dl/go$(GO_VERSION).$(OS)-$(ARCH).tar.gz" > "go$(GO_VERSION).$(OS)-$(ARCH).tar.gz"; \
sudo tar -C /usr/local -xzf "go$(GO_VERSION).$(OS)-$(ARCH).tar.gz" && rm "go$(GO_VERSION).$(OS)-$(ARCH).tar.gz"; \
echo export PATH="\$PATH:/usr/local/go/bin" >> $(HOME)/.profile
endif
# echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc

.PHONY: install-deb-build-deps
install-deb-build-deps:
sudo apt-get update
sudo sh -c 'curl -OL https://go.dev/dl/go1.21.4.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.21.4.linux-amd64.tar.gz && rm go1.21.4.linux-amd64.tar.gz && echo "export PATH=\$PATH:/usr/local/go/bin" >> /etc/profile.d/go.sh'
sudo apt-get install -y \
build-essential \
libssl-dev \
libuv1-dev \
libcurl4-openssl-dev \
libzstd-dev \
make \
cmake \
sudo \
pkg-config \
zlib1g-dev \
debhelper \
lintian \
patchelf \
devscripts
devscripts \
alien \
libjansson-dev

.PHONY: prep-submodules
prep-submodules:
Expand Down Expand Up @@ -160,6 +160,7 @@ clean-rpm:

.PHONY: deb
deb:
echo "abs:version=$(VERSION)" > packages/debian/substvars
cd $(WORKSPACE)/packages && dpkg-buildpackage
mv $(WORKSPACE)/$(BINARY_NAME)_* $(WORKSPACE)/target
mv $(WORKSPACE)/$(BINARY_NAME)-* $(WORKSPACE)/target
Expand Down
64 changes: 64 additions & 0 deletions packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# DEB package

## Install

### Installation
```shell
cd target && sudo dpkg -i aerospike-backup-service_0.1.0-1_amd64.deb
```

### Verify Installation
```shell
sudo systemctl status aerospike-backup-service
```

Should get the following output
```
● aerospike-backup-service.service - Aerospike Backup Service
Loaded: loaded (/lib/systemd/system/aerospike-backup-service.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-12-20 11:08:58 UTC; 14min ago
Main PID: 229439 (aerospike-backu)
Tasks: 26 (limit: 19160)
Memory: 32.3M
CPU: 6.562s
CGroup: /system.slice/aerospike-backup-service.service
└─229439 /usr/bin/aerospike-backup-service --config /etc/aerospike-backup-service/aerospike-backup-service.yml
```

### Modify service configuration
```shell
sudo vi /etc/aerospike-backup-service/aerospike-backup-service.yml
```

Restart service
```shell
sudo systemctl restart aerospike-backup-service
```

### Check service logs
```shell
sudo journalctl -u aerospike-backup-service -n 100 --no-page -f
```

## Uninstall

Stop the service
```shell
sudo systemctl stop aerospike-backup-service
```

### Remove service
* keeping the configuration
```shell
sudo dpkg -r aerospike-backup-service
```

* completely
```shell
sudo dpkg -P aerospike-backup-service
```

To remove the backup files run
```shell
sudo rm -rf /var/lib/aerospike-backup-service
```
27 changes: 27 additions & 0 deletions packages/config/aerospike-backup-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
aerospike-clusters:
cluster1:
host: "127.0.0.1"
port: 3000
user: "admin"
password: "admin"

storage:
local1:
type: 0
path: "/var/lib/aerospike-backup-service"

backup-policies:
policy1:
type: 1
parallel: 1
remove-files: false

backup-routines:
routine1:
interval: 30000
incr-interval: 5000
backup-policy: "policy1"
source-cluster: "cluster1"
storage: "local1"
namespace: "test"
11 changes: 0 additions & 11 deletions packages/debian/aerospike-backup-service.1

This file was deleted.

11 changes: 11 additions & 0 deletions packages/debian/aerospike-backup-service.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Aerospike Backup Service
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/aerospike-backup-service --config /etc/aerospike-backup-service/aerospike-backup-service.yml
Restart=on-failure

[Install]
WantedBy=multi-user.target
3 changes: 2 additions & 1 deletion packages/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
aerospike-backup-service (1.0.0-1) unstable; urgency=low
aerospike-backup-service (0.1.0-1) unstable; urgency=low
* Initial Release
-- David Gerchikov <[email protected]> Tue, 19 Dec 2023 11:55:00 +0200
4 changes: 2 additions & 2 deletions packages/debian/control
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Source: aerospike-backup-service
Section: misc
Priority: optional
Version: 1.0.0-1
Version: ${abs:version}
Maintainer: Aerospike <[email protected]>
Build-Depends: debhelper, debhelper-compat (= 13)

Package: aerospike-backup-service
Architecture: amd64
Architecture: amd64 arm64
Depends: libc6
Description: Aerospike Backup Service
This package provides backup and restore capabilities
Expand Down
1 change: 1 addition & 0 deletions packages/debian/dirs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/usr/bin
/usr/lib
/var/lib/aerospike-backup-service
3 changes: 2 additions & 1 deletion packages/debian/install
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
../target/aerospike-backup-service /usr/bin/
../target/aerospike-backup-service /usr/bin
../lib/* /usr/lib
config/aerospike-backup-service.yml /etc/aerospike-backup-service
11 changes: 8 additions & 3 deletions packages/debian/rules
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
#!/usr/bin/make -f
export DH_VERBOSE=1
SOURCE_DIR := $(shell git rev-parse --show-toplevel)
BINARY_NAME := aerospike-backup-service
BINARY_NAME := $(shell basename $(SOURCE_DIR))
ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
VERSION := $(shell cat $(SOURCE_DIR)/VERSION)
%:
dh $@
override_dh_auto_configure:
cd $(SOURCE_DIR)/modules/aerospike-tools-backup && git submodule update --init --recursive
(cd $(SOURCE_DIR); $(MAKE) prep-submodules)
dh_auto_configure
override_dh_installchangelogs:
dh_installchangelogs
override_dh_installman:
dh_installman
dh_installman man/$(BINARY_NAME).1
override_dh_installdocs:
dh_installdocs
override_dh_auto_build:
(cd $(SOURCE_DIR); $(MAKE) build-submodules; $(MAKE) build)
dh_auto_build
override_dh_dwz:

override_dh_installsystemd:
dh_installsystemd $(BINARY_NAME).service

override_dh_clean:
set -x
dh_clean

0 comments on commit dc4b56f

Please sign in to comment.