From 80a6b39f7fb1203a6ec1626885b8d37a11163821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Fri, 27 Dec 2019 10:52:19 +0200 Subject: [PATCH 1/4] Include systemd service definition in Debian packaging --- debian/galera-arbitrator-4.garb.service | 1 + debian/galera-arbitrator-4.install | 1 + debian/rules | 3 +++ 3 files changed, 5 insertions(+) create mode 120000 debian/galera-arbitrator-4.garb.service diff --git a/debian/galera-arbitrator-4.garb.service b/debian/galera-arbitrator-4.garb.service new file mode 120000 index 0000000..05cd333 --- /dev/null +++ b/debian/galera-arbitrator-4.garb.service @@ -0,0 +1 @@ +../garb/files/garb.service \ No newline at end of file diff --git a/debian/galera-arbitrator-4.install b/debian/galera-arbitrator-4.install index 436ef14..39f0ffc 100644 --- a/debian/galera-arbitrator-4.install +++ b/debian/galera-arbitrator-4.install @@ -1 +1,2 @@ garb/garbd usr/bin +garb/files/garb-systemd usr/bin diff --git a/debian/rules b/debian/rules index b0e892c..bccfec8 100755 --- a/debian/rules +++ b/debian/rules @@ -64,5 +64,8 @@ override_dh_auto_build: override_dh_installinit-arch: dh_installinit -n --name=garb -- defaults 18 22 +override_dh_installsystemd: + dh_installsystemd --name=garb + %: dh $@ -- GitLab From e7878f7167b4edd691b0a2aad463fc54a216cb74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sat, 4 Jan 2020 23:22:38 +0200 Subject: [PATCH 2/4] Add man page for garb-systemd --- debian/additions/garb-systemd.8 | 16 ++++++++++++++++ debian/galera-arbitrator-4.manpages | 1 + 2 files changed, 17 insertions(+) create mode 100644 debian/additions/garb-systemd.8 diff --git a/debian/additions/garb-systemd.8 b/debian/additions/garb-systemd.8 new file mode 100644 index 0000000..add754c --- /dev/null +++ b/debian/additions/garb-systemd.8 @@ -0,0 +1,16 @@ +.TH GARB-SYSTEMD "8" "January 2020" "garb-systemd" "System Administration Utilities" +.SH NAME +garb-systemd \- systemd start helper for arbitrator daemon +.SH SYNOPSIS +.B garb-systemd +{\fI\,start\/\fR} +.SH "DESCRIPTION" +This is a simple wrapper for garbd written in shell script, which facilitates starting garbd via systemd. While starting garbd, settings are applied from /etc/sysconfig/garb or from environment variables GALERA_NODES, GALERA_GROUP, GALERA_PORT, GALERA_OPTIONS and LOG_FILE. + +For more information, view the source code and read more at https://galeracluster.com/library/documentation/arbitrator.html + +.SH BUGS +See Galera bug tracker at https://github.com/codership/galera + +.SH AUTHOR +Codership Oy diff --git a/debian/galera-arbitrator-4.manpages b/debian/galera-arbitrator-4.manpages index c881ff7..db629fd 100644 --- a/debian/galera-arbitrator-4.manpages +++ b/debian/galera-arbitrator-4.manpages @@ -1 +1,2 @@ +debian/additions/garb-systemd.8 man/garbd.8 -- GitLab From 96e9ef4e5d167ce472feb0ecb1c8596ed157cea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sat, 4 Jan 2020 23:55:24 +0200 Subject: [PATCH 3/4] Add minor systemd service definition fixes --- debian/patches/series | 2 ++ debian/patches/systemd-documentation.patch | 33 +++++++++++++++++++ debian/patches/systemd-obsolete-target.patch | 34 ++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 debian/patches/systemd-documentation.patch create mode 100644 debian/patches/systemd-obsolete-target.patch diff --git a/debian/patches/series b/debian/patches/series index d7987b4..1430728 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -3,3 +3,5 @@ 526.patch 527.patch disable-sporadic-failing-tests.patch +systemd-obsolete-target.patch +systemd-documentation.patch diff --git a/debian/patches/systemd-documentation.patch b/debian/patches/systemd-documentation.patch new file mode 100644 index 0000000..3277b27 --- /dev/null +++ b/debian/patches/systemd-documentation.patch @@ -0,0 +1,33 @@ +From 968b03ea08c9c50a3946c0c3926e450ecedcdcfa Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= +Date: Sat, 4 Jan 2020 23:48:24 +0200 +Subject: [PATCH] Add Documentation keys to systemd service definition + +Documentation for systemd service files can be automatically viewed using +'systemctl help servicename' if this field is present. + +See also: +https://lintian.debian.org/tags/systemd-service-file-missing-documentation-key.html +--- + garb/files/garb.service | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/garb/files/garb.service b/garb/files/garb.service +index 198755c0c..45cb7db05 100644 +--- a/garb/files/garb.service ++++ b/garb/files/garb.service +@@ -2,6 +2,8 @@ + + [Unit] + Description=Galera Arbitrator Daemon ++Documentation=man:garbd(8) ++Documentation=https://galeracluster.com/library/documentation/arbitrator.html + After=network.target + + [Install] +@@ -19,5 +21,3 @@ KillSignal=SIGINT + + TimeoutSec=2m + PrivateTmp=false +- +- diff --git a/debian/patches/systemd-obsolete-target.patch b/debian/patches/systemd-obsolete-target.patch new file mode 100644 index 0000000..d0d4588 --- /dev/null +++ b/debian/patches/systemd-obsolete-target.patch @@ -0,0 +1,34 @@ +From 416222e6e76484323002d316d261a6c3b0056044 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= +Date: Sat, 4 Jan 2020 23:47:00 +0200 +Subject: [PATCH] Remove obsolete target 'syslog' from systemd service + definition + +Declaring After=syslog.target is unnecessary by now because syslog is +socket-activated and will therefore be started when needed. + +Having network.target is enough, and that is e.g. how the MariaDB systemd +service defines it. + +This change is safe on the Galera 4.x branch since it most likely will not +target very old Linux distros anymore. + +See also: +https://lintian.debian.org/tags/systemd-service-file-refers-to-obsolete-target.html +--- + garb/files/garb.service | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/garb/files/garb.service b/garb/files/garb.service +index 9bd9ddaa7..198755c0c 100644 +--- a/garb/files/garb.service ++++ b/garb/files/garb.service +@@ -2,7 +2,7 @@ + + [Unit] + Description=Galera Arbitrator Daemon +-After=network.target syslog.target ++After=network.target + + [Install] + WantedBy=multi-user.target -- GitLab From 894afbb5d7945558900e465151c6da4dc7aa99d5 Mon Sep 17 00:00:00 2001 From: Faustin Lammler Date: Fri, 24 Jan 2020 10:57:27 +0100 Subject: [PATCH 4/4] Fix systemd unit and start script. The start script does not work on Debian because the path for config file is not correct. The environment definition in the systemd unit file is redundant (and problematic on Debian) with config file definition in the bash start script (garb-systemd). Also, the bash script needed some linting IMO. Finally, Alias should not be used in systemd unit file and static symlink should be deployed at postinstall instead. See https://wiki.debian.org/Teams/pkg-systemd/Packaging#systemd_unit_files_naming_and_installation --- debian/galera-arbitrator-4.links | 1 + debian/patches/fix-systemd-config-path.patch | 106 +++++++++++++++++++ debian/patches/fix-systemd-unit-file | 14 +++ debian/patches/series | 2 + 4 files changed, 123 insertions(+) create mode 100644 debian/galera-arbitrator-4.links create mode 100644 debian/patches/fix-systemd-config-path.patch create mode 100644 debian/patches/fix-systemd-unit-file diff --git a/debian/galera-arbitrator-4.links b/debian/galera-arbitrator-4.links new file mode 100644 index 0000000..1dd2f26 --- /dev/null +++ b/debian/galera-arbitrator-4.links @@ -0,0 +1 @@ +lib/systemd/system/garb.service lib/systemd/system/garbd.service diff --git a/debian/patches/fix-systemd-config-path.patch b/debian/patches/fix-systemd-config-path.patch new file mode 100644 index 0000000..ec41770 --- /dev/null +++ b/debian/patches/fix-systemd-config-path.patch @@ -0,0 +1,106 @@ +--- a/garb/files/garb-systemd ++++ b/garb/files/garb-systemd +@@ -1,62 +1,61 @@ + #!/bin/bash -ue + # + +- +-config=/etc/sysconfig/garb ++if [[ -f /etc/redhat-release ]]; then ++ config=/etc/sysconfig/garb ++else ++ config=/etc/default/garb ++fi + + log_failure() { +- echo " ERROR! $@" ++ echo " ERROR! $@" + } + +- +- + program_start() { +- echo "Starting garbd" +- /usr/bin/garbd "$@" ++ echo "Starting garbd" ++ /usr/bin/garbd "$@" + } + +- + start() { + +- if grep -q -E '^# REMOVE' $config;then +- log_failure "Garbd config $config is not configured yet" +- return 0 +- fi +- +- [ -f $config ] && . $config +- +- # Check that node addresses are configured +- if [[ -z "${GALERA_NODES:-}" ]]; then +- log_failure "List of GALERA_NODES is not configured" +- return 6 +- fi +- if [[ -z "${GALERA_GROUP:-}" ]]; then +- log_failure "GALERA_GROUP name is not configured" +- return 6 +- fi +- +- GALERA_PORT=${GALERA_PORT:-4567} +- +- OPTIONS="-a gcomm://${GALERA_NODES// /,}" +- # substitute space with comma for backward compatibility +- +- [ -n "${GALERA_GROUP:-}" ] && OPTIONS="$OPTIONS -g '$GALERA_GROUP'" +- [ -n "${GALERA_OPTIONS:-}" ] && OPTIONS="$OPTIONS -o '$GALERA_OPTIONS'" +- [ -n "${LOG_FILE:-}" ] && OPTIONS="$OPTIONS -l '$LOG_FILE'" ++ if grep -q -E '^# REMOVE' $config; then ++ log_failure "Garbd config $config is not configured yet" ++ return 0 ++ fi ++ ++ [ -f $config ] && . $config ++ ++ # Check that node addresses are configured ++ if [[ -z "${GALERA_NODES:-}" ]]; then ++ log_failure "List of GALERA_NODES is not configured" ++ return 6 ++ fi ++ if [[ -z "${GALERA_GROUP:-}" ]]; then ++ log_failure "GALERA_GROUP name is not configured" ++ return 6 ++ fi ++ ++ GALERA_PORT=${GALERA_PORT:-4567} ++ ++ OPTIONS="-a gcomm://${GALERA_NODES// /,}" ++ # substitute space with comma for backward compatibility ++ ++ [ -n "${GALERA_GROUP:-}" ] && OPTIONS="$OPTIONS -g '$GALERA_GROUP'" ++ [ -n "${GALERA_OPTIONS:-}" ] && OPTIONS="$OPTIONS -o '$GALERA_OPTIONS'" ++ [ -n "${LOG_FILE:-}" ] && OPTIONS="$OPTIONS -l '$LOG_FILE'" + +- eval program_start $OPTIONS ++ eval program_start $OPTIONS + } + +- +- + # See how we were called. + case "$1" in +- start) +- start +- ;; +- *) +- echo $"Usage: $0 {start}" +- exit 2 ++start) ++ start ++ ;; ++*) ++ echo $"Usage: $0 {start}" ++ exit 2 ++ ;; + esac + + exit $? diff --git a/debian/patches/fix-systemd-unit-file b/debian/patches/fix-systemd-unit-file new file mode 100644 index 0000000..72fabc3 --- /dev/null +++ b/debian/patches/fix-systemd-unit-file @@ -0,0 +1,14 @@ +--- a/garb/files/garb.service ++++ b/garb/files/garb.service +@@ -6,11 +6,9 @@ + + [Install] + WantedBy=multi-user.target +-Alias=garbd.service + + [Service] + User=nobody +-EnvironmentFile=/etc/sysconfig/garb + ExecStart=/usr/bin/garb-systemd start + + # Use SIGINT because with the default SIGTERM diff --git a/debian/patches/series b/debian/patches/series index 1430728..17fbab0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,5 @@ +fix-systemd-unit-file +fix-systemd-config-path.patch 910471.patch 525.patch 526.patch -- GitLab