4
if [ -z "$SNAP" ]; then
9
upgrade_path="$SNAP_DATA/.upgraded_${SNAP_VERSION}"
10
prev_rules="$SNAP_DATA/.rules.orig"
14
prev_shipped="$prev_rules/$bn"
15
inuse="$SNAP_DATA/etc/ufw/$bn"
16
new_shipped="$SNAP/usr/share/ufw/iptables/$bn"
18
# if the old shipped rules are the same as the rules in use, but the new
19
# shipped rules are different, then copy the new rules to the rules in use
20
if diff "$prev_shipped" "$inuse" >/dev/null ; then
21
if ! diff "$new_shipped" "$prev_shipped" > /dev/null ; then
23
cp -f --preserve=mode "$new_shipped" "$inuse"
25
echo "'$bn' has changes that cannot be merged. For details, see:"
26
echo "$ diff -Nau $new_shipped $inuse"
31
# First run, none of this exists, so just copy over wholesale
32
if [ ! -e "$SNAP_DATA/lib" ]; then
33
cp -fr --preserve=mode "$SNAP/lib" "$SNAP_DATA"
35
if [ ! -e "$SNAP_DATA/etc" ]; then
36
cp -fr --preserve=mode "$SNAP/etc" "$SNAP_DATA"
37
chmod 640 "$SNAP_DATA"/etc/ufw/*.rules
38
chmod 640 "$SNAP_DATA"/etc/ufw/*.init
41
# Next, make sure these files are available for upgrade comparisons
42
if [ ! -e "$prev_rules" ]; then
46
# On upgrades, detect if the rules file matches the shipped file, and if
47
# so, apply any changes to the rules file (ie, emulate ucf)
48
if [ ! -e "$upgrade_path" ]; then
49
for fn in before.rules before6.rules after.rules after6.rules ; do
50
if [ -e "$prev_rules/$fn" ]; then
53
# create/overwrite the new, upgraded rules for comparison on next
55
cp -f --preserve=mode "$SNAP/usr/share/ufw/iptables/$fn" "$prev_rules"
58
# remove old for housekeeping
59
rm -f "$SNAP_DATA/.upgraded*"
65
"$SNAP"/lib/ufw/ufw-init --rootdir "$SNAP" --datadir "$SNAP_DATA" start