Skip to content

Commit

Permalink
made a service to start IMUNES topologies on boot
Browse files Browse the repository at this point in the history
FreeBSD only.
Copy topologies in /var/imunes-service to start them on boot time.
Run 'make service' to enable the service.
Run 'make noservice' to disable the service.
  • Loading branch information
denisSal committed Jun 15, 2016
1 parent b5a4f74 commit 4170914
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
23 changes: 23 additions & 0 deletions GNUmakefile
Expand Up @@ -18,6 +18,8 @@ TARBALL_DIR = imunes_$(IMUNESDATE)
RELEASE_DIR = imunes-$(IMUNESVER)
UNAME_S = $(shell uname -s)
VROOT_EXISTS = $(shell [ -d /var/imunes/vroot ] && echo 1 || echo 0 )
SERVICEDIR=/usr/local/etc/rc.d
STARTUPDIR=/var/imunes-service

BASEFILES = COPYRIGHT README VERSION
CONFIGFILES = $(wildcard config/*.tcl)
Expand Down Expand Up @@ -131,6 +133,8 @@ uninstall:
for file in imunes $(notdir $(TOOLS)); do \
rm -f $(BINDIR)/$${file}; \
done ;
rm -rf $(STARTUPDIR)
rm -rf $(SERVICEDIR)/imunes-service.sh

netgraph:
ifeq ($(UNAME_S), FreeBSD)
Expand Down Expand Up @@ -164,6 +168,25 @@ else
@echo "/var/imunes/vroot does not exist, exiting..."
endif

service:
ifeq ($(UNAME_S), FreeBSD)
cp scripts/imunes-service.sh $(SERVICEDIR)
chmod 755 $(SERVICEDIR)/imunes-service.sh
mkdir -p $(STARTUPDIR)
@echo ""
@echo "Created directory $(STARTUPDIR)"
@echo "To start the experiment on boot, copy a topology to this folder."
endif

noservice:
ifeq ($(UNAME_S), FreeBSD)
rm -rf $(SERVICEDIR)/imunes-service.sh
@echo ""
@echo "Removed $(SERVICEDIR)/imunes-service.sh"
@echo "To remove startup topologies, remove $(STARTUPDIR)"
endif


tarball:
rm -f ../$(TARBALL_DIR).tar.gz

Expand Down
18 changes: 18 additions & 0 deletions scripts/imunes-service.sh
@@ -0,0 +1,18 @@
#!/bin/sh

. /etc/rc.subr

name="imunes-service"
start_cmd="${name}_start"
stop_cmd=":"

imunes-service_start() {
startupFolder="/var/imunes-service"
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin
for topology in `ls $startupFolder`; do
imunes -b $startupFolder/$topology
done
}

load_rc_config $name
run_rc_command "$1"

0 comments on commit 4170914

Please sign in to comment.