coova / coova-chilli

CoovaChilli is an open-source software access controller for captive portal hotspots.
Other
516 stars 258 forks source link

cannot generate configuration on ubuntu 16.04/14.04 and Debian8 x86_64 #323

Closed AceSlash closed 7 years ago

AceSlash commented 7 years ago

Hello,

Similar issue as #263 and #116 (I don't understand why those tickets are closed by the way).

When chilli is installed, it creates a script /etc/init.d/chilli that should be used to create the configuration files (if I understand correctly), but this script depends on /etc/rc.d/init.d/functions which is not present on Debian/Ubuntu systems:

# /etc/init.d/chilli start
/etc/init.d/chilli: 9: .: Can't open /etc/rc.d/init.d/functions

I created an ansible role to reproduce it:

---
# file: roles/coova_chilli/tasks/main.yml

- name: "package for build"
  apt:
    name: "{{ item }}"
    state: installed
  with_items:
    - build-essential
    - automake
    - autoconf
    - libtool
    - gengetopt
    - haserl
    - libssl-dev
    - freeradius-utils
    - git
  tags: coova_chilli

- name: "git clone"
  git:
    repo: https://github.com/coova/coova-chilli.git
    dest: /usr/local/src/coova-chilli
  register: git
  tags: coova_chilli

- name: "./bootstrap"
  command: './bootstrap chdir="/usr/local/src/coova-chilli"'
  when: git.changed == True
  tags: coova_chilli

# from https://www.howtoforge.com/tutorial/how-to-install-a-wireless-hotspot-with-captive-page-in-linux-using-coovachilli/
- name: "./configure --prefix=/usr --libdir=/usr/lib64 --localstatedir=/var --sysconfdir=/etc --enable-miniportal --with-openssl --enable-libjson --enable-useragent --enable-sessionstate --enable-sessionid --enable-chilliredir --enable-binstatusfile --enable-statusfile --disable-static --enable-shared --enable-largelimits --enable-proxyvsa --enable-chilliproxy --enable-chilliradsec --with-poll"
  command: './configure --prefix=/usr --libdir=/usr/lib64 --localstatedir=/var --sysconfdir=/etc --enable-miniportal --with-openssl --enable-libjson --enable-useragent --enable-sessionstate --enable-sessionid --enable-chilliredir --enable-binstatusfile --enable-statusfile --disable-static --enable-shared --enable-largelimits --enable-proxyvsa --enable-chilliproxy --enable-chilliradsec --with-poll chdir="/usr/local/src/coova-chilli"'
  when: git.changed == True
  tags: coova_chilli

- name: "make"
  command: 'make chdir="/usr/local/src/coova-chilli"'
  when: git.changed == True
  tags: coova_chilli

- name: "make install"
  command: 'make install chdir="/usr/local/src/coova-chilli"'
  when: git.changed == True
  tags: coova_chilli

Seems to me like coova-chilli cannot be used easily on modern Debian Family based systems, does this not qualify as a bug? Or is coova-chilli not supported on this type of distrib?

sevan commented 7 years ago

Hi, Can you post a copy of your installed /etc/init.d/chilli up or just the snippet of lines 8 to 10. The source file which generates the installed script contains # Source function library. . /etc/rc.d/init.d/functions . @ETCCHILLI@/functions

I'm interested if @ETCCHILLI@/functions has been translated correctly to the correct path for you.

AceSlash commented 7 years ago

Hello sevan, here is the begining of the file /etc/init.d/chilli:

#!/bin/sh
#
# chilli - CoovaChilli
#
# chkconfig: 2345 65 35
# description: CoovaChilli

# Source function library.
. /etc/rc.d/init.d/functions
. /etc/chilli/functions

exec="/usr/sbin/chilli"
prog=$(basename $exec)

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

MULTI=$(ls /etc/chilli/*/chilli.conf 2>/dev/null)
[ -z "$DHCPIF" ] && [ -n "$MULTI" ] && {
    for c in $MULTI;
    do
        echo "Found configuration $c"
        DHCPIF=$(basename $(echo $c|sed 's#/chilli.conf##'))
        export DHCPIF
        echo "Running DHCPIF=$DHCPIF $0 $*"
        sh $0 $*
    done
    exit
}

pidfile=/var/run/chilli.pid
CONFIG=/etc/chilli.conf

if [ -n "$DHCPIF" ]; then
    CONFIG=/etc/chilli/$DHCPIF/chilli.conf
    pidfile=/var/run/chilli.$DHCPIF.pid
fi

[ -f $CONFIG ] || {
    echo "$CONFIG not found"
    exit 0
}
sevan commented 7 years ago

ok, can you delete the line which says . /etc/rc.d/init.d/functions

sevan commented 7 years ago

And try running the script & reporting back what happens

AceSlash commented 7 years ago

Thanks! Seems to work after running chilli radconfig without the first function line, I now have the files local.conf main.conf hs.conf

Running chilli -fd after that runs coovachilli. The fix seems simple in retrospect.

sjbeskur commented 7 years ago

This almost worked. Unfortunately there also seems to be a bug with the daemon command as it doesn't seem to respect the config arguments.

I updated the following line in start()

daemon $exec -c $CONFIG

with the following

start-stop-daemon --start --quiet --pidfile $pidfile --exec $exec -- -c $CONFIG

All now seems to be working very well and systemd seems happy.

● chilli.service - SYSV: CoovaChilli
   Loaded: loaded (/etc/init.d/chilli; bad; vendor preset: enabled)
   Active: active (running) since Mon 2016-12-12 19:29:23 PST; 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 66304 ExecStart=/etc/init.d/chilli start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/chilli.service
           └─66381 /sbin/chilli -c /etc/chilli/eth1.30/chilli.conf
sevan commented 7 years ago

loaded (/etc/init.d/chilli; bad; vendor preset: enabled)

What's the bad referring to?

sjbeskur commented 7 years ago

Well, it doesn't look 'good'. I have been curious about that also.
Log messages / journalctl -xe do not indicate any issues that I can tell. I will do more testing today.

sjbeskur commented 7 years ago

Without digging much deeper into the workings of systemd I cannot determine why this message is shown. From what I can tell the "bad" message is meaningless. Coova is working as expected and there is no operational impact that I have found.