diff --git a/debian/additions/garb-systemd.8 b/debian/additions/garb-systemd.8 new file mode 100644 index 0000000000000000000000000000000000000000..add754c99646d7b5aa12ea99169bd81d06a32d79 --- /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.garb.service b/debian/galera-arbitrator-4.garb.service new file mode 120000 index 0000000000000000000000000000000000000000..05cd3337679e30129b4fa44274f36389ca8ec24a --- /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 436ef14ebfb2480334852b4076f20b797dd102c9..39f0ffcc4eec78464fe0d2d954842297d097e5d4 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/galera-arbitrator-4.links b/debian/galera-arbitrator-4.links new file mode 100644 index 0000000000000000000000000000000000000000..1dd2f266469ea4a91d291fa8c7daf4551a8c9141 --- /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/galera-arbitrator-4.manpages b/debian/galera-arbitrator-4.manpages index c881ff7d034c0afadb4723d1bf609f101fe666c2..db629fd7c0899181fa256dabe23abccb40440a0e 100644 --- a/debian/galera-arbitrator-4.manpages +++ b/debian/galera-arbitrator-4.manpages @@ -1 +1,2 @@ +debian/additions/garb-systemd.8 man/garbd.8 diff --git a/debian/patches/fix-systemd-config-path.patch b/debian/patches/fix-systemd-config-path.patch new file mode 100644 index 0000000000000000000000000000000000000000..ec41770b398b763567adbbc60bf4146f369c5e12 --- /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 0000000000000000000000000000000000000000..72fabc361fd42d185b9473b9e990b97686ee904b --- /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 d7987b41e932273c3c57cf459571fa40ff6de1a0..17fbab025d978c0c82531d9266b050a6c17855a3 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,5 +1,9 @@ +fix-systemd-unit-file +fix-systemd-config-path.patch 910471.patch 525.patch 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 0000000000000000000000000000000000000000..3277b27df3ca76a7177a85bddf98e3611a9f134e --- /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 0000000000000000000000000000000000000000..d0d4588739d29c5afd7025e1ba4ab1a30c2609eb --- /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 diff --git a/debian/rules b/debian/rules index b0e892cfdc0f8afa09e46f36f3d24d726a5441f8..bccfec87f64b17d38c4c533365bbb683bd2be53d 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 $@