Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.53 KB | None | 0 0
  1. # Maintainer: Brent Saner <bts (at) phreewifi (dot) org>
  2. # Contributor: TJ Vanderpoel <tj@rubyists.com>
  3.  
  4. ## MAINTAINER NOTE BEGIN
  5. # Most (like, ~80%) of this is taken verbatim from the freeswitch AUR package currently (as of 02.28.2014) maintained by bougyman.
  6. # https://aur.archlinux.org/packages/freeswitch/
  7. # However, it's horribly out of date and doesn't seem to be actively maintained anymore.
  8. ## MAINTAINER NOTE END
  9.  
  10.  
  11. # This builds the FreeSWITCH open source telephone engine
  12. # from the freeswitch git.  It enables the following modules
  13. # not enabled in the standard freeswitch build:
  14. #  * mod_callcenter
  15. #  * mod_xml_curl
  16. # And disables the following standard modules:
  17. #  * mod_dialplan_asterisk
  18. #  * mod_say_ru
  19. #  * mod_spidermonkey
  20. #  * mod_lua
  21. # You can modify this and other options in the BUILD CONFIGURATION section below
  22.  
  23.  
  24. # BUILD CONFIGURATION BEGINS #
  25.  
  26. # SET THIS TO GET HIGHER QUALITY SOUNDFILES
  27. # Value can be "hd-", "uhd-", or "cd-" to get 16k, 32k, or 48k sounds.
  28. # By default we only download the 8k sounds. If you only use g711 or
  29. # 8k codecs, leave this as-is
  30.  
  31. _sounds="cd-"
  32.  
  33. # ADDED MODULES
  34. # If you don't need/want these modules remove them from _enabled_modules
  35. # You can add any modules here you wish to add, make sure they're not
  36. # in _disabled_modules, though
  37. #
  38. # xml_int/mod_xml_curl - Remote http dialplan lookups/control
  39. # xml_int/mod_xml_cdr - Remote http dialplan lookups/control
  40. # applications/mod_callcenter - Inbound call queueing system
  41. _enabled_modules=(xml_int/mod_xml_curl
  42.                   xml_int/mod_xml_cdr
  43.                   formats/mod_shout
  44.                   applications/mod_callcenter
  45.           languages/mod_lua)
  46.  
  47. # DISABLED MODULES
  48. # Remove from _disabled_modules if you want to build these
  49. #
  50. # languages/mod_spidermonkey - server-side javascript
  51. # languages/mod_lua - server-side lua
  52. # say/mod_say_ru - Russian phrases
  53. # dialplans/mod_dialplan_asterisk - Legacy dialplan
  54. _disabled_modules=(languages/mod_spidermonkey
  55.                    say/mod_say_ru
  56.                    dialplans/mod_dialplan_asterisk)
  57.  
  58. # CONCURRENT BOOTSTRAP
  59. # Uncomment this to enable backgrounded concurrent bootstrap operations.
  60. # You will suffer a lot of autotools scroll from this, Fair Warning.
  61.  
  62. #_concurrent="-j"
  63.  
  64. # BUILD CONFIGURATION ENDS                     #
  65. #                                              #
  66. # CHANGE ANYTHING BELOW HERE AT YOUR OWN RISK! #
  67. #                                              #
  68.  
  69.  
  70. pkgname=freeswitch-git
  71. pkgver=1.5.7.r2590.g46cf8a4
  72. pkgrel=3
  73. pkgdesc="An opensource and free (libre, price) telephony system, similar to Asterisk."
  74. arch=('i686' 'x86_64')
  75. url="http://freeswitch.org/"
  76. license=('MPL')
  77. depends=('curl' 'xz' 'python' 'libtheora' 'unixodbc' 'libvorbis' 'speex' 'libjpeg-turbo' 'postgresql-libs')
  78. # per https://wiki.freeswitch.org/wiki/FreeSwitch_Dependencies, dependencies are downloaded and built *from upstream*, so thankfully the deps are pretty minimal.
  79. makedepends=('git' 'libjpeg' 'libedit' 'ldns' 'curl' 'python2' 'unixodbc' 'sed' 'make')
  80. # per https://aur.archlinux.org/packages/freeswitch-fixed/ 2014-08-13 14:02 comment, enable this when freetdm is packaged.
  81. # freetdm will require libsangoma, wanpipe, libsng_isdn, libpri. see http://wiki.freeswitch.org/wiki/FreeTDM#Dependencies ; links below
  82. # http://wiki.sangoma.com/wanpipe-linux-drivers
  83. # http://downloads.asterisk.org/pub/telephony/libpri/releases
  84. optdepends=('libilbc-git: Support for the iLBC codec')
  85. provides=('freeswitch')
  86. conflicts=('freeswitch' 'freeswitch-fixed')
  87. install=freeswitch.install
  88. backup=('etc/freeswitch/private/passwords.xml' 'etc/freeswitch/vars.xml')
  89. source=('git+https://stash.freeswitch.org/scm/fs/freeswitch.git' 'freeswitch.conf.d' 'README.freeswitch' 'run.freeswitch' 'run_log.freeswitch' 'conf_log.freeswitch' 'freeswitch.service')
  90. changelog='ChangeLog'
  91. _pkgname="freeswitch"
  92.  
  93. ## HAH. autoincrement.
  94. pkgver() {
  95.   cd "${srcdir}/${_pkgname}"
  96.   git describe --long | sed -r 's/^v//;s/([^-]*-g)/r\1/;s/-/./g'
  97. }
  98.  
  99.  
  100. _pathorig=${PATH}
  101.  
  102. enable_module() {
  103.   _fs_mod=${1}
  104.   sed -i -e "s|^#${_fs_mod}|${_fs_mod}|" modules.conf
  105. }
  106.  
  107. disable_module() {
  108.   _fs_mod=${1}
  109.   sed -i -e "s|^${_fs_mod}|#${_fs_mod}|" modules.conf
  110. }
  111.  
  112. build() {
  113.   mkdir -p /var/tmp/bin
  114.   ln -sf /usr/bin/python2 /var/tmp/bin/python
  115.   PATH="/var/tmp/bin:${PATH}"
  116.   cd ${srcdir}/${_pkgname}
  117.  
  118.   # BUILD BEGINS
  119.   msg "Bootstrapping..."
  120.   ./bootstrap.sh ${_concurrent} > /dev/null
  121.   msg "Bootstrap Complete"
  122.  
  123.   # MODULE ENABLE/DISABLE
  124.   for _mod in ${_enabled_modules[@]};do
  125.     msg "Enabling ${_mod}"
  126.     enable_module ${_mod}
  127.   done
  128.  
  129.   for _mod in ${_disabled_modules[@]};do
  130.     msg "Disabling ${_mod}"
  131.     disable_module ${_mod}
  132.   done
  133.  
  134.   msg "Module Configuration Complete, Stop Now with Ctrl-C if the above is not correct"
  135.   sleep 5
  136.  
  137.   # SED FIXES
  138.    sed -i -e '/if\ test\ "\$ac_cv_gcc_supports_w_no_unused_result"\ =\ yes;\ then/,+2d' configure.ac
  139.    #sed -i -e '/\ _BSD_SOURCE$/d' src/include/switch.h
  140.  
  141.   # CONFIGURE
  142.   ./configure --prefix=/var/lib/freeswitch --with-python=/usr/bin/python2 \
  143.     --bindir=/usr/bin --sbindir=/usr/sbin --localstatedir=/var \
  144.     --sysconfdir=/etc --datarootdir=/usr/share \
  145.     --libexecdir=/usr/lib/freeswitch --libdir=/usr/lib/freeswitch \
  146.     --includedir=/usr/include/freeswitch --enable-core-odbc-support \
  147.     --with-recordingsdir=/var/spool/freeswitch/recordings \
  148.     --with-dbdir=/var/spool/freeswitch/db \
  149.     --with-pkgconfigdir=/usr/lib/pkgconfig \
  150.     --with-logfiledir=/var/log/freeswitch \
  151.     --with-modinstdir=/usr/lib/freeswitch/mod \
  152.     --with-rundir=/run/freeswitch
  153.  
  154.   # COMPILE
  155.   make
  156.  
  157.   PATH=${_pathorig}
  158.   rm -f /var/tmp/bin/python
  159.   rmdir /var/tmp/bin
  160. }
  161.  
  162. enable_mod_xml() {
  163.   _fs_mod=$(basename $1)
  164.  
  165.   if [ "x$(grep ${_fs_mod} ${pkgdir}/etc/freeswitch/autoload_configs/modules.conf.xml)" == "x" ];then
  166.     msg "Adding missing module ${_fs_mod} to modules.conf.xml"
  167.     sed -i -e "s|^\(\s*</modules>\)|\t\t<\!-- added by archlinux package -->\n\t\t<load module=\"${_fs_mod}\"/>\n\1|" \
  168.       "${pkgdir}/etc/freeswitch/autoload_configs/modules.conf.xml"
  169.   else
  170.     msg "Enabling module ${_fs_mod} in modules.conf.xml"
  171.     sed -i -e "s|^\(\s*\)<\!--\s*\(<load module=\"${_fs_mod}\"/>\)\s*-->|\1\2|" \
  172.       "${pkgdir}/etc/freeswitch/autoload_configs/modules.conf.xml"
  173.   fi
  174.  
  175. }
  176.  
  177. disable_mod_xml() {
  178.   _fs_mod=$(basename $1)
  179.   msg "Disabling module ${_fs_mod} in modules.conf.xml"
  180.   sed -i -e "s|^\(\s*\)\(<load module=\"${_fs_mod}\"/>\)|\1<\!-- \2 -->|" \
  181.     "${pkgdir}/etc/freeswitch/autoload_configs/modules.conf.xml"
  182. }
  183.  
  184. package() {
  185.   mkdir -p /var/tmp/bin
  186.   ln -s /usr/bin/python2 /var/tmp/bin/python
  187.   PATH="/var/tmp/bin:${PATH}"
  188.   cd "${srcdir}/${_pkgname}"
  189.   make DESTDIR="${pkgdir}/" install
  190.   make DESTDIR="${pkgdir}/" ${_sounds}moh-install
  191.   make DESTDIR="${pkgdir}/" ${_sounds}sounds-install
  192.   PATH=${_pathorig}
  193.   rm -rf /var/tmp/bin/python
  194.   rmdir /var/tmp/bin
  195.  
  196.   cd ${pkgdir} # MUY IMPORTANT, $PWD is $pkgdir from here on out
  197.   # Mangle freeswitch's installed dirs into a more compliant structure,
  198.   # leaving symlinks in their place so freeswitch doesn't notice.
  199.   ln -s /var/log/freeswitch var/lib/freeswitch/log
  200.   ln -s /var/spool/freeswitch/db var/lib/freeswitch/db
  201.   ln -s /var/spool/freeswitch/recordings var/lib/freeswitch/recordings
  202.   install -D -m 0755 -d var/spool/freeswitch/storage && \
  203.     ln -s /var/spool/freeswitch/storage var/lib/freeswitch/storage
  204.   rm usr/lib/freeswitch/mod/*.la 2>/dev/null|| true
  205.   rm usr/lib/freeswitch/*.la 2>/dev/null || true
  206.   ln -s /usr/lib/freeswitch/mod var/lib/freeswitch/mod
  207.   install -D -m 0644 ${srcdir}/freeswitch.service usr/lib/systemd/system/freeswitch.service
  208.   install -D -m 0644 "${srcdir}/freeswitch.conf.d" etc/conf.d/freeswitch
  209.   install -D -m 0644 "${srcdir}/README.freeswitch" usr/share/doc/freeswitch/README
  210.   cp -a "${srcdir}/${_pkgname}/docs" usr/share/doc/freeswitch
  211.   install -D -m 0755 -d usr/share/doc/freeswitch/support-d
  212.   cp -a "${srcdir}/${_pkgname}/support-d" usr/share/doc/freeswitch/
  213.   install -D -m 0755 -d usr/share/doc/freeswitch/scripts
  214.   cp -a "${srcdir}/${_pkgname}/scripts" usr/share/doc/freeswitch/
  215.   # Copy upstream confs
  216.   install -D -m 0755 -d usr/share/doc/freeswitch/examples/conf.default
  217.   install -D -m 0755 -d usr/share/doc/freeswitch/examples/conf.archlinux
  218.   mkdir etc/freeswitch/private
  219.   echo '<X-PRE-PROCESS cmd="include" data="private/passwords.xml"/>' >> etc/freeswitch/vars.xml
  220.   echo "<X-PRE-PROCESS cmd=\"set\" data=\"default_password=$(tr -dc 0-9 < /dev/urandom | head -c10)\"/>" > etc/freeswitch/private/passwords.xml
  221.   chmod 700 etc/freeswitch/private
  222.   chmod 600 etc/freeswitch/private/passwords.xml
  223.   ln -s /etc/freeswitch var/lib/freeswitch/conf
  224.   cp -a etc/freeswitch/* usr/share/doc/freeswitch/examples/conf.default/
  225.  
  226.   for _mod in ${_enabled_modules[@]};do
  227.     enable_mod_xml $_mod
  228.   done
  229.  
  230.   for _mod in ${_disabled_modules[@]};do
  231.     disable_mod_xml $_mod
  232.   done
  233.  
  234.   mv etc/freeswitch/* usr/share/doc/freeswitch/examples/conf.archlinux/
  235.   rmdir etc/freeswitch
  236.   install -D -m0755 -d usr/share/freeswitch/conf
  237.   install -D -m 0755 "${srcdir}/run.freeswitch" usr/share/freeswitch/run
  238.   install -D -m 0755 "${srcdir}/run_log.freeswitch" usr/share/freeswitch/log/run
  239.   install -D -m 0644 "${srcdir}/conf_log.freeswitch" usr/share/freeswitch/log/conf
  240. }
  241. md5sums=('SKIP'
  242.      'f674b302edeb1895bbefcaf7bb8510ca'
  243.          'bfa0c6c70c8173bc78fd228bd42a98ef'
  244.          '4126dcbe4e1e4f689230a0fe40edcb68'
  245.          'e9f0bdde366bca6fd29a9202818f3591'
  246.          'e6411d793501c29ec4afd6d54018de1b'
  247.          '31cd89e02ec3cc52769489a30ccf6c9b')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement