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