Skip to content

Commit

Permalink
Fix remove hook (#48)
Browse files Browse the repository at this point in the history
* Improve install/remove/setup logs and comments

* Fix directory removal in remove hook

* Allow firewall setup from remove hook
  • Loading branch information
farshidtz authored Jun 24, 2024
1 parent 00b96c8 commit c25bc7e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
4 changes: 3 additions & 1 deletion snap/hooks/install
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ snapctl set webgui-listen-address="::"
snapctl set webgui-port=80
set +x

mkdir -p $SNAP_COMMON/thread-data
THREAD_DATA=$SNAP_COMMON/thread-data
logger --tag=$TAG "Creating directory for thread data: $THREAD_DATA"
mkdir -p $THREAD_DATA
14 changes: 5 additions & 9 deletions snap/hooks/remove
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/bin/bash -e

TAG="$SNAP_NAME.remove"

logger --tag=$TAG "Start"

TAG="$SNAP_NAME.hook.remove"

###############################################################################
logger --tag=$TAG "Remove the firewall config"
logger --tag=$TAG "Removing the firewall config"
$SNAP/bin/script/otbr-firewall stop

logger --tag=$TAG "Removing the socket directory"
# This directory gets created whenever OTBR setup runs
rm -fr /run/snap.$SNAP_NAME


rm -f /run/snap.$SNAP_NAME

logger --tag=$TAG "End"
2 changes: 2 additions & 0 deletions snap/local/stage/bin/otbr-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

echo "OTBR oneshot setup service"

# Create directory for the OpenThread Posix Config Domain Socket
# This path is set with a build flag when building OTBR
mkdir -p /run/snap.$SNAP_NAME

# The operations performed here get reversed upon reboot and removal of the snap.
Expand Down
7 changes: 4 additions & 3 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ layout:
/var/lib/thread:
symlink: $SNAP_COMMON/thread-data

# hooks:
# install:
# plugs: [network]
hooks:
remove:
plugs:
- firewall-control

apps:
otbr-setup:
Expand Down

0 comments on commit c25bc7e

Please sign in to comment.