VOL-758 OpenOLT - Create Linux services for BAL and openolt

service bal_core_dist status|stop|start
service openolt status|stop|start

bal_core_dist and openolt started as init.d services at system startup.

Change-Id: If8a97e74b999b68f202a8a3c05331766b84a4641
diff --git a/mkdebian/build_asfvolt16_deb.sh b/mkdebian/build_asfvolt16_deb.sh
index 1aed343..6c60959 100755
--- a/mkdebian/build_asfvolt16_deb.sh
+++ b/mkdebian/build_asfvolt16_deb.sh
@@ -1,4 +1,3 @@
 #!/bin/bash
 export ONL_ARCH="amd64"
 dpkg-buildpackage -b -us -uc -a"$ONL_ARCH"
-
diff --git a/mkdebian/debian/asfvolt16.postinst b/mkdebian/debian/asfvolt16.postinst
index 5369f78..b12bfb2 100644
--- a/mkdebian/debian/asfvolt16.postinst
+++ b/mkdebian/debian/asfvolt16.postinst
@@ -5,8 +5,16 @@
 tar zxf /tmp/release_asfvolt16_V02.06.201804301043.tar.gz -C / 2>&1 > /dev/null
 grep -q '\/opt\/bcm68620\/svk_init.sh' /etc/rc.local || sed -i -e '$i \/opt\/bcm68620\/svk_init.sh' /etc/rc.local
 rm -f /run/bcm68620
+cp /tmp/init.d/bal_core_dist /etc/init.d
+cp /tmp/init.d/openolt /etc/init.d
+chmod +x /etc/init.d/bal_core_dist
+chmod +x /etc/init.d/openolt
+update-rc.d bal_core_dist defaults
+update-rc.d openolt defaults
 mv /tmp/openolt /broadcom
 mv /tmp/libgrpc++.so.1 /usr/local/lib
 mv /tmp/libgrpc.so.6 /usr/local/lib
 mv /broadcom/libbal_api_dist.so /usr/local/lib
 /opt/bcm68620/svk_init.sh
+#service bal_core_dist start
+#service openolt start
diff --git a/mkdebian/debian/asfvolt16.preinst b/mkdebian/debian/asfvolt16.preinst
index 9377c9a..047e7fe 100644
--- a/mkdebian/debian/asfvolt16.preinst
+++ b/mkdebian/debian/asfvolt16.preinst
@@ -4,9 +4,13 @@
 echo "kill running time application"
 [ -n "`pidof bcm_user_appl`" ] && killall bcm_user_appl
 [ -n "`pidof bcm.user`" ] && killall bcm.user
-[ -n "`pidof bal_core_dist`" ] && killall bal_core_dist 
 [ -n "`pidof voltha_bal_driver`" ] && killall voltha_bal_driver
+# service bal_core_dist stop
+# service openolt stop
+[ -n "`pidof bal_core_dist`" ] && killall bal_core_dist 
+rm -f /var/run/bal_core_dist.pid
 [ -n "`pidof openolt`" ] && killall openolt
+rm -f /var/run/openolt.pid
 
 # unload drivers
 echo "unload kernel drivers"
diff --git a/mkdebian/debian/rules b/mkdebian/debian/rules
index 8a7f968..33d257a 100755
--- a/mkdebian/debian/rules
+++ b/mkdebian/debian/rules
@@ -30,6 +30,7 @@
 	cp -a $(CURDIR)/debian/libgrpc++.so.1 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libgrpc.so.6 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/openolt $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/init.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 
 #override_dh_shlibdeps:
 #	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info -l$(ONLP_LIB_PATH):$(OFDPA_LIB_PATH)