packages/zabbix: use new service functions, various other zabbix-agent fixes:
* move user/group creation from postinst to initscript * use /var/run/zabbix directory for pid file * use /var/log/zabbix directory for log file * set correct ownership and perms for both directories git-svn-id: svn://svn.openwrt.org/openwrt/packages@28892 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
241960f2db
commit
9a9089341f
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=zabbix
|
||||
PKG_VERSION:=1.6
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/zabbix
|
||||
@ -75,44 +75,6 @@ define Package/zabbix-agent/install
|
||||
$(INSTALL_BIN) ./files/zabbix_agentd.init $(1)/etc/init.d/zabbix_agentd
|
||||
endef
|
||||
|
||||
define Package/zabbix-agent/postinst
|
||||
#!/bin/sh
|
||||
|
||||
name=zabbix
|
||||
id=53
|
||||
|
||||
# do not change below
|
||||
# check if we are on real system
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
# create copies of passwd and group, if we use squashfs
|
||||
rootfs=`mount |awk '/root/ { print $$5 }'`
|
||||
if [ "$$rootfs" = "squashfs" ]; then
|
||||
if [ -h /etc/group ]; then
|
||||
rm /etc/group
|
||||
cp /rom/etc/group /etc/group
|
||||
fi
|
||||
if [ -h /etc/passwd ]; then
|
||||
rm /etc/passwd
|
||||
cp /rom/etc/passwd /etc/passwd
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then
|
||||
echo "adding group $$name to /etc/group"
|
||||
echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group
|
||||
fi
|
||||
|
||||
if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then
|
||||
echo "adding user $$name to /etc/passwd"
|
||||
echo "$${name}:x:$${id}:$${id}:$${name}:/tmp/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd
|
||||
fi
|
||||
|
||||
chown $${name} $${IPKG_INSTROOT}/etc/zabbix/zabbix_agentd.conf
|
||||
fi
|
||||
|
||||
endef
|
||||
|
||||
define Package/zabbix-sender/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/zabbix_sender $(1)/usr/sbin/
|
||||
|
@ -57,12 +57,12 @@ DebugLevel=3
|
||||
|
||||
# Name of PID file
|
||||
|
||||
PidFile=/tmp/zabbix_agentd.pid
|
||||
PidFile=/var/run/zabbix/zabbix_agentd.pid
|
||||
|
||||
# Name of log file.
|
||||
# If not set, syslog will be used
|
||||
|
||||
LogFile=/tmp/zabbix_agentd.log
|
||||
LogFile=/var/log/zabbix/zabbix_agentd.log
|
||||
|
||||
# Spend no more than Timeout seconds on processing
|
||||
# Must be between 1 and 30
|
||||
|
@ -1,21 +1,25 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2008 OpenWrt.org
|
||||
# Copyright (C) 2008-2011 OpenWrt.org
|
||||
|
||||
START=60
|
||||
|
||||
SERVICE_PID_FILE=/var/run/zabbix/zabbix_agentd.pid
|
||||
|
||||
start() {
|
||||
[ -f /etc/zabbix/zabbix_agentd.conf ] || {
|
||||
echo "/etc/zabbix/zabbix_agentd.conf does not exist !";
|
||||
exit 0;
|
||||
};
|
||||
[ -x /usr/sbin/zabbix_agentd ] && /usr/sbin/zabbix_agentd
|
||||
[ -f /etc/zabbix/zabbix_agentd.conf ] || return 1
|
||||
user_exists zabbix 53 || user_add zabbix 53
|
||||
group_exists zabbix 53 || group_add zabbix 53
|
||||
[ -d /var/log/zabbix ] || {
|
||||
mkdir -m0755 -p /var/log/zabbix
|
||||
chown zabbix:zabbix /var/log/zabbix
|
||||
}
|
||||
[ -d /var/run/zabbix ] || {
|
||||
mkdir -m0755 -p /var/run/zabbix
|
||||
chown zabbix:zabbix /var/run/zabbix
|
||||
}
|
||||
service_start /usr/sbin/zabbix_agentd
|
||||
}
|
||||
|
||||
stop() {
|
||||
killall zabbix_agentd
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
service_stop /usr/sbin/zabbix_agentd
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user