keepalived: remove file sync handling for ucitrack
[feed/packages.git] / net / keepalived / Makefile
index 2e782e81a68dce0d7befa146ecf9c468b20b8092..b04e45e9355e0bfd640019304461921c5ac922d7 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=keepalived
-PKG_VERSION:=2.2.7
-PKG_RELEASE:=$(AUTORELEASE)
+PKG_VERSION:=2.2.8
+PKG_RELEASE:=6
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://www.keepalived.org/software
-PKG_HASH:=c61940d874154a560a54627ecf7ef47adebdf832164368d10bf242a4d9b7d49d
+PKG_HASH:=85882eb62974f395d4c631be990a41a839594a7e62fbfebcb5649a937a7a1bb6
 
 PKG_CPE_ID:=cpe:/a:keepalived:keepalived
 PKG_LICENSE:=GPL-2.0-or-later
@@ -274,4 +274,103 @@ endif
 
 endef
 
+define Package/keepalived-sync
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=Keepalived Master and Backup Synchronization
+  DEPENDS:= +keepalived +rsync +inotifywait +sudo +coreutils-timeout
+endef
+
+define Package/keepalived-sync/description
+ Keepalived HA with Master to Backup files and data Synchronization
+endef
+
+define Package/keepalived-sync/conffiles
+/etc/keepalived/scripts
+/etc/keepalived/keys
+endef
+
+define Package/keepalived-sync/install
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/etc/init.d/keepalived-inotify \
+               $(1)/etc/init.d/keepalived-inotify
+
+       $(INSTALL_DIR) $(1)/usr/share/keepalived/scripts
+       $(INSTALL_BIN) ./files/usr/share/keepalived/scripts/rsync.sh \
+               $(1)/usr/share/keepalived/scripts/rsync.sh
+
+       $(INSTALL_DIR) $(1)/etc/keepalived/scripts
+       $(LN) /usr/share/keepalived/scripts/rsync.sh \
+               $(1)/etc/keepalived/scripts/rsync.sh
+
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) ./files/usr/bin/keepalived-rsync-inotify \
+               $(1)/usr/bin/keepalived-rsync-inotify
+
+       $(INSTALL_DIR) $(1)/lib/functions/keepalived
+       $(INSTALL_DATA) ./files/lib/functions/keepalived/hotplug.sh \
+               $(1)/lib/functions/keepalived/hotplug.sh
+       $(INSTALL_DATA) ./files/lib/functions/keepalived/common.sh \
+               $(1)/lib/functions/keepalived/common.sh
+
+       $(INSTALL_DIR) $(1)/usr/libexec/keepalived/rpc
+       $(INSTALL_DATA) ./files/usr/libexec/keepalived/rpc/sync.sh \
+               $(1)/usr/libexec/keepalived/rpc/sync.sh
+
+       $(INSTALL_DIR) $(1)/etc/hotplug.d/keepalived
+       $(CP) ./files/etc/hotplug.d/keepalived/* \
+               $(1)/etc/hotplug.d/keepalived
+endef
+
+USER=keepalived
+USER_ID=60001
+USER_HOME=/usr/share/keepalived/rsync
+SUDO_DIR=/etc/sudoers.d
+SUDO_FILE=$(SUDO_DIR)/$(USER)
+KEYS_DIR=/etc/keepalived/keys
+
+define Package/keepalived-sync/postinst
+       #!/bin/sh
+
+       mkdir -p "$${IPKG_INSTROOT}/etc/uci-defaults"
+       DEFAULT_SCRIPT="$${IPKG_INSTROOT}/etc/uci-defaults/99-keepalived-sync"
+
+       cat << EOF > $${DEFAULT_SCRIPT}
+#!/bin/sh
+
+. /lib/functions.sh
+
+mkdir -p $(KEYS_DIR)
+
+group_add "$(USER)" "$(USER_ID)"
+user_add "$(USER)" "$(USER_ID)" "$(USER_ID)" "$(USER)" "$(USER_HOME)" "/bin/ash"
+
+mkdir -m 700 -p "$(USER_HOME)"
+mkdir -m 700 -p "$(USER_HOME)/.ssh"
+chown "$(USER)":"$(USER)" "$(USER_HOME)" -R
+
+[ ! -d "$(SUDO_DIR)" ] && mkdir "$(SUDO_DIR)"
+echo "$(USER) ALL= NOPASSWD:/usr/bin/rsync" > "$(SUDO_FILE)"
+EOF
+
+       [ -z "$${IPKG_INSTROOT}" ] && [ -f "$${DEFAULT_SCRIPT}" ] && sh "$${DEFAULT_SCRIPT}"
+
+       exit 0
+endef
+
+define Package/keepalived-sync/postrm
+       #!/bin/sh
+
+       [ -n "$${IPKG_INSTROOT}" ] && exit 0
+
+       [ -d "$(KEYS_DIR)" ] && rm -rf "$(KEYS_DIR)"
+       [ -d "$(USER_HOME)" ] && rm -rf "$(USER_HOME)"
+       [ -f "$(SUDO_FILE)" ] && rm -f "$(SUDO_FILE)"
+
+       sed -i -e "/^$(USER):/d" /etc/passwd /etc/shadow /etc/group
+
+       exit 0
+endef
+
 $(eval $(call BuildPackage,keepalived))
+$(eval $(call BuildPackage,keepalived-sync))