post-build.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. IPK_BUILD=${BUILD_DIR}/ipk-build
  3. # Pull the files for the snmpd service out of the target to create a install archive
  4. # and setup a basic configuration so that the startup script works.
  5. mkdir -p ${IPK_BUILD}/CONTROL \
  6. ${IPK_BUILD}/etc/init.d/ \
  7. ${IPK_BUILD}/usr/sbin \
  8. ${IPK_BUILD}/etc/snmp \
  9. ${IPK_BUILD}/etc/default
  10. mv -f ${TARGET_DIR}/etc/init.d/S59snmpd ${IPK_BUILD}/etc/init.d/
  11. mv -f ${TARGET_DIR}/usr/sbin/snmpd ${IPK_BUILD}/usr/sbin/
  12. echo "agentuser nobody" > ${IPK_BUILD}/etc/snmp/snmpd.conf
  13. echo "SNMPDRUN=yes" > ${IPK_BUILD}/etc/default/snmpd
  14. # build the control file
  15. cat <<EOM >${IPK_BUILD}/CONTROL/control
  16. Package: example-snmpd-package
  17. Version: 1.0
  18. Architecture: arm
  19. Maintainer: user@domain.tld
  20. Section: extras
  21. Priority: optional
  22. Source: http://example.com
  23. Description: This is an example IPK package for installing snmpd
  24. EOM
  25. # preinst script is not created to run before the install for this test example
  26. # postinst script is ran after install completes to start the services
  27. cat <<EOM >${IPK_BUILD}/CONTROL/postinst
  28. #!/bin/sh
  29. /etc/init.d/S59snmpd start
  30. EOM
  31. chmod +x ${IPK_BUILD}/CONTROL/postinst
  32. # prerm script is ran before removal so that the services isn't in use
  33. cat <<EOM >${IPK_BUILD}/CONTROL/prerm
  34. #!/bin/sh
  35. /etc/init.d/S59snmpd stop
  36. EOM
  37. chmod +x ${IPK_BUILD}/CONTROL/prerm
  38. # build the archive from template and pkg files
  39. ${HOST_DIR}/bin/opkg-build -Z gzip ${IPK_BUILD} ${TARGET_DIR}/root/
  40. rm -fr ${IPK_BUILD}