Committed revision 23627 - Reverts Commit 23626 - Needs fixing

On Sun, Oct 24, 2010 at 9:11 PM, Outback Dingo <[email protected]>wrote:

> Committed revision 23626.
>
>
> On Sat, Oct 23, 2010 at 6:32 PM, Jonas Gorski <
> [email protected] <jonas.gorski%[email protected]>> wrote:
>
>> Add a startup and a uci configuration for ZNC. This allows configuring
>> multiple users, loading modules with parameters (global and per user)
>> and starts the ZNC binary as nobody. The latter requires su, so add this
>> as a dependecy.
>>
>> Signed-off-by: Jonas Gorski 
>> <[email protected]<jonas.gorski%[email protected]>
>> >
>> ---
>>  net/znc/Makefile       |   10 +++++-
>>  net/znc/files/znc.conf |   13 +++++++
>>  net/znc/files/znc.init |   92
>> ++++++++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 114 insertions(+), 1 deletions(-)
>>  create mode 100644 net/znc/files/znc.conf
>>  create mode 100644 net/znc/files/znc.init
>>
>> diff --git a/net/znc/Makefile b/net/znc/Makefile
>> index 08364d4..1eaf795 100644
>> --- a/net/znc/Makefile
>> +++ b/net/znc/Makefile
>> @@ -29,7 +29,7 @@ endef
>>
>>  define Package/znc
>>   $(Package/znc/default)
>> -  DEPENDS:=+libopenssl +uclibcxx
>> +  DEPENDS:=+libopenssl +uclibcxx +coreutils-su
>>   MENU:=1
>>  endef
>>
>> @@ -39,6 +39,10 @@ define Package/znc/description
>>        bouncing, and c++ module support to name a few.
>>  endef
>>
>> +define Package/znc/conffiles
>> +/etc/config/znc
>> +endef
>> +
>>  define Package/znc-mod-admin
>>   $(Package/znc/default)
>>   TITLE+= (admin plugin)
>> @@ -388,6 +392,10 @@ endef
>>  define Package/znc/install
>>        $(INSTALL_DIR) $(1)/usr/bin
>>        $(INSTALL_BIN) $(PKG_BUILD_DIR)/znc $(1)/usr/bin/
>> +       $(INSTALL_DIR) $(1)/etc/init.d
>> +       $(INSTALL_BIN) ./files/znc.init $(1)/etc/init.d/znc
>> +       $(INSTALL_DIR) $(1)/etc/config
>> +       $(INSTALL_DATA) ./files/znc.conf $(1)/etc/config/znc
>>  endef
>>
>>  define Package/znc-mod-admin/install
>> diff --git a/net/znc/files/znc.conf b/net/znc/files/znc.conf
>> new file mode 100644
>> index 0000000..ba3f069
>> --- /dev/null
>> +++ b/net/znc/files/znc.conf
>> @@ -0,0 +1,13 @@
>> +config znc
>> +       # where to listen for connections
>> +       list listener   '192.168.1.1 1234'
>> +
>> +config user 'sampleUser'
>> +       option password 'changeme'
>> +       option nick     'sampleUser'
>> +       option altnick  'userSample'
>> +       option ident    'openwrt'
>> +       option realname 'John Doe'
>> +
>> +       # list of allowed servers
>> +       list server     'chat.freenode.net 6667'
>> diff --git a/net/znc/files/znc.init b/net/znc/files/znc.init
>> new file mode 100644
>> index 0000000..6e56efd
>> --- /dev/null
>> +++ b/net/znc/files/znc.init
>> @@ -0,0 +1,92 @@
>> +#!/bin/sh /etc/rc.common
>> +# Copyright (C) 2010 Openwrt.org
>> +
>> +START=60
>> +
>> +PID_FILE=/tmp/etc/znc/znc.pid
>> +ZNC_CONFIG=/tmp/etc/znc/configs/znc.conf
>> +
>> +add_param() {
>> +       echo "$1 = $2" >> $ZNC_CONFIG
>> +}
>> +
>> +znc_global() {
>> +       local znc="$1"
>> +       local anoniplimit
>> +       local maxbuffersize
>> +       local connectdelay
>> +       local serverthrottle
>> +
>> +
>> +       config_get anoniplimit "$znc" anoniplimit
>> +       config_get maxbuffersize "$znc" maxbuffersize
>> +       config_get connectdelay "$znc" connectdelay
>> +       config_get serverthrottle "$znc" serverthrottle
>> +
>> +       [ -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_user() {
>> +       local user="$1"
>> +       local password
>> +       local nick
>> +       local altnick
>> +       local ident
>> +       local realname
>> +       local buffer
>> +       local quitmsg
>> +       local chanmodes
>> +       local vhost
>> +
>> +       config_get password "$user" password
>> +       config_get nick "$user" nick
>> +       config_get altnick "$user" altnick
>> +       config_get ident "$user" ident
>> +       config_get realname "$user" realname
>> +       config_get buffer "$user" buffer
>> +       config_get quitmsg "$user" quitmsg
>> +       config_get chanmodes "$user" chanmodes
>> +       config_get vhost "$user" vhost
>> +
>> +       echo "<User $user>" >> $ZNC_CONFIG
>> +       echo "  Pass = plain#$password" >> $ZNC_CONFIG
>> +       echo "  Nick = $nick" >> $ZNC_CONFIG
>> +       echo "  AltNick = ${altnick:-$nick"_"}" >> $ZNC_CONFIG
>> +       echo "  Ident = ${ident:-$nick}" >> $ZNC_CONFIG
>> +       echo "  RealName = ${realname:-$nick}" >> $ZNC_CONFIG
>> +       [ -z "$vhost" ] || echo "       VHost = $vhost" >> $ZNC_CONFIG
>> +       echo "  Buffer = ${buffer:-50}"  >> $ZNC_CONFIG
>> +       echo "  KeepBuffer = false" >> $ZNC_CONFIG
>> +       echo "  ChanModes = ${chanmodes:-"+stn"}" >> $ZNC_CONFIG
>> +       [ -z "$quitmsg" ] || echo "     QuitMsg = $quitmsg" >> $ZNC_CONFIG
>> +
>> +       config_list_foreach "$user" server "add_param \"        Server\""
>> +       config_list_foreach "$user" module "add_param \"
>>  LoadModule\""
>> +       echo "</User>" >> $ZNC_CONFIG
>> +}
>> +
>> +
>> +start() {
>> +       mkdir -p /tmp/etc/znc/configs/
>> +       [ -f "$ZNC_CONFIG" ] && rm "$ZNC_CONFIG"
>> +       config_load znc
>> +       config_foreach znc_global znc
>> +       config_foreach add_listener listener
>> +       config_foreach add_user user
>> +
>> +       chown -R nobody:nogroup /tmp/etc/znc
>> +       su -s /bin/ash -c "/usr/bin/znc -d/tmp/etc/znc" nobody
>> +}
>> +
>> +stop() {
>> +       [ -f "$PID_FILE" ] && kill $(cat "$PID_FILE")
>> +}
>> +
>> --
>> 1.5.6.5
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> [email protected]
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>>
>
>
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to