ZNC: Fix webadmin, allow external config and minor fixes
* Fix the webadmin module and add the themes * Allow providing ZNC an external config (closes #9110) * Allow specifying the user and group to run ZNC as (needs su when using external config) * Allow providing a certificate for incoming SSL connections * Reduce buildtime by not rebuilding everything everytime Signed-off-by: Jonas Gorski <jonas.gorski+openwrt@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/packages@26722 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
6a9be8f98c
commit
91d39ae951
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=znc
|
PKG_NAME:=znc
|
||||||
PKG_VERSION:=0.098
|
PKG_VERSION:=0.098
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=http://znc.in/releases
|
PKG_SOURCE_URL:=http://znc.in/releases
|
||||||
@ -73,12 +73,58 @@ define module
|
|||||||
define Package/znc-mod-$(strip $(1))/install
|
define Package/znc-mod-$(strip $(1))/install
|
||||||
$(INSTALL_DIR) $$(1)/usr/lib/znc/
|
$(INSTALL_DIR) $$(1)/usr/lib/znc/
|
||||||
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/modules/$(strip $(3))$(subst -,_,$(strip $(1))).so $$(1)/usr/lib/znc/
|
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/modules/$(strip $(3))$(subst -,_,$(strip $(1))).so $$(1)/usr/lib/znc/
|
||||||
|
# include webadmin page templates if existing
|
||||||
|
if [ -d $$(PKG_BUILD_DIR)/modules/$(strip $(3))$(subst -,_,$(strip $(1))) ]; then \
|
||||||
|
$(INSTALL_DIR) $$(1)/usr/share/znc/ ;\
|
||||||
|
$(CP) -r $$(PKG_BUILD_DIR)/modules/$(strip $(3))$(subst -,_,$(strip $(1))) $$(1)/usr/share/znc/ ;\
|
||||||
|
fi
|
||||||
endef
|
endef
|
||||||
|
|
||||||
ZNC_MODULES += znc-mod-$(strip $(1))
|
ZNC_MODULES += znc-mod-$(strip $(1))
|
||||||
$(if $(CONFIG_PACKAGE_znc-mod-$(strip $(1))),ZNC_MODULE_TARGETS += $(strip $(3))$(subst -,_,$(strip $(1))).so)
|
$(if $(CONFIG_PACKAGE_znc-mod-$(strip $(1))),ZNC_MODULE_TARGETS += $(strip $(3))$(subst -,_,$(strip $(1))).so)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
define webadmin
|
||||||
|
define Package/znc-mod-webadmin
|
||||||
|
$(Package/znc/default)
|
||||||
|
TITLE+= (webadmin plugin)
|
||||||
|
DEPENDS:=znc
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/znc-mod-webadmin/description
|
||||||
|
Allows you to add/remove/edit users and settings on the fly via a web browser.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/znc-mod-webadmin/install
|
||||||
|
$(INSTALL_DIR) $$(1)/usr/lib/znc/
|
||||||
|
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/modules/webadmin.so $$(1)/usr/lib/znc/
|
||||||
|
$(INSTALL_DIR) $$(1)/usr/share/znc/
|
||||||
|
$(CP) -r $$(PKG_BUILD_DIR)/modules/webadmin $$(1)/usr/share/znc/
|
||||||
|
$(INSTALL_DIR) $$(1)/usr/share/znc/webskins/
|
||||||
|
$(CP) -r $$(PKG_BUILD_DIR)/webskins/_default_ $$(1)/usr/share/znc/webskins/
|
||||||
|
endef
|
||||||
|
|
||||||
|
ZNC_MODULES += znc-mod-webadmin
|
||||||
|
$(if $(CONFIG_PACKAGE_znc-mod-webadmin),ZNC_MODULE_TARGETS += webadmin.so)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define webskin
|
||||||
|
define Package/znc-webskin-$(strip $(1))
|
||||||
|
$(Package/znc/default)
|
||||||
|
TITLE+= ($(strip $(1)) webskin)
|
||||||
|
DEPENDS:=znc-mod-webadmin
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/znc-webskin-$(strip $(1))/description
|
||||||
|
$(strip $(1)) webskin for webadmin
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/znc-webskin-$(strip $(1))/install
|
||||||
|
$(INSTALL_DIR) $$(1)/usr/share/znc/webskins/
|
||||||
|
$(CP) -r $$(PKG_BUILD_DIR)/webskins/$(strip $(1)) $$(1)/usr/share/znc/webskins/
|
||||||
|
endef
|
||||||
|
ZNC_MODULES += znc-webskin-$(strip $(1))
|
||||||
|
endef
|
||||||
|
|
||||||
, := ,
|
, := ,
|
||||||
|
|
||||||
@ -164,9 +210,6 @@ $(eval $(call module,stickychan,Keeps you sticked to specific channels.))
|
|||||||
$(eval $(call module,watch,Monitor activity for specific text patterns from \
|
$(eval $(call module,watch,Monitor activity for specific text patterns from \
|
||||||
specific users and have the text sent to a special query window.))
|
specific users and have the text sent to a special query window.))
|
||||||
|
|
||||||
$(eval $(call module,webadmin,Allows you to add/remove/edit users and settings \
|
|
||||||
on the fly via a web browser.))
|
|
||||||
|
|
||||||
$(eval $(call module,antiidle,Hides your idle time.,extra/))
|
$(eval $(call module,antiidle,Hides your idle time.,extra/))
|
||||||
|
|
||||||
$(eval $(call module,autovoice,Autovoices everyone who joins some channel., \
|
$(eval $(call module,autovoice,Autovoices everyone who joins some channel., \
|
||||||
@ -203,6 +246,11 @@ $(eval $(call module,send-raw,Allows you to send raw traffic to IRC from \
|
|||||||
$(eval $(call module,shell,Have your unix shell in a query window right inside \
|
$(eval $(call module,shell,Have your unix shell in a query window right inside \
|
||||||
of your IRC client.,extra/))
|
of your IRC client.,extra/))
|
||||||
|
|
||||||
|
$(eval $(call webadmin))
|
||||||
|
|
||||||
|
$(eval $(call webskin,dark-clouds))
|
||||||
|
$(eval $(call webskin,forest))
|
||||||
|
$(eval $(call webskin,ice))
|
||||||
|
|
||||||
PKG_CONFIG_DEPENDS := $(patsubst %,CONFIG_PACKAGE_%,$(ZNC_MODULES))
|
PKG_CONFIG_DEPENDS := $(patsubst %,CONFIG_PACKAGE_%,$(ZNC_MODULES))
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
config znc
|
config znc
|
||||||
# where to listen for connections
|
# where to listen for connections
|
||||||
list listener '192.168.1.1 1234'
|
list listener '192.168.1.1 1234'
|
||||||
|
# If using SSL sockets, use the following certifcate:
|
||||||
|
# option znc_ssl_cert '/etc/znc.cert'
|
||||||
|
|
||||||
# load global modules (You need to install them first):
|
# load global modules (You need to install them first):
|
||||||
# list module 'fail2ban'
|
# list module 'fail2ban'
|
||||||
|
|
||||||
|
@ -3,8 +3,14 @@
|
|||||||
|
|
||||||
START=60
|
START=60
|
||||||
|
|
||||||
PID_FILE=/tmp/etc/znc/znc.pid
|
ZNC_CONFIG_PATH=/tmp/etc/znc
|
||||||
ZNC_CONFIG=/tmp/etc/znc/configs/znc.conf
|
PID_FILE=${ZNC_CONFIG_PATH}/znc.pid
|
||||||
|
ZNC_CONFIG=${ZNC_CONFIG_PATH}/configs/znc.conf
|
||||||
|
|
||||||
|
EXTERNAL_CONFIG=0
|
||||||
|
|
||||||
|
RUNAS_USER=
|
||||||
|
RUNAS_GROUP=
|
||||||
|
|
||||||
add_param() {
|
add_param() {
|
||||||
echo "$1 = $2" >> $ZNC_CONFIG
|
echo "$1 = $2" >> $ZNC_CONFIG
|
||||||
@ -24,24 +30,42 @@ znc_global() {
|
|||||||
local maxbuffersize
|
local maxbuffersize
|
||||||
local connectdelay
|
local connectdelay
|
||||||
local serverthrottle
|
local serverthrottle
|
||||||
|
local znc_config_path
|
||||||
|
local znc_pem_file
|
||||||
|
|
||||||
|
config_get znc_config_path "$znc" znc_config_path
|
||||||
|
|
||||||
config_get anoniplimit "$znc" anoniplimit
|
config_get RUNAS_USER "$znc" runas_user
|
||||||
config_get maxbuffersize "$znc" maxbuffersize
|
config_get RUNAS_GROUP "$znc" runas_group
|
||||||
config_get connectdelay "$znc" connectdelay
|
|
||||||
config_get serverthrottle "$znc" serverthrottle
|
|
||||||
|
|
||||||
[ -z $anoniplimit ] || echo "AnonIPLimit = $anoniplimit" >> $ZNC_CONFIG
|
if [ "${znc_config_path}" ]
|
||||||
[ -z $maxbuffersize ] || echo "MaxBufferSize = $maxbuffersize" >> $ZNC_CONFIG
|
then
|
||||||
[ -z $connectdelay ] || echo "ConnectDelay = $connectdelay" >> $ZNC_CONFIG
|
ZNC_CONFIG_PATH=$znc_config_path
|
||||||
[ -z $serverthrottle ] || echo "ServerThrottle = $anoniplimit" >> $ZNC_CONFIG
|
EXTERNAL_CONFIG=1
|
||||||
|
else
|
||||||
|
mkdir -p $ZNC_CONFIG_PATH/configs/
|
||||||
|
[ ! -f "$ZNC_CONFIG" ] || rm "$ZNC_CONFIG"
|
||||||
|
|
||||||
echo "PidFile = $PID_FILE" >> $ZNC_CONFIG
|
config_get anoniplimit "$znc" anoniplimit
|
||||||
|
config_get maxbuffersize "$znc" maxbuffersize
|
||||||
|
config_get connectdelay "$znc" connectdelay
|
||||||
|
config_get serverthrottle "$znc" serverthrottle
|
||||||
|
config_get znc_pem_file "$znc" znc_ssl_cert
|
||||||
|
|
||||||
config_list_foreach "$znc" listener "add_param Listener"
|
[ -z $znc_pem_file -o -f $ZNC_CONFIG_PATH/znc.pem ] || ln -s "$znc_pem_file" $ZNC_CONFIG_PATH/znc.pem
|
||||||
config_list_foreach "$znc" module "add_param LoadModule"
|
|
||||||
|
|
||||||
add_param LoadModule "droproot nobody nogroup"
|
[ -z $anoniplimit ] || echo "AnonIPLimit = $anoniplimit" >> $ZNC_CONFIG
|
||||||
|
[ -z $maxbuffersize ] || echo "MaxBufferSize = $maxbuffersize" >> $ZNC_CONFIG
|
||||||
|
[ -z $connectdelay ] || echo "ConnectDelay = $connectdelay" >> $ZNC_CONFIG
|
||||||
|
[ -z $serverthrottle ] || echo "ServerThrottle = $anoniplimit" >> $ZNC_CONFIG
|
||||||
|
|
||||||
|
echo "PidFile = $PID_FILE" >> $ZNC_CONFIG
|
||||||
|
|
||||||
|
config_list_foreach "$znc" listener "add_param Listener"
|
||||||
|
config_list_foreach "$znc" module "add_param LoadModule"
|
||||||
|
|
||||||
|
add_param LoadModule "droproot ${RUNAS_USER:-nobody} ${RUNAS_GROUP:-nogroup}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
add_user() {
|
add_user() {
|
||||||
@ -95,18 +119,38 @@ add_user() {
|
|||||||
|
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
mkdir -p /tmp/etc/znc/configs/
|
|
||||||
[ -f "$ZNC_CONFIG" ] && rm "$ZNC_CONFIG"
|
|
||||||
config_load znc
|
config_load znc
|
||||||
config_foreach znc_global znc
|
config_foreach znc_global znc
|
||||||
config_foreach add_listener listener
|
|
||||||
config_foreach add_user user
|
|
||||||
|
|
||||||
chown -R nobody:nogroup /tmp/etc/znc
|
if [ "$EXTERNAL_CONFIG" -eq 0 ]
|
||||||
/usr/bin/znc -d/tmp/etc/znc -r >/dev/null &
|
then
|
||||||
|
config_foreach add_listener listener
|
||||||
|
config_foreach add_user user
|
||||||
|
|
||||||
|
chown -R ${RUNAS_USER:-nobody}:${RUNAS_GROUP:-nogroup} /tmp/etc/znc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$EXTERNAL_CONFIG" -eq 1 -a "$RUNAS_USER" ]
|
||||||
|
then
|
||||||
|
local SU=$(which su)
|
||||||
|
if [ "$SU" ]
|
||||||
|
then
|
||||||
|
$SU -c "/usr/bin/znc -d$ZNC_CONFIG_PATH >/dev/null &" $RUNAS_USER
|
||||||
|
else
|
||||||
|
logger -s -t ZNC -p daemon.err "Could not run ZNC as user $RUNAS_USER: su not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
/usr/bin/znc -d$ZNC_CONFIG_PATH >/dev/null &
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
[ -f "$PID_FILE" ] && kill $(cat "$PID_FILE")
|
if [ -f "$PID_FILE" ]
|
||||||
|
then
|
||||||
|
kill $(cat "$PID_FILE")
|
||||||
|
else
|
||||||
|
killall znc
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
net/znc/patches/003-Reduce_rebuild_time.patch
Normal file
32
net/znc/patches/003-Reduce_rebuild_time.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
From 94aff4c3389111fc85054eb06b40bea26a216d0c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jonas Gorski <jonas.gorski+openwrt@gmail.com>
|
||||||
|
Date: Sat, 16 Apr 2011 05:51:04 +0200
|
||||||
|
Subject: [PATCH] Don't rebuild everything when the Makefile's timestamp changed
|
||||||
|
|
||||||
|
---
|
||||||
|
Makefile.in | 2 +-
|
||||||
|
modules/Makefile.in | 2 +-
|
||||||
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
--- a/Makefile.in
|
||||||
|
+++ b/Makefile.in
|
||||||
|
@@ -96,7 +96,7 @@ clean:
|
||||||
|
distclean: clean
|
||||||
|
rm -rf $(DISTCLEAN)
|
||||||
|
|
||||||
|
-%.o: %.cpp Makefile
|
||||||
|
+%.o: %.cpp
|
||||||
|
@mkdir -p .depend
|
||||||
|
$(E) Building $@...
|
||||||
|
$(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< -MMD -MF .depend/$@.dep
|
||||||
|
--- a/modules/Makefile.in
|
||||||
|
+++ b/modules/Makefile.in
|
||||||
|
@@ -114,7 +114,7 @@ install_metadirs: create_install_dir
|
||||||
|
clean:
|
||||||
|
rm -rf $(CLEAN)
|
||||||
|
|
||||||
|
-%.so: %.cpp Makefile
|
||||||
|
+%.so: %.cpp
|
||||||
|
@mkdir -p .depend
|
||||||
|
@mkdir -p extra
|
||||||
|
$(E) Building $(if $(filter %extra/,$(dir $<)),extra )module $(notdir $(basename $@))...
|
Loading…
x
Reference in New Issue
Block a user