Skip to content

Commit

Permalink
snapcraft: Add FPM module with command to set mode or disable it
Browse files Browse the repository at this point in the history
- New snap command:
    frr.set fpm {disable | protobuf | netlink}

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
  • Loading branch information
mwinter-osr committed Apr 21, 2017
1 parent 80b4df3 commit d851b2f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
16 changes: 16 additions & 0 deletions snapcraft/README.usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Commands defined by this snap
options
- `frr.readme`:
Returns this document `cat README_usage.md`
- `frr.set`:
Allows to enable `FPM` module. See FPM section below

and for debugging defined at this time (May get removed later - do not
depend on them). These are mainly intended to debug the Snap
Expand Down Expand Up @@ -86,6 +88,20 @@ are named `eth0`, `eth1` and `eth2`, then the additional lines in
These settings require either a reboot or a manual configuration with
`sysctl` as well.

FPM Module
----------
The `frr.set` allows to turn FPM module on or off.

frr.set fpm {disable|protobuf|netlink}

Disables FPM or enables FPM with selected mode

By default, the FPM module is disabled, but installed with netlink and
protobuf support. To enable the FPM module, use the `frr.set fpm protobuf`
or `frr.set fpm netlink` command. The command will only enable the mode
for the next restart of zebra. Please reboot or restart zebra after
changing the mode to become effective.

FAQ
---
- frr.vtysh displays `--MORE--` on long output. How to suppress this?
Expand Down
1 change: 1 addition & 0 deletions snapcraft/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ install:
install -D -m 0755 pimd-service $(DESTDIR)/bin/
install -D -m 0755 ldpd-service $(DESTDIR)/bin/
install -D -m 0755 nhrpd-service $(DESTDIR)/bin/
install -D -m 0755 set-options $(DESTDIR)/bin/
40 changes: 40 additions & 0 deletions snapcraft/scripts/set-options
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

set -e

case $1 in
fpm)
case $2 in
disable)
rm -f $SNAP_DATA/fpm.conf
echo "FPM module disabled. Please restart FRR"
;;
protobuf)
echo "-M fpm:protobuf" > $SNAP_DATA/fpm.conf
echo "FPM enabled and set to protobuf mode. Please restart FRR"
;;
netlink)
echo "-M fpm:netlink" > $SNAP_DATA/fpm.conf
echo "FPM enabled and set to netlink mode. Please restart FRR"
;;
*)
echo "Usage:"
echo " ${SNAP_NAME}.set fpm {disable|protobuf|netlink}"
echo ""
echo " Disables FPM module or enables it with specified mode"
echo " Mode will be saved for next restart of zebra, but zebra"
echo " is not automatically restarted"
exit 1
;;
esac
;;
*)
echo "Usage:"
echo " ${SNAP_NAME}.set fpm {disable|protobuf|netlink}"
echo ""
echo " Disables FPM or enables FPM with selected mode"
exit 1
;;
esac

exit 0
8 changes: 6 additions & 2 deletions snapcraft/scripts/zebra-service
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ fi
if ! [ -e $SNAP_DATA/vtysh.conf ]; then
cp $SNAP/etc/frr/vtysh.conf.default $SNAP_DATA/vtysh.conf
fi
EXTRA_OPTIONS=""
if [ -e $SNAP_DATA/fpm.conf ]; then
EXTRA_OPTIONS="`cat $SNAP_DATA/fpm.conf`"
fi
exec $SNAP/sbin/zebra \
-f $SNAP_DATA/zebra.conf \
--pid_file $SNAP_DATA/zebra.pid \
--socket $SNAP_DATA/zsock \
--vty_socket $SNAP_DATA

--vty_socket $SNAP_DATA \
--moduledir $SNAP/lib/frr/modules $EXTRA_OPTIONS
5 changes: 5 additions & 0 deletions snapcraft/snapcraft.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ apps:
- network
- network-bind
- network-control
set:
command: bin/set-options
zebra-debug:
command: sbin/zebra -f $SNAP_DATA/zebra.conf --pid_file $SNAP_DATA/zebra.pid --socket $SNAP_DATA/zsock --vty_socket $SNAP_DATA
plugs:
Expand Down Expand Up @@ -177,6 +179,7 @@ parts:
- bison
- flex
- python3-dev
- protobuf-c-compiler
stage-packages:
- coreutils
- iproute2
Expand Down Expand Up @@ -208,6 +211,8 @@ parts:
- --enable-group=root
- --enable-pimd
- --enable-ldpd
- --enable-fpm
- --enable-protobuf
- --enable-configfile-mask=0640
- --enable-logfile-mask=0640
- --localstatedir=/var/run
Expand Down

0 comments on commit d851b2f

Please sign in to comment.