# HG changeset patch # User Heiko Schlittermann # Date 1594042886 -7200 # Node ID 2272c9e2eaf71a6d747f4e651c3e635b05705834 # Parent 9f66fe44239cc72e560aab569494ae4153052d33# Parent b2ddc3c831c60153abcad10a0eabe0da7df2f142 merged diff -r b2ddc3c831c6 -r 2272c9e2eaf7 Makefile --- a/Makefile Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -SCRIPTS = ha-config ha-hostname ha-sync ha-diff - -all: - chmod a+rx $(SCRIPTS) - -install: - install -d $(DESTDIR)/boot/ha-config - install -d $(DESTDIR)/etc/ha-sync - install -d $(DESTDIR)/etc/ha-sync/scripts - - install -m755 ha-sync $(DESTDIR)/usr/sbin/ - install -m755 ha-diff $(DESTDIR)/usr/sbin/ - - install -d $(DESTDIR)/usr/share/doc/ha-sync/examples - install -m644 *.ex $(DESTDIR)/usr/share/doc/ha-sync/examples - - install -m755 ha-config $(DESTDIR)/etc/init.d/ha-config - install -m755 ha-hostname $(DESTDIR)/etc/init.d/ha-hostname - -clean: - chmod a-x $(SCRIPTS) diff -r b2ddc3c831c6 -r 2272c9e2eaf7 README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Mon Jul 06 15:41:26 2020 +0200 @@ -0,0 +1,1 @@ +moved to https://git.schlittermann.de/ius/ha-sync diff -r b2ddc3c831c6 -r 2272c9e2eaf7 TODO --- a/TODO Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -* $NODE *is* required, but the script does not check it -* why is 'dry-run' not the default? - i think changes should always be kept small and reviewed before actually - synchronised. diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/changelog --- a/debian/changelog Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -ha-sync (0.18+nmu1) stable; urgency=low - - * Non-maintainer upload. - * use bash in maintainer scripts and debian/ha-sync.config because they - contain bashisms - * fix lsb headers for ha-hostname - * fix nodename detection in ha-sync.config - * silence ucf (and make it actually work?) - * disable init scripts *before* they are purged in postrm - * several (not all) lintian fixes - - -- Matthias Förste Wed, 30 Nov 2011 13:31:03 +0100 - -ha-sync (0.18) stable; urgency=low - - * updated drbdlinks dependency to >= 1.14 - - -- Heiko Schlittermann Tue, 29 Nov 2011 11:52:34 +0100 - -ha-sync (0.17) stable oldstable; urgency=low - - * added ha-diff to .deb - - -- Heiko Schlittermann Sun, 06 Sep 2009 17:21:41 +0200 - -ha-sync (0.16) stable oldstable; urgency=low - - * added dependency on rsync 2.6.9 - - -- Heiko Schlittermann Fri, 14 Aug 2009 09:11:31 +0200 - -ha-sync (0.15) stable; urgency=low - - * improved „-n” to show --itemized-changes - * added ha-diff (experimental) - - -- Heiko Schlittermann Thu, 13 Aug 2009 23:38:33 +0200 - -ha-sync (0.14-1) stable; urgency=low - - * Path updated (tail not found) - - -- Heiko Schlittermann Tue, 21 Aug 2007 12:21:51 +0200 - -ha-sync (0.13-1) stable; urgency=low - - * new upstream (run-parts) - - -- Heiko Schlittermann Thu, 24 May 2007 15:16:40 +0200 - -ha-sync (0.11-1) stable; urgency=low - - * new upstream - - -- Heiko Schlittermann Thu, 24 May 2007 14:44:29 +0200 - -ha-sync (0.9-3) stable; urgency=low - - * still in stable - * added some chrony files to the exclude list - - -- Heiko Schlittermann Wed, 23 May 2007 14:25:48 +0200 - -ha-sync (0.9-2) stable; urgency=low - - * now in stable - - -- Heiko Schlittermann Fri, 13 Apr 2007 15:00:04 +0200 - -ha-sync (0.9-1) testing; urgency=low - - * new upstream - - - -- Heiko Schlittermann Fri, 13 Apr 2007 15:00:04 +0200 - -ha-sync (0.8-1) testing; urgency=low - - * new upstream - - -- Heiko Schlittermann Mon, 12 Dec 2006 12:46:31 +0100 - -ha-sync (0.7-1) testing; urgency=low - - * new upstream - - -- Heiko Schlittermann Wed, 29 Nov 2006 23:46:31 +0100 - -ha-sync (0.5-1) testing; urgency=low - - * new upstream - - -- Heiko Schlittermann Sat, 28 Nov 2006 11:40:22 +0100 - -ha-sync (0.4-1) testing; urgency=low - - * new upstream - - -- Heiko Schlittermann Sat, 18 Nov 2006 03:40:22 +0100 - -ha-sync (0.3-1) testing; urgency=low - - * use drbdlinks! - - -- Heiko Schlittermann Sat, 18 Nov 2006 03:10:07 +0100 - -ha-sync (0.2-2) testing; urgency=low - - * depency on drbdlinks (1.07-1.ius) - - -- Heiko Schlittermann Sat, 18 Nov 2006 02:01:37 +0100 - -ha-sync (0.2-1) testing; urgency=low - - * exclude list improved - - -- Heiko Schlittermann Thu, 17 Nov 2006 22:05:28 +0000 - -ha-sync (0.1-1) testing; urgency=low - - * Initial release - - -- Heiko Schlittermann Thu, 16 Nov 2006 23:05:28 +0000 - diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/compat --- a/debian/compat Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -5 diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/control --- a/debian/control Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -Source: ha-sync -Section: admin -Priority: extra -Maintainer: Heiko Schlittermann -Build-Depends: debhelper (>= 5) -Standards-Version: 3.7.2 - -Package: ha-sync -Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, ucf (>= 0.28), ssh, stow, rsync (>= 2.6.9), stow -Recommends: drbdlinks (>= 1.14) -Description: sync script for ha cluster - script helping to keep clusters in sync diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/copyright --- a/debian/copyright Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -This work was packaged for Debian by: - -This package was debianized by Heiko Schlittermann on Thu, 16 Nov 2006 23:04:43 +0000 - -It was downloaded from http://hg.schlittermann.de/ha-sync/ - -Upstream Author(s): - - Heiko Schlittermann , - Matthias Förste - -Copyright: - - Copyright (C) 2006-2011 Schlittermann internet & unix support - -License: - - 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 3 of the License, or - (at your option) any later version. - - This package 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. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -On Debian systems, the complete text of the GNU General -Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". - -The Debian packaging is: - - Copyright (C) 2006-2011 Schlittermann internet & unix support - -and is licensed under the GPL version 3, see above. diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/dirs --- a/debian/dirs Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -usr/sbin -etc/ha-sync -etc/init.d diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/docs diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/ha-sync.config --- a/debian/ha-sync.config Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -#! /bin/bash - -set -e -. /usr/share/debconf/confmodule - -# test "$1" = "purge" && { db_purge ha-sync/nodes; exit; } - -# Hostname(s) - -db_input high ha-sync/dir || true - -HOSTNAME=${HOSTNAME%-[ab]} -NODES="$HOSTNAME-a $HOSTNAME-b" -db_set ha-sync/nodes "$NODES" -db_input high ha-sync/nodes || true - -# Filesystems -FILESYSTEMS=`egrep '[1-9][[:space:]]*$' /etc/fstab | while read dev fs rest; do echo -n "$fs, "; done` - -db_subst ha-sync/fs choices ${FILESYSTEMS%, } -db_input high ha-sync/fs || true - -# Exclude file -db_input low ha-sync/exclude || true - -db_go diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/ha-sync.templates --- a/debian/ha-sync.templates Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -Template: ha-sync/nodes -Type: string -Description: Names of your two nodes (space separated) - -Template: ha-sync/fs -Type: multiselect -Description: filesystems to sync -Choices: ${choices} - -Template: ha-sync/dir -Type: string -Description: directory for maintained files -Default: /boot/ha-config - -Template: ha-sync/exclude -Type: string -Description: location of the exclude list -Default: /etc/ha-sync/exclude diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/postinst --- a/debian/postinst Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -#!/bin/bash -# postinst script for ha-sync -# -# see: dh_installdeb(1) -set -e -. /usr/share/debconf/confmodule - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - configure) - - { - update-rc.d ha-hostname defaults >/dev/null - update-rc.d ha-config defaults >/dev/null - - test -f /etc/ha-sync/id_rsa || { - ssh-keygen -N "" -C "ha-sync@`hostname`" -f /etc/ha-sync/id_rsa >&2 - chmod u=r,go= /etc/ha-sync/id_rsa - } - - } >&2 - - - TMP=`tempfile`; trap "rm -f $TMP" EXIT - - ## Config file - { - echo "# see /usr/share/doc/ha-sync/examples/ha-sync.conf.ex for" - echo "# example" - echo "" - - db_get ha-sync/dir - echo DIR="'$RET'" - - db_get ha-sync/nodes - echo "$RET" | while read a b; do - echo NODE_A="'$a'" - echo NODE_B="'$b'" - done - - db_get ha-sync/fs - echo FILESYSTEMS="'${RET//,/}'" - - db_get ha-sync/exclude - echo EXCLUDE="'$RET'" - - } >> $TMP - ucf --debconf-ok $TMP /etc/ha-sync/ha-sync.conf - - ## Exclude list - ucf --debconf-ok /usr/share/doc/ha-sync/examples/exclude.ex /etc/ha-sync/exclude - - ## noch Verzeichnisse - source /etc/ha-sync/ha-sync.conf - install -d "$DIR"; - for node in $NODE_A $NODE_B; do - install -d $DIR/$node.etc - done - - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 - - -# vim:sts=4 sw=4 aw ai sm: diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/postrm --- a/debian/postrm Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -#!/bin/bash -# postrm script for ha-sync -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `remove' -# * `purge' -# * `upgrade' -# * `failed-upgrade' -# * `abort-install' -# * `abort-install' -# * `abort-upgrade' -# * `disappear' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - - purge) - { - rm -f /etc/ha-sync/id_rsa{,.pub} - for p in /etc/ha-sync/{ha-sync.conf,exclude}; do - ucf --purge $p; rm -f $p $p.ucf-* - ucf --purge $p; rm -f $p $p.ucf-* - done - } >&2 - ;; - - remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - { - update-rc.d ha-hostname remove >/dev/null - update-rc.d ha-config remove >/dev/null - } >&2 - ;; - - *) - echo "postrm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -# #DEBHELPER# - -exit 0 - - diff -r b2ddc3c831c6 -r 2272c9e2eaf7 debian/rules --- a/debian/rules Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - - - - -CFLAGS = -Wall -g - -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif - -configure: configure-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - - touch configure-stamp - - -build: build-stamp - -build-stamp: configure-stamp - dh_testdir - - # Add here commands to compile the package. - $(MAKE) - #docbook-to-man debian/ha-sync.sgml > ha-sync.1 - - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - -$(MAKE) clean - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/ha-sync. - $(MAKE) DESTDIR=$(CURDIR)/debian/ha-sync install - - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs - dh_installexamples -# dh_install -# dh_installmenu - dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_python -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_perl -# dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff -r b2ddc3c831c6 -r 2272c9e2eaf7 exclude.ex --- a/exclude.ex Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -# files and directories to be excluded -# you should remove the next entry to sync anything -# at all :-) -# --> REMOVE AT LEAST THIS LINE <-- -/** - -*.drbdlinks - -/boot/ha-config/current.boot -/boot/ha-config/current.etc -/boot/ha-config/links -/boot/map - -# exclude kernel stuff -/boot/grub/ -/boot/vmlinuz* -/boot/initrd* -/boot/System* -/boot/config* -/lib/modules/ - -/dev - -/etc/adjtime -/etc/blkid.tab -/etc/lvm/.cache -/etc/lvm/cache -/etc/lvm/archive -/etc/lvm/backup -/etc/mtab -/etc/network/run -/etc/network/run/* -/etc/udev/rules.d/*persistent-net.rules -/etc/udev/rules.d/*persistent-cd.rules -/etc/udev/rules.d/*local.rules -/etc/mdadm/mdadm.conf - -/proc - -/root/.ssh/known_hosts -/root/LOG.* -/root/LOG - -/shared - -/sys - -/tmp - -/var/lib/amavis -/var/lib/dhcpd3 -/var/lib/heartbeat/hb_* -/var/lib/heartbeat/rsctmp -/var/lock/ -/var/log/* -/var/run/heartbeat -/var/lib/chrony/** -/var/lib/initramfs-tools/ -/var/lib/nfs/*tab -/var/lib/nfs/state -/var/lib/havp/havp.loop - -/var/run/**socket -/var/run/**pid -/var/run/utmp - -/var/run/mysqld/*sock -/var/run/spamd/*sock -/var/run/slapd/*args - diff -r b2ddc3c831c6 -r 2272c9e2eaf7 ha-config --- a/ha-config Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -#! /bin/bash -e -### BEGIN INIT INFO -# Provides: ha-config -# Required-Start: $local_fs -# Required-Stop: $local_fs -# Default-Start: S -# Default-Stop: -# Short-Description: ha-config -### END INIT INFO - -# © 2006 Heiko Schlittermann -# -# Es wird davon ausgegangen, daß in /ha-config alles liegt, was -# auf beiden System *unterschiedlich* sein muß. Oder: beide -# Systeme sind an allen anderen Stellen *identisch*. -# $Id$ -# $URL$ - -ME=`basename $0` - -source /etc/ha-sync/ha-sync.conf - -test "$DIR" || { - echo "Need directory" >&2 - exit 2 -} - -# Erst mal sicherstellen, daß das Verzeichnis auch da ist - -if ! test -e /etc/fstab; then - echo "$ME: /etc/fstab doesn't exist!" >&2 - exit -fi - -D=; for d in ${DIR//\// }; do - test -d $DIR && break - - D=$D/$d - egrep -q "^[^#][[:print:]]+[[:space:]]+$D[[:space:]]" /etc/fstab \ - && mount $D - -done - -cd $DIR - -# Den aktuellen Hostnamen ermitteln wir von der Kernel-Kommando-Zeile -# (den letzten dort auftauchenden hostname=XXX Parameter) -# oder wenn das nicht hilft über das 'hostname'-Kommando - -eval `grep -o 'hostname=[-[:alnum:]]\+' /proc/cmdline | tail -1` -hostname=${hostname-`hostname`} - -# Nun laufen wir über alle Verzeichnisse, die unseren Hostnamen -# haben und gehen davon aus, daß der Rest des Verzeichnisnamens -# das Zielverzeichnis darstellt. -# Dann legen wir einen Link 'current.$target' auf dieses Verzeichnis. -# Warum? Damit z.B. in /etc/exim4 dann immer *auf jedem Host* ein Link -# nach /ha-config/current.etc/exim4/exim4.conf liegen kann. Sonst wären die -# /etc-Verzeichnisse ja wieder unterschiedlich. -# FIXME: Was, wenn es nicht ein Verzeichnis direkt unter / ist? -for p in $hostname.*; do - - # Ziel ist das, was dem Punkt folgt - target=${p#$hostname.} - - echo "$ME: found target $target" >&2 - - echo "$ME: `rm -vf current.$target`" >&2 - echo "$ME: `ln -vs $p current.$target`" >&2 - - # Wenn Konflikte auftreten, diese Konflikt-Files - # zur Seite legen - echo "$ME: resolving possible conflicts" >&2 - stow --target /$target -ncR current.$target 2>&1 \ - | sed 's/^.*[[:space:]]vs\.[[:space:]]\+//' \ - | tee /tmp/$ME.tmp \ - | xargs -n1 -i{} mv -v {} {}.stow.`date -I`.saved - - echo "$ME: found `wc -l &2 - rm -f /tmp/$ME.tmp - - echo "$ME: stowing" >&2 - stow --target /$target -R current.$target -done - -# vim:ai aw sm: diff -r b2ddc3c831c6 -r 2272c9e2eaf7 ha-diff --- a/ha-diff Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#! /usr/bin/perl -# ha-diff [diff-options] file -use strict; -use warnings; -use Cwd qw(abs_path); - -die "bad usage" if @ARGV < 2; - -my $file = pop @ARGV; -my $other = pop @ARGV; - -$file = abs_path($file) if not $file =~ /^\//; -push @ARGV, "-u" if (not @ARGV); - -system qq{/bin/bash -c "diff @ARGV --label other <(ssh $other cat '$file') '$file'"}; -system qq{/bin/bash -c "diff @ARGV --label other --label local <(ssh $other stat '$file') <(stat '$file')"} - if $? == 0; diff -r b2ddc3c831c6 -r 2272c9e2eaf7 ha-hostname --- a/ha-hostname Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: ha-hostname -# Required-Start: -# Required-Stop: -# Should-Start: hostname -# Default-Start: S -# Default-Stop: -# Short-Description: Set hostname based on /etc/hostname -# Description: Read the machines hostname from /etc/hostname, and -# update the kernel value with this value. If -# /etc/hostname is empty, the current kernel value -# for hostname is used. If the kernel value is -# empty, the value 'localhost' is used. -### END INIT INFO - -PATH=/sbin:/bin:/usr/sbin:/usr/bin - -. /lib/init/vars.sh -. /lib/lsb/init-functions - -do_start () { - - # .hs - eval `grep -o '[[:blank:]]hostname=[[:graph:]]\+' /proc/cmdline | tail -1` - - if test "$hostname"; then - HOSTNAME="$hostname" - else - [ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)" - fi - - # Keep current name if /etc/hostname is missing. - [ -z "$HOSTNAME" ] && HOSTNAME="$(hostname)" - - # And set it to 'localhost' if no setting was found - [ -z "$HOSTNAME" ] && HOSTNAME=localhost - - [ "$VERBOSE" != no ] && log_action_begin_msg "Setting hostname to '$HOSTNAME'" - hostname "$HOSTNAME" - ES=$? - [ "$VERBOSE" != no ] && log_action_end_msg $ES - exit $ES -} - -case "$1" in - start|"") - do_start - ;; - restart|reload|force-reload) - echo "Error: argument '$1' not supported" >&2 - exit 3 - ;; - stop) - # No-op - ;; - *) - echo "Usage: hostname.sh [start|stop]" >&2 - exit 3 - ;; -esac diff -r b2ddc3c831c6 -r 2272c9e2eaf7 ha-sync --- a/ha-sync Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -#! /bin/bash -CONFIG=/etc/ha-sync/ha-sync.conf -source $CONFIG - -test "$NODE" \ - && test "$NODE_A" \ - && test "$NODE_B" \ - && test "$FILESYSTEMS" \ - && test "$EXCLUDE" \ - || { - echo "$0: essential config variables are missing from $CONFIG" >&2 - exit 2 -} - -grep "REMOVE AT LEAST THIS LINE" $EXCLUDE -q && { - echo "$0: Please review $EXCLUDE first!" >&2 - exit 2 -} - -# check rsync version -rsync --help | grep -qe '--acls' || { - echo "$0: rsync does not support '--acls'" >&2 - exit -} - -rsync --help | grep -qe '--itemize-changes' || { - echo "$0: rsync does not support '--itemize-changes'" >&2 - exit -} - -NODES="$NODE_A $NODE_B" - -# No user serviceable parts inside :-) -SSHID="/etc/ha-sync/id_rsa" -export RSYNC_RSH="ssh -i $SSHID" - -TMP=`getopt -n $0 -o nd -l dry,debug -- "$@"` || exit -eval set -- $TMP - -while true; do - case "$1" in - -n|--dry) opt_dry=1; shift;; - -d|--debug) opt_debug=1; shift;; - --) break; shift;; - esac -done - - -other() { - # we assume that there only two! - echo $NODES | tr ' ' '\n' | grep -v "$NODE" -} - -# exclude list -# we cannot sync the dirs under maintainance of drbdlinks -# on any of our nodes... -exclude=`tempfile` -trap "rm -f $exclude" EXIT -echo $exclude >$exclude # and exclude it! - -OTHER=`other` -while read; do - if test "${REPLY:0:1}" = '`'; then - REPLY=${REPLY#?} - REPLY=${REPLY%?} - { - $REPLY - ssh -i "$SSHID" $OTHER "$REPLY" >$exclude - - -command -v drbdlinks >/dev/null && { - drbdlinks list | sed 's/[[:space:]].*//' >>$exclude -} - -cd / || exit 1 -for FS in ${FILESYSTEMS%/}/; do - extraopt= - - # if less than 100M: checksumming - test "`df -m \"$FS\" | awk 'NR == 2 {print $3 < 100}'`" = 1 \ - && extraopt=-c - - ${opt_debug+echo} rsync ${opt_dry+-ni} \ - $extraopt \ - --exclude-from $exclude \ - --del --acls -Ravx .$FS `other`:/ - -done - - -# we do not sync the kernel anymore! -#test "$opt_dry" || ${opt_debug+echo} ssh -i $SSHID `other` update-grub - -test "$opt_dry" \ - || ${opt_debug+echo} \ - ssh -i $SSHID `other` "run-parts /etc/ha-sync/scripts" - -# vim:sts=4 sw=4 aw ai sm: diff -r b2ddc3c831c6 -r 2272c9e2eaf7 ha-sync.conf.ex --- a/ha-sync.conf.ex Fri Aug 04 15:29:47 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -# shell snipped - -# Where are the maintained files: -DIR=/boot/ha-config - -# The two nodes to be maintained: -# NODE_A=host-a -# NODE_B=host-b -HOSTNAME=`hostname` -NODE=${HOSTNAME#*-} -NODE_A= -NODE_B= - -# Which filesystems to syncronize: -# FILESYSTEMS="/ /boot" -FILESYSTEMS= -