Fix asterisk & asterisk: 13.6.0 -> 14.1.2 (#20788)

* fix/asterisk-module: use unix-group for asterisk-files
* fix/asterisk-module: add configOption to use some default config-files
* fix/asterisk-module: correction of skel copy
* fix/asterisk-module: use /etc/asterisk as configDir
* fix/asterisk-module: add reload; do not restart unit
* asterisk: 13.6.0 -> 14.1.2
* fix/asterisk: compile with lua, pjsip, format_mp3
* fix/asterisk: fix indentation
* fix/asterisk: remove broken flag
This commit is contained in:
Tim Digel 2016-12-28 23:04:58 +01:00 committed by Joachim Schiele
parent d479639187
commit 81d8a457ed
5 changed files with 83 additions and 37 deletions

View File

@ -467,7 +467,7 @@
ihaskell = 189;
i2p = 190;
lambdabot = 191;
#asterisk = 192; # unused
asterisk = 192;
plex = 193;
sabnzbd = 194;
#grafana = 196; #unused

View File

@ -6,29 +6,38 @@ let
cfg = config.services.asterisk;
asteriskUser = "asterisk";
asteriskGroup = "asterisk";
varlibdir = "/var/lib/asterisk";
spooldir = "/var/spool/asterisk";
logdir = "/var/log/asterisk";
# Add filecontents from files of useTheseDefaultConfFiles to confFiles, do not override
defaultConfFiles = subtractLists (attrNames cfg.confFiles) cfg.useTheseDefaultConfFiles;
allConfFiles =
cfg.confFiles //
builtins.listToAttrs (map (x: { name = x;
value = builtins.readFile (pkgs.asterisk + "/etc/asterisk/" + x); })
defaultConfFiles);
asteriskEtc = pkgs.stdenv.mkDerivation
((mapAttrs' (name: value: nameValuePair
# Fudge the names to make bash happy
((replaceChars ["."] ["_"] name) + "_")
(value)
) cfg.confFiles) //
) allConfFiles) //
{
confFilesString = concatStringsSep " " (
attrNames cfg.confFiles
attrNames allConfFiles
);
name = "asterisk.etc";
name = "asterisk-etc";
# Default asterisk.conf file
# (Notice that astetcdir will be set to the path of this derivation)
asteriskConf = ''
[directories]
astetcdir => @out@
astetcdir => /etc/asterisk
astmoddir => ${pkgs.asterisk}/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk
astdbdir => /var/lib/asterisk
@ -169,6 +178,16 @@ in
'';
};
useTheseDefaultConfFiles = mkOption {
default = [ "ari.conf" "acl.conf" "agents.conf" "amd.conf" "calendar.conf" "cdr.conf" "cdr_syslog.conf" "cdr_custom.conf" "cel.conf" "cel_custom.conf" "cli_aliases.conf" "confbridge.conf" "dundi.conf" "features.conf" "hep.conf" "iax.conf" "pjsip.conf" "pjsip_wizard.conf" "phone.conf" "phoneprov.conf" "queues.conf" "res_config_sqlite3.conf" "res_parking.conf" "statsd.conf" "udptl.conf" "unistim.conf" ];
type = types.listOf types.str;
example = [ "sip.conf" "dundi.conf" ];
description = ''Sets these config files to the default content. The default value for
this option contains all necesscary files to avoid errors at startup.
This does not override settings via <option>services.asterisk.confFiles</option>.
'';
};
extraArguments = mkOption {
default = [];
type = types.listOf types.str;
@ -182,12 +201,22 @@ in
};
config = mkIf cfg.enable {
users.extraUsers = singleton
{ name = asteriskUser;
uid = config.ids.uids.asterisk;
description = "Asterisk daemon user";
home = varlibdir;
};
environment.systemPackages = [ pkgs.asterisk ];
environment.etc.asterisk.source = asteriskEtc;
users.extraUsers.asterisk =
{ name = asteriskUser;
group = asteriskGroup;
uid = config.ids.uids.asterisk;
description = "Asterisk daemon user";
home = varlibdir;
};
users.extraGroups.asterisk =
{ name = asteriskGroup;
gid = config.ids.gids.asterisk;
};
systemd.services.asterisk = {
description = ''
@ -196,14 +225,17 @@ in
wantedBy = [ "multi-user.target" ];
# Do not restart, to avoid disruption of running calls. Restart unit by yourself!
restartIfChanged = false;
preStart = ''
# Copy skeleton directory tree to /var
for d in '${varlibdir}' '${spooldir}' '${logdir}'; do
# TODO: Make exceptions for /var directories that likely should be updated
if [ ! -e "$d" ]; then
mkdir -p "$d"
cp --recursive ${pkgs.asterisk}/"$d" "$d"
chown --recursive ${asteriskUser} "$d"
cp --recursive ${pkgs.asterisk}/"$d"/* "$d"/
chown --recursive ${asteriskUser}:${asteriskGroup} "$d"
find "$d" -type d | xargs chmod 0755
fi
done
@ -215,7 +247,9 @@ in
# FIXME: This doesn't account for arguments with spaces
argString = concatStringsSep " " cfg.extraArguments;
in
"${pkgs.asterisk}/bin/asterisk -U ${asteriskUser} -C ${asteriskEtc}/asterisk.conf ${argString} -F";
"${pkgs.asterisk}/bin/asterisk -U ${asteriskUser} -C /etc/asterisk/asterisk.conf ${argString} -F";
ExecReload = ''${pkgs.asterisk}/bin/asterisk -x "core reload"
'';
Type = "forking";
PIDFile = "/var/run/asterisk/asterisk.pid";
};

View File

@ -1,20 +1,25 @@
{ stdenv, fetchurl, fetchgit, jansson, libxml2, libxslt, ncurses, openssl, sqlite, utillinux }:
{ stdenv, pkgs, fetchurl, fetchgit,
jansson, libxml2, libxslt, ncurses, openssl, sqlite,
utillinux, dmidecode, libuuid, binutils, newt,
lua,
srtp, wget, curl,
subversionClient
}:
stdenv.mkDerivation rec {
name = "asterisk-${version}";
version = "13.6.0";
version = "14.1.2";
src = fetchurl {
url = "http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-${version}.tar.gz";
sha256 = "0nh0fnqx84as92kk9d73s0386cndd17l06y1c72jl2bdjhyba0ca";
sha256 = "0w9s4334rwvpyxm169grmnb4k9yq0l2al73dyh4cb8769qcs0ij8";
};
# Note that these sounds are included with the release tarball. They are
# provided here verbatim for the convenience of anyone wanting to build
# Asterisk from other sources.
coreSounds = fetchurl {
url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.4.26.tar.gz;
sha256 = "2300e3ed1d2ded6808a30a6ba71191e7784710613a5431afebbd0162eb4d5d73";
url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.5.tar.gz;
sha256 = "01xzbg7xy0c5zg7sixjw5025pvr4z64kfzi9zvx19im0w331h4cd";
};
mohSounds = fetchurl {
url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-wav-2.03.tar.gz;
@ -22,7 +27,7 @@ stdenv.mkDerivation rec {
};
# TODO: Sounds for other languages could be added here
buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux ];
buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux dmidecode libuuid binutils newt lua srtp wget curl subversionClient ];
patches = [
# Disable downloading of sound files (we will fetch them
@ -38,14 +43,24 @@ stdenv.mkDerivation rec {
# Use the following preConfigure section when building Asterisk from sources
# other than the release tarball.
# preConfigure = ''
# ln -s ${coreSounds} sounds/asterisk-core-sounds-en-gsm-1.4.26.tar.gz
# ln -s ${mohSounds} sounds/asterisk-moh-opsound-wav-2.03.tar.gz
# '';
# preConfigure = ''
# ln -s ${coreSounds} sounds/asterisk-core-sounds-en-gsm-1.5.tar.gz
# ln -s ${mohSounds} sounds/asterisk-moh-opsound-wav-2.03.tar.gz
#'';
# The default libdir is $PREFIX/usr/lib, which causes problems when paths
# compiled into Asterisk expect ${out}/usr/lib rather than ${out}/lib.
configureFlags = "--libdir=\${out}/lib";
configureFlags = [
"--libdir=\${out}/lib"
"--with-lua=${lua}/lib"
"--with-pjproject-bundled"
];
preBuild = ''
make menuselect.makeopts
substituteInPlace menuselect.makeopts --replace 'format_mp3 ' ""
./contrib/scripts/get_mp3_source.sh
'';
postInstall = ''
# Install sample configuration files for this version of Asterisk
@ -56,9 +71,6 @@ stdenv.mkDerivation rec {
description = "Software implementation of a telephone private branch exchange (PBX)";
homepage = http://www.asterisk.org/;
license = licenses.gpl2;
maintainers = with maintainers; [ auntie ];
# Marked as broken due to needing an update for security issues.
# See: https://github.com/NixOS/nixpkgs/issues/18856
broken = true;
maintainers = with maintainers; [ auntie DerTim1 ];
};
}

View File

@ -1,7 +1,7 @@
diff -ruN asterisk-13.2.0/sounds/Makefile asterisk-13.2.0-patched/sounds/Makefile
--- asterisk-13.2.0/sounds/Makefile 2014-09-09 14:01:11.000000000 -0600
+++ asterisk-13.2.0-patched/sounds/Makefile 2015-03-31 16:12:00.549133670 -0600
@@ -89,7 +89,7 @@
diff -ruN asterisk-14.1.2/sounds/Makefile asterisk-14.1.2-patched/sounds/Makefile
--- asterisk-14.1.2/sounds/Makefile 2016-11-10 20:43:02.000000000 +0100
+++ asterisk-14.1.2-patched/sounds/Makefile 2016-11-16 10:08:46.591615147 +0100
@@ -90,7 +90,7 @@
) && touch "$(1)$(if $(3),/$(3),)/$$@"; \
fi

View File

@ -1,6 +1,6 @@
diff -rupN asterisk-13.3.2/build_tools/make_defaults_h asterisk-13.3.2-patched/build_tools/make_defaults_h
--- asterisk-13.3.2/build_tools/make_defaults_h 2012-01-30 14:21:16.000000000 -0700
+++ asterisk-13.3.2-patched/build_tools/make_defaults_h 2015-04-15 19:07:46.760351155 -0600
diff -rupN asterisk-14.1.2/build_tools/make_defaults_h asterisk-14.1.2-patched/build_tools/make_defaults_h
--- asterisk-14.1.2/build_tools/make_defaults_h 2016-11-10 20:43:02.000000000 +0100
+++ asterisk-14.1.2-patched/build_tools/make_defaults_h 2016-11-16 10:09:04.189625495 +0100
@@ -1,4 +1,13 @@
#!/bin/sh
+