From 369b6de63a042bd7b0a95a5510f0260a314c2361 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 4 Aug 2016 18:43:17 -0400 Subject: [PATCH] 9706: Add postinst script to Go packages that have systemd unit files, so (on Debian) the service starts up without manual intervention. --- build/go-package-scripts/postinst | 15 +++++++++++++++ build/run-library.sh | 9 +++++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100755 build/go-package-scripts/postinst diff --git a/build/go-package-scripts/postinst b/build/go-package-scripts/postinst new file mode 100755 index 0000000000..137f8988d3 --- /dev/null +++ b/build/go-package-scripts/postinst @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +script="${0##*/}" +pkg="${script%.postinst}" + +case "${1}" in + configure) + if which systemctl >/dev/null && [[ -e "/lib/systemd/system/${pkg}.service" ]]; then + systemctl enable "${pkg}" + systemctl start "${pkg}" + fi + ;; +esac diff --git a/build/run-library.sh b/build/run-library.sh index aee579c7c1..9140ac1611 100755 --- a/build/run-library.sh +++ b/build/run-library.sh @@ -101,14 +101,15 @@ package_go_binary() { cd $WORKSPACE/packages/$TARGET go get "git.curoverse.com/arvados.git/$src_path" - declare -a addfiles=() + declare -a switches=() systemd_unit="$WORKSPACE/${src_path}/${prog}.service" if [[ -e "${systemd_unit}" ]]; then - addfiles+=("${systemd_unit}=/lib/systemd/system/${prog}.service") + switches+=("${systemd_unit}=/lib/systemd/system/${prog}.service") + switches+=(--after-install "$WORKSPACE/build/go-package-scripts/postinst") fi - addfiles+=("$WORKSPACE/$license_file=/usr/share/doc/$prog/$license_file") + switches+=("$WORKSPACE/$license_file=/usr/share/doc/$prog/$license_file") - fpm_build "$GOPATH/bin/$basename=/usr/bin/$prog" "$prog" 'Curoverse, Inc.' dir "$version" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=$description" "${addfiles[@]}" + fpm_build "$GOPATH/bin/$basename=/usr/bin/$prog" "$prog" 'Curoverse, Inc.' dir "$version" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=$description" "${switches[@]}" } default_iteration() { -- 2.30.2