+%pre
+if [ -n "`/usr/bin/getgid %{name}`" ]; then
+ if [ "`/usr/bin/getgid %{name}`" != %{groupid} ]; then
+ echo "Error: group %{name} doesn't have gid=%{groupid}. Correct this before installing %{name}." 1>&2
+ exit 1
+ fi
+else
+ /usr/sbin/groupadd -g %{groupid} %{name}
+fi
+if [ -n "`/bin/id -u %{name} 2>/dev/null`" ]; then
+ if [ "`/bin/id -u %{name}`" != %{userid} ]; then
+ echo "Error: user %{name} doesn't have uid=%{userid}. Correct this before installing %{name}." 1>&2
+ exit 1
+ fi
+else
+ /usr/sbin/useradd -u %{userid} -d /var/run/%{name} -s /bin/false \
+ -c "%{name} User" -g %{name} %{name} 1>&2
+fi
+
+%post
+if ! egrep -q '^(adminpass|password)' /etc/bnc/bnc.conf; then
+%banner %{name} -e <<EOF
+You need to setup passwords in /etc/bnc/bnc.conf!
+The daemon will not start unless you've set them!
+
+EOF
+# ' vim
+
+fi
+
+# add service just once
+[ "$1" = "1" ] && /sbin/chkconfig --add %{name}
+
+if [ -f /var/lock/subsys/%{name} ]; then
+ /etc/rc.d/init.d/%{name} restart 1>&2
+else
+ echo "Run \"/etc/rc.d/init.d/%{name} start\" to start %{name} daemon."
+fi
+
+%preun
+if [ "$1" = "0" ]; then
+ if [ -f /var/lock/subsys/%{name} ]; then
+ /etc/rc.d/init.d/%{name} stop 1>&2
+ fi
+ /sbin/chkconfig --del %{name}
+fi
+
+%postun
+if [ "$1" = "0" ]; then
+ %userremove bnc
+ %groupremove bnc
+fi
+