git.iko.soy/typeable/nixpkgs
on master help sign in
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

commit81d8a457ed83a83f2cb4a0151ce0a9451f77eb20 authorTim Digel <tim.digel@active-group.de> dateWed 28 Dec 2016, 23:04 (10 years ago) parentd479639
5 files changed+83−37
nixos/modules/misc/ids.nix+1−1 nixos/modules/services/networking/asterisk.nix+47−13 pkgs/servers/asterisk/default.nix+28−16 pkgs/servers/asterisk/disable-download.patch+4−4 pkgs/servers/asterisk/runtime-vardirs.patch+3−3
nixos/modules/misc/ids.nix+1−1
@@ -467,7 +467,7 @@
467467 ihaskell = 189;
468468 i2p = 190;
469469 lambdabot = 191;
470− #asterisk = 192; # unused
470+ asterisk = 192;
471471 plex = 193;
472472 sabnzbd = 194;
473473 #grafana = 196; #unused
nixos/modules/services/networking/asterisk.nix+47−13
@@ -6,29 +6,38 @@ let
66 cfg = config.services.asterisk;
77
88 asteriskUser = "asterisk";
9+ asteriskGroup = "asterisk";
910
1011 varlibdir = "/var/lib/asterisk";
1112 spooldir = "/var/spool/asterisk";
1213 logdir = "/var/log/asterisk";
1314
15+ # Add filecontents from files of useTheseDefaultConfFiles to confFiles, do not override
16+ defaultConfFiles = subtractLists (attrNames cfg.confFiles) cfg.useTheseDefaultConfFiles;
17+ allConfFiles =
18+ cfg.confFiles //
19+ builtins.listToAttrs (map (x: { name = x;
20+ value = builtins.readFile (pkgs.asterisk + "/etc/asterisk/" + x); })
21+ defaultConfFiles);
22+
1423 asteriskEtc = pkgs.stdenv.mkDerivation
1524 ((mapAttrs' (name: value: nameValuePair
1625 # Fudge the names to make bash happy
1726 ((replaceChars ["."] ["_"] name) + "_")
1827 (value)
19− ) cfg.confFiles) //
28+ ) allConfFiles) //
2029 {
2130 confFilesString = concatStringsSep " " (
22− attrNames cfg.confFiles
31+ attrNames allConfFiles
2332 );
2433
25− name = "asterisk.etc";
34+ name = "asterisk-etc";
2635
2736 # Default asterisk.conf file
2837 # (Notice that astetcdir will be set to the path of this derivation)
2938 asteriskConf = ''
3039 [directories]
31− astetcdir => @out@
40+ astetcdir => /etc/asterisk
3241 astmoddir => ${pkgs.asterisk}/lib/asterisk/modules
3342 astvarlibdir => /var/lib/asterisk
3443 astdbdir => /var/lib/asterisk
@@ -169,6 +178,16 @@ in
169178 '';
170179 };
171180
181+ useTheseDefaultConfFiles = mkOption {
182+ 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" ];
183+ type = types.listOf types.str;
184+ example = [ "sip.conf" "dundi.conf" ];
185+ description = ''Sets these config files to the default content. The default value for
186+ this option contains all necesscary files to avoid errors at startup.
187+ This does not override settings via <option>services.asterisk.confFiles</option>.
188+ '';
189+ };
190+
172191 extraArguments = mkOption {
173192 default = [];
174193 type = types.listOf types.str;
@@ -182,12 +201,22 @@ in
182201 };
183202
184203 config = mkIf cfg.enable {
185− users.extraUsers = singleton
186− { name = asteriskUser;
187− uid = config.ids.uids.asterisk;
188− description = "Asterisk daemon user";
189− home = varlibdir;
190− };
204+ environment.systemPackages = [ pkgs.asterisk ];
205+
206+ environment.etc.asterisk.source = asteriskEtc;
207+
208+ users.extraUsers.asterisk =
209+ { name = asteriskUser;
210+ group = asteriskGroup;
211+ uid = config.ids.uids.asterisk;
212+ description = "Asterisk daemon user";
213+ home = varlibdir;
214+ };
215+
216+ users.extraGroups.asterisk =
217+ { name = asteriskGroup;
218+ gid = config.ids.gids.asterisk;
219+ };
191220
192221 systemd.services.asterisk = {
193222 description = ''
@@ -196,14 +225,17 @@ in
196225
197226 wantedBy = [ "multi-user.target" ];
198227
228+ # Do not restart, to avoid disruption of running calls. Restart unit by yourself!
229+ restartIfChanged = false;
230+
199231 preStart = ''
200232 # Copy skeleton directory tree to /var
201233 for d in '${varlibdir}' '${spooldir}' '${logdir}'; do
202234 # TODO: Make exceptions for /var directories that likely should be updated
203235 if [ ! -e "$d" ]; then
204236 mkdir -p "$d"
205− cp --recursive ${pkgs.asterisk}/"$d" "$d"
206− chown --recursive ${asteriskUser} "$d"
237+ cp --recursive ${pkgs.asterisk}/"$d"/* "$d"/
238+ chown --recursive ${asteriskUser}:${asteriskGroup} "$d"
207239 find "$d" -type d | xargs chmod 0755
208240 fi
209241 done
@@ -215,7 +247,9 @@ in
215247 # FIXME: This doesn't account for arguments with spaces
216248 argString = concatStringsSep " " cfg.extraArguments;
217249 in
218− "${pkgs.asterisk}/bin/asterisk -U ${asteriskUser} -C ${asteriskEtc}/asterisk.conf ${argString} -F";
250+ "${pkgs.asterisk}/bin/asterisk -U ${asteriskUser} -C /etc/asterisk/asterisk.conf ${argString} -F";
251+ ExecReload = ''${pkgs.asterisk}/bin/asterisk -x "core reload"
252+ '';
219253 Type = "forking";
220254 PIDFile = "/var/run/asterisk/asterisk.pid";
221255 };
pkgs/servers/asterisk/default.nix+28−16
@@ -1,20 +1,25 @@
1−{ stdenv, fetchurl, fetchgit, jansson, libxml2, libxslt, ncurses, openssl, sqlite, utillinux }:
2−
1+{ stdenv, pkgs, fetchurl, fetchgit,
2+ jansson, libxml2, libxslt, ncurses, openssl, sqlite,
3+ utillinux, dmidecode, libuuid, binutils, newt,
4+ lua,
5+ srtp, wget, curl,
6+ subversionClient
7+}:
38stdenv.mkDerivation rec {
49 name = "asterisk-${version}";
5− version = "13.6.0";
10+ version = "14.1.2";
611
712 src = fetchurl {
813 url = "http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-${version}.tar.gz";
9− sha256 = "0nh0fnqx84as92kk9d73s0386cndd17l06y1c72jl2bdjhyba0ca";
14+ sha256 = "0w9s4334rwvpyxm169grmnb4k9yq0l2al73dyh4cb8769qcs0ij8";
1015 };
1116
1217 # Note that these sounds are included with the release tarball. They are
1318 # provided here verbatim for the convenience of anyone wanting to build
1419 # Asterisk from other sources.
1520 coreSounds = fetchurl {
16− url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.4.26.tar.gz;
17− sha256 = "2300e3ed1d2ded6808a30a6ba71191e7784710613a5431afebbd0162eb4d5d73";
21+ url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.5.tar.gz;
22+ sha256 = "01xzbg7xy0c5zg7sixjw5025pvr4z64kfzi9zvx19im0w331h4cd";
1823 };
1924 mohSounds = fetchurl {
2025 url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-wav-2.03.tar.gz;
@@ -22,7 +27,7 @@ stdenv.mkDerivation rec {
2227 };
2328 # TODO: Sounds for other languages could be added here
2429
25− buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux ];
30+ buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux dmidecode libuuid binutils newt lua srtp wget curl subversionClient ];
2631
2732 patches = [
2833 # Disable downloading of sound files (we will fetch them
@@ -38,14 +43,24 @@ stdenv.mkDerivation rec {
3843
3944 # Use the following preConfigure section when building Asterisk from sources
4045 # other than the release tarball.
41−# preConfigure = ''
42−# ln -s ${coreSounds} sounds/asterisk-core-sounds-en-gsm-1.4.26.tar.gz
43−# ln -s ${mohSounds} sounds/asterisk-moh-opsound-wav-2.03.tar.gz
44−# '';
46+ # preConfigure = ''
47+ # ln -s ${coreSounds} sounds/asterisk-core-sounds-en-gsm-1.5.tar.gz
48+ # ln -s ${mohSounds} sounds/asterisk-moh-opsound-wav-2.03.tar.gz
49+ #'';
4550
4651 # The default libdir is $PREFIX/usr/lib, which causes problems when paths
4752 # compiled into Asterisk expect ${out}/usr/lib rather than ${out}/lib.
48− configureFlags = "--libdir=\${out}/lib";
53+ configureFlags = [
54+ "--libdir=\${out}/lib"
55+ "--with-lua=${lua}/lib"
56+ "--with-pjproject-bundled"
57+ ];
58+
59+ preBuild = ''
60+ make menuselect.makeopts
61+ substituteInPlace menuselect.makeopts --replace 'format_mp3 ' ""
62+ ./contrib/scripts/get_mp3_source.sh
63+ '';
4964
5065 postInstall = ''
5166 # Install sample configuration files for this version of Asterisk
@@ -56,9 +71,6 @@ stdenv.mkDerivation rec {
5671 description = "Software implementation of a telephone private branch exchange (PBX)";
5772 homepage = http://www.asterisk.org/;
5873 license = licenses.gpl2;
59− maintainers = with maintainers; [ auntie ];
60− # Marked as broken due to needing an update for security issues.
61− # See: https://github.com/NixOS/nixpkgs/issues/18856
62− broken = true;
74+ maintainers = with maintainers; [ auntie DerTim1 ];
6375 };
6476}
pkgs/servers/asterisk/disable-download.patch+4−4
@@ -1,7 +1,7 @@
1−diff -ruN asterisk-13.2.0/sounds/Makefile asterisk-13.2.0-patched/sounds/Makefile
2−--- asterisk-13.2.0/sounds/Makefile 2014-09-09 14:01:11.000000000 -0600
3−+++ asterisk-13.2.0-patched/sounds/Makefile 2015-03-31 16:12:00.549133670 -0600
4−@@ -89,7 +89,7 @@
1+diff -ruN asterisk-14.1.2/sounds/Makefile asterisk-14.1.2-patched/sounds/Makefile
2+--- asterisk-14.1.2/sounds/Makefile 2016-11-10 20:43:02.000000000 +0100
3++++ asterisk-14.1.2-patched/sounds/Makefile 2016-11-16 10:08:46.591615147 +0100
4+@@ -90,7 +90,7 @@
55 ) && touch "$(1)$(if $(3),/$(3),)/$$@"; \
66 fi
77
pkgs/servers/asterisk/runtime-vardirs.patch+3−3
@@ -1,6 +1,6 @@
1−diff -rupN asterisk-13.3.2/build_tools/make_defaults_h asterisk-13.3.2-patched/build_tools/make_defaults_h
2−--- asterisk-13.3.2/build_tools/make_defaults_h 2012-01-30 14:21:16.000000000 -0700
3−+++ asterisk-13.3.2-patched/build_tools/make_defaults_h 2015-04-15 19:07:46.760351155 -0600
1+diff -rupN asterisk-14.1.2/build_tools/make_defaults_h asterisk-14.1.2-patched/build_tools/make_defaults_h
2+--- asterisk-14.1.2/build_tools/make_defaults_h 2016-11-10 20:43:02.000000000 +0100
3++++ asterisk-14.1.2-patched/build_tools/make_defaults_h 2016-11-16 10:09:04.189625495 +0100
44@@ -1,4 +1,13 @@
55 #!/bin/sh
66+