mirror of
git://git.proxmox.com/git/pve-network.git
synced 2025-04-30 11:27:11 +02:00

failing a package-install does not help repairing the situation - so
inform the user about the issue instead of erroring out. The copy
could fail if a node is not quorate, so writes in /etc/pve are a bit
more likely to fail
adapts the change introduced in
d0628df
("debian: migrate legacy mac/ipam cache/state files")
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
36 lines
911 B
Bash
36 lines
911 B
Bash
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
migrate_ipam_db() {
|
|
LEGACY_IPAM_DB_FILE="/etc/pve/priv/ipam.db"
|
|
IPAM_DB_FILE="/etc/pve/sdn/pve-ipam-state.json"
|
|
|
|
if test -f "$LEGACY_IPAM_DB_FILE" && test ! -f "$IPAM_DB_FILE"; then
|
|
echo "copying over existing legacy IPAM state file to new path..."
|
|
cp $LEGACY_IPAM_DB_FILE $IPAM_DB_FILE || echo "copying IPAM state file failed!"
|
|
fi
|
|
}
|
|
|
|
migrate_mac_cache() {
|
|
LEGACY_MAC_DB_FILE="/etc/pve/priv/macs.db"
|
|
MAC_DB_FILE="/etc/pve/sdn/mac-cache.json"
|
|
|
|
if test -f "$LEGACY_MAC_DB_FILE" && test ! -f "$MAC_DB_FILE"; then
|
|
echo "copying over existing legacy IPAM MAC-map cache file to new path..."
|
|
cp $LEGACY_MAC_DB_FILE $MAC_DB_FILE || echo "copying IPAM MAC-map cache file failed!"
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
configure)
|
|
# TODO: remove with PVE 9+
|
|
if dpkg --compare-versions "$2" 'lt' '0.9.9'; then
|
|
migrate_ipam_db
|
|
migrate_mac_cache
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
exit 0
|