This would do the job:
vi /etc/rc.d/erlang.sh
-
#!/bin/sh
-
case $1 in
-
start)
-
/usr/pkg/bin/erl -Pa /home/user/path_to_your_applications +A 5 -remsh -name e1@192.168.1.5 -heart -detached -setcookie "mycookie" &
-
;;
-
stop)
-
killall erl
-
;;
-
esac