1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#!/bin/bash
set -e
[ -n "$IUDSZG2DEBUG" ] && set -x
STATEPDIR="/etc/network/run"
STATEDIR="$STATEPDIR/ifupdown-scripts-zg2"
OLDSTATEDIR="/var/lib/ifupdown-scripts-zg2"
if [ "$1" = "configure" ]; then
update-ifupdown-scripts-zg2.d-symlinks
if [ -d "$OLDSTATEDIR" ]; then
# OLDSTATEDIR stll exists, migrate state files from there
if ! [ -d "$STATEPDIR" ]; then
echo >&2 "ERR: missing $STATEPDIR. Is ifupdown configured?"
exit 1
fi
[ -d "$STATEDIR" ] || mkdir -m 755 "$STATEDIR"
for file in $(ls ${OLDSTATEDIR}/*.state 2>/dev/null); do
if ! [ -e "$STATEDIR/$(basename $file)" ]; then
mv "$file" "$STATEDIR/$(basename $file)"
else
echo >&2 "ERR: $(basename $file) exists in both $STATEDIR and $OLDSTATEDIR. This should not happen."
exit 1
fi
done
# OLDSTATEDIR should be empty now
if [ "$(ls -A $OLDSTATEDIR | wc -l)" != 0 ]; then
echo >&2 "ERR: $OLDSTATEDIR not empty."
exit 1
fi
rmdir "$OLDSTATEDIR"
fi
fi
#DEBHELPER#
|