dahdi_span_assignments.8: s/register/assign/

* Use the term "assignment" instead of "registration" (for spans).
* Further fixes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
dahdi_span_types: allow defaults + overrides

* Allow wildcards for both device and span number (as before).
  Example:
     *        *:T1

* But now we are carefull to follow strict order in the configuration
  file. This means, if there are multiple matches -- last one wins.

* So we can use specialisation:
     *        *:T1	# Everything is T1
     FOO      [34]:T1	# Except spans 3,4 on the FOO device

* Added --dry-run and --verbose options.

* Updated the man-page:
  - Fixed "registered" => "assigned".
  - Use "line mode" for E1/J1/T1.
  - Document current changes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
Change span-type.conf generation policy

* Add '--line-mode=<E1|T1|J1>' option to dahdi_span_types:
  - Will first generate a wildcard entry (* *:<type>)
  - All later entries will be commented-out.
  - Manually uncommenting any of them will create an "override"
    (e.g: mixed system with all spans T1, but some E1)

* Now dahdi_genconf does not generate span-types.conf by default:
  - Added '--line-mode=<E1|T1|J1>' option to trigger generation
  - This parameter will be passed to "dahdi_span_types dumpconfig"
  - Also explicit specification of 'spantypes' as an argument will
    trigger a similar generation (with a default of 'E1').
  - The line-mode may also be passed to the generator directly
    with identical results. Example:
          dahdi_genconf spantypes=line-mode=T1

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
dahdi_span_types: hush warning of missing attribute

Don't warn when a sysfs attribute does not exist.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
programmable bash completion for some commands

Programmable bash completion for dahdi_span_assignments,
dahdi_span_types and dahdi_genconf.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
dahdi_perl: fix regression with an AB with no modules

Fixes a regression introduced in
3572bb5a137e1fef85e30805c6811ae74a619b2a (before 2.7.0) - most of the
dahdi_perl tools will fail for an Astribank with no modules claiming
"No XPDs for '/sys/bus/astribanks/devices/xbus-00'"

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
bash_completion: fix dahdi_genconf

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
dahdi.init: Don't exit on lack of /etc/dahdi/system.conf

auto_spans and dahdi_cfg -c are valid config methods which may not have a
/etc/dahdi/system.conf. We already check for the existance of the dahdi modules
before the case start, so I think it's safe to remove this section.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
hyphen/minus fixes in man pages

in groff '-' creates a hyphen and for a minus (path, option, or similar)
you need '\-'.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
hotplug: document asterisk scriptlet

A well-behaving distribution may choose not to install
span_config.d/50-asterisk as part of dahdi-tools, as it belongs in
asterisk. Still, it would be nice to be able to keep it as a documented
usage example. So just writ where this file needs to go and what it
does.

No other change: it is still installed by default.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
README: udev hooks run scripts from directories

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
hotplug: Do not run auto span configuration if spans are auto assigned.

This reapplies the change made in commit (6ed0adc08 "dahdi_span_config: Do not run auto
span configuration if spans are auto assigned.") which appears to have been
accidentally removed in (7f826a7d35 "hotplug modularization: split logic to
scriptlets").

To rationale from commit 6ed0adc08:

I have seen cases were users run:

  # modprobe <driver>; dahdi_cfg -c <custom config file>

and the spans end up misconfigured because dahdi_span_assignments ends up
running, via udev, after the user configured the span the way it wanted.

dahdi_span_assignments now looks at auto_assign_spans module parameter on
dahdi.ko, like dahdi_handle_device already does, to determine if legacy or udev
based configuration is being done.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
hotplug: Check for auto_assign_spans only when ACTION is add.

Removes a potentially confusing error message. This is a reapplication of
(4f259cd569f6 "dahdi_handle_device, dahdi_span_config: Check for
auto_assign_spans only when ACTION is add.") which appears to have been
accidentally removed when moving the hotplug scripts into a subdirectory.

From the original commit:

When dahdi.ko is unloaded, it may be possible for the driver to be removed from
the kernel before the udev scripts are run.  When this happens, you'll see
messages like the following which are not accurate:

    'dahdi_handle_device'[24567]: Old driver (no auto_assign_spans parameter). Skip /devices/pci0000:00/0000:00:1e.0/0000:11:01.0/pci:0000:11:01.0

Now instead you will see:

    'dahdi_handle_device'[28008]: remove: /devices/pci0000:00/0000:00:1e.0/0000:11:01.0/pci:0000:11:01.0

Also, all the udev events will be logged in the system log even when they are
ignored because of legacy auto span assignment. This will help show what is
going on during the transition period to full udev configuration of spans.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>