Files
spine/Makefile.am
TheWitness 575782d329 build: seed spine.conf from spine.conf.dist on first install (#629)
## Problem

`config_DATA = spine.conf.dist` only ever installs `spine.conf.dist`
itself under `$(sysconfdir)` (`/usr/local/spine/etc` by default).
Nothing produces a live `spine.conf`, so a fresh install has no usable
configuration until an operator manually copies the `.dist` file.

## Fix

Added an `install-data-hook` that copies `spine.conf.dist` to
`spine.conf` under `$(configdir)`, but only when `spine.conf` does not
already exist. A first install seeds a working config; a re-install
(upgrade in place) never touches an already-customized `spine.conf`.

## Testing

Verified via WSL:
- Fresh `make install DESTDIR=...` creates `etc/spine.conf` identical to
`spine.conf.dist`.
- Hand-edited `spine.conf` (appended a marker line) survives a second
`make install` unchanged.
2026-09-22 10:10:04 -04:00

51 lines
2.6 KiB
Makefile

# +-------------------------------------------------------------------------+
# | Copyright (C) 2004-2024 The Cacti Group |
# | |
# | This program is free software; you can redistribute it and/or |
# | modify it under the terms of the GNU General Public License |
# | as published by the Free Software Foundation; either version 2 |
# | of the License, or (at your option) any later version. |
# | |
# | This program is distributed in the hope that it will be useful, |
# | but WITHOUT ANY WARRANTY; without even the implied warranty of |
# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# | GNU General Public License for more details. |
# +-------------------------------------------------------------------------+
# | Cacti: The Complete RRDtool-based Graphing Solution |
# +-------------------------------------------------------------------------+
# | This code is designed, written, and maintained by the Cacti Group. See |
# | about.php and/or the AUTHORS file for specific developer information. |
# +-------------------------------------------------------------------------+
# | http://www.cacti.net/ |
# +-------------------------------------------------------------------------+
AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4
spine_SOURCES = sql.c spine.c util.c snmp.c locks.c poller.c nft_popen.c php.c ping.c keywords.c error.c
configdir = $(sysconfdir)
config_DATA = spine.conf.dist
# Seed a live config on first install without ever overwriting an existing one.
install-data-hook:
if [ ! -f "$(DESTDIR)$(configdir)/spine.conf" ]; then \
$(INSTALL_DATA) "$(srcdir)/spine.conf.dist" "$(DESTDIR)$(configdir)/spine.conf"; \
fi
# Mirror image of the hook above: only remove spine.conf if it was never
# customized (still identical to the .dist it was seeded from), so a real
# uninstall never discards a live config, while distcheck's install/uninstall
# symmetry check still passes against its untouched sandbox copy.
uninstall-hook:
if cmp -s "$(DESTDIR)$(configdir)/spine.conf" "$(srcdir)/spine.conf.dist" 2>/dev/null; then \
rm -f "$(DESTDIR)$(configdir)/spine.conf"; \
fi
bin_PROGRAMS = spine
man_MANS = spine.1
spine.1: $(bin_PROGRAMS)
$(HELP2MAN) --output=$@ --name='Data Collector for Cacti' --no-info --version-option='--version' ./spine