#!/bin/bash
mkdir -p buildirectory/sourcecode
cd buildirectory/sourcecode
dh_make -i -n -p rash_$1 -y
rm -f debian/*.EX debian/*.ex debian/README*
mkdir files/
touch files/nrpe.cfg.default
touch debian/install debian/postinst debian/postrm
printf "files/* tmp" > debian/install
printf "files/etc/* etc" > debian/install
> debian/postrm
cat >>debian/postrm <<EOF
#!/bin/bash
rm -fr /etc/nagios/nrpe.cfg.installed
EOF
> debian/changelog
cat>>debian/changelog <<EOF
rash ($1) stable; urgency=medium
* Initial build
-- Naveed Sheikh <naveed@nash.com> $(date -R)
EOF
> debian/control
cat >>debian/control <<EOF
Source: rash
Section: installation
Priority: optional
Maintainer: Naveed Sheikh <naveed@nash.com>
Build-Depends: debhelper (>= 10)
Standards-Version: 4.1.2
Homepage: www.home.com
Package: rash
Architecture: all
Pre-Depends: nagios-nrpe-server
Depends: \${misc:Depends}
Description: Installing nrpe config file
EOF
> debian/postinst
cat >>debian/postinst<<EOF
#!/bin/sh
after_upgrade() {
:
#!/bin/bash
if [ -e /etc/nagios/nrpe.cfg.installed ]
then
rm -fr /tmp/nrpe.cfg.default
exit 0
else
cd /etc/nagios/
cat /tmp/nrpe.cfg.default > nrpe.cfg
mv /tmp/nrpe.cfg.default nrpe.cfg.installed
rm -fr /tmp/nrpe.cfg.default
fi
}
after_install() {
:
#!/bin/bash
cd /etc/nagios/
mv nrpe.cfg nrpe.original.backup
cat /tmp/nrpe.cfg.default > nrpe.cfg
mv /tmp/nrpe.cfg.default nrpe.cfg.installed
rm -fr nrpe.original.backup /tmp/nrpe.cfg.default
}
if [ "${1}" = "configure" -a -z "${2}" ] || \
[ "${1}" = "abort-remove" ]
then
# "after install" here
# "abort-remove" happens when the pre-removal script failed.
# In that case, this script, which should be idemptoent, is run
# to ensure a clean roll-back of the removal.
after_install
elif [ "${1}" = "configure" -a -n "${2}" ]
then
upgradeFromVersion="${2}"
# "after upgrade" here
# NOTE: This slot is also used when deb packages are removed,
# but their config files aren't, but a newer version of the
# package is installed later, called "Config-Files" state.
# basically, that still looks a _lot_ like an upgrade to me.
after_upgrade "${2}"
elif echo "${1}" | grep -E -q "(abort|fail)"
then
echo "Failed to install before the post-installation script was run." >&2
exit 1
fi
EOF
chmod 755 debian/post*
dpkg-buildpackage -uc -us
exit 0
mkdir -p buildirectory/sourcecode
cd buildirectory/sourcecode
dh_make -i -n -p rash_$1 -y
rm -f debian/*.EX debian/*.ex debian/README*
mkdir files/
touch files/nrpe.cfg.default
touch debian/install debian/postinst debian/postrm
printf "files/* tmp" > debian/install
printf "files/etc/* etc" > debian/install
> debian/postrm
cat >>debian/postrm <<EOF
#!/bin/bash
rm -fr /etc/nagios/nrpe.cfg.installed
EOF
> debian/changelog
cat>>debian/changelog <<EOF
rash ($1) stable; urgency=medium
* Initial build
-- Naveed Sheikh <naveed@nash.com> $(date -R)
EOF
> debian/control
cat >>debian/control <<EOF
Source: rash
Section: installation
Priority: optional
Maintainer: Naveed Sheikh <naveed@nash.com>
Build-Depends: debhelper (>= 10)
Standards-Version: 4.1.2
Homepage: www.home.com
Package: rash
Architecture: all
Pre-Depends: nagios-nrpe-server
Depends: \${misc:Depends}
Description: Installing nrpe config file
EOF
> debian/postinst
cat >>debian/postinst<<EOF
#!/bin/sh
after_upgrade() {
:
#!/bin/bash
if [ -e /etc/nagios/nrpe.cfg.installed ]
then
rm -fr /tmp/nrpe.cfg.default
exit 0
else
cd /etc/nagios/
cat /tmp/nrpe.cfg.default > nrpe.cfg
mv /tmp/nrpe.cfg.default nrpe.cfg.installed
rm -fr /tmp/nrpe.cfg.default
fi
}
after_install() {
:
#!/bin/bash
cd /etc/nagios/
mv nrpe.cfg nrpe.original.backup
cat /tmp/nrpe.cfg.default > nrpe.cfg
mv /tmp/nrpe.cfg.default nrpe.cfg.installed
rm -fr nrpe.original.backup /tmp/nrpe.cfg.default
}
if [ "${1}" = "configure" -a -z "${2}" ] || \
[ "${1}" = "abort-remove" ]
then
# "after install" here
# "abort-remove" happens when the pre-removal script failed.
# In that case, this script, which should be idemptoent, is run
# to ensure a clean roll-back of the removal.
after_install
elif [ "${1}" = "configure" -a -n "${2}" ]
then
upgradeFromVersion="${2}"
# "after upgrade" here
# NOTE: This slot is also used when deb packages are removed,
# but their config files aren't, but a newer version of the
# package is installed later, called "Config-Files" state.
# basically, that still looks a _lot_ like an upgrade to me.
after_upgrade "${2}"
elif echo "${1}" | grep -E -q "(abort|fail)"
then
echo "Failed to install before the post-installation script was run." >&2
exit 1
fi
EOF
chmod 755 debian/post*
dpkg-buildpackage -uc -us
exit 0
No comments:
Post a Comment