Initial commit

tags/0.1.0
Daniel Berteaud 13 years ago
commit c173c7e399
  1. 6
      createlinks
  2. 1
      root/etc/e-smith/db/configuration/defaults/callback/Host
  3. 1
      root/etc/e-smith/db/configuration/defaults/callback/User
  4. 1
      root/etc/e-smith/db/configuration/defaults/callback/access
  5. 1
      root/etc/e-smith/db/configuration/defaults/callback/status
  6. 1
      root/etc/e-smith/db/configuration/defaults/callback/type
  7. 31
      root/etc/e-smith/db/configuration/migrate/callback-secret
  8. 3
      root/etc/e-smith/templates.metadata/etc/callback/callback.conf
  9. 6
      root/etc/e-smith/templates/etc/callback/callback.conf/All
  10. 31
      root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98CallBack
  11. 55
      root/usr/share/callback/cgi-bin/callback.cgi
  12. 1
      root/usr/share/callback/index.html
  13. 58
      smeserver-callback.spec

@ -0,0 +1,6 @@
#!/usr/bin/perl -w
use esmith::Build::CreateLinks qw(:all);
templates2events("/etc/callback/callback.conf", qw(webapps-update bootstrape-ldap-save));

@ -0,0 +1,31 @@
{
my $rec = $DB->get('callback')
|| $DB->new_record('callback', {type => 'webapp'});
my $pw = $rec->prop('Secret');
if (not $pw or length($pw) < 30)
{
use MIME::Base64 qw(encode_base64);
$pw = "not set due to error";
if ( open( RANDOM, "/dev/urandom" ) )
{
my $buf;
if ( read( RANDOM, $buf, 30 ) != 30 )
{
warn("Short read from /dev/random: $!");
}
else
{
$pw = encode_base64($buf);
chomp $pw;
}
close RANDOM;
}
else
{
warn "Could not open /dev/urandom: $!";
}
$rec->set_prop('Secret', $pw);
}
}

@ -0,0 +1,6 @@
$host = "{$callback{'Host'} || '127.0.0.1';}";
$port = "{$callback{'Port'} || '5038';}";
$user = "{$callback{'User'} || 'callback';}";
$secret = "{$callback{'Secret'} || 'secret';}";
1

@ -0,0 +1,31 @@
{
my $access = $callback{'access'} || 'private';
my $allow = ($access eq 'public')?'all':"$localAccess $externalSSLAccess";
my $requiressl = (($callback{'RequireSSL'} || 'yes') eq 'yes') ?
"SSLRequireSSL on":"# RequireSSL is disabled";
my $alias = (($callback{'AliasOnPrimary'} || 'enabled') eq 'enabled') ?
'ScriptAlias /callback /usr/share/callback/cgi-bin/callback.cgi' : '';
if ($callback{'status'} eq 'enabled'){
$OUT .=<<"END"
# Callback Configuration
$alias
<Directory /usr/share/callback/cgi-bin/>
SetHandler cgi-script
Options ExecCGI
AllowOverride None
$requiressl
order deny,allow
deny from all
allow from $allow
</Directory>
END
}
else{
$OUT .= "# CallBack is disabled\n";
}
}

@ -0,0 +1,55 @@
#!/usr/bin/perl -w
use Asterisk::AMI;
use CGI qw/:standard/;
require ('/etc/callback/callback.conf');
$host ||= '127.0.0.1';
$port ||= '5038';
$user ||= 'callback';
$secret ||= 'secret';
my $q = new CGI;
print $q->header,
$q->start_html(-title=>'CallBack',
),
$q->h1('page de callback'),
$q->start_form,
"Entrez ici votre numero ",textfield('nback'),p,
"Entrez ici le numero de votre destinataire ", textfield('ndest'),p,
$q->submit,
$q->end_form,
$q->hr;
if ($q->param()) {
my $nback = $q->param('nback') || $ENV{'HTTP_USER_EXTENSION'};
my $ndest = $q->param('ndest');
$nback =~ s/[\s\(\)\.<>]//g;
$ndest =~ s/[\s\(\)\.<>]//g;
unless (($nback =~ m/^\d+$/) && ($ndest =~ m/^\d+$/)){
print $q->h1('un des numeros ne semble pas valide, ils ne doivent contenir que des chiffres');
die ('bad number');
}
my $astman = Asterisk::AMI->new(PeerAddr => "$host",
PeerPort => "$port",
Username => "$user",
Secret => "$secret"
);
die "Unable to connect to asterisk" unless ($astman);
my $response = $astman->action({Action => 'Originate',
Channel => "Local/$nback\@from-internal",
Context => 'from-internal',
CallerID => $ndest,
Exten => $ndest,
Priority => 1});
}

@ -0,0 +1 @@
<META http-equiv="Refresh" content="0; URL=/cgi-bin/callback.cgi">

@ -0,0 +1,58 @@
Summary: A small page to originate calls through an asterisk server
%define name smeserver-callback
Name: %{name}
%define version 0.1
%define release 0.beta3
Version: %{version}
Release: %{release}%{?dist}
License: GPL
Group: Applications/System
Source: %{name}-%{version}.tar.gz
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot
BuildArch: noarch
BuildRequires: e-smith-devtools
Requires: e-smith-base
Requires: smeserver-webapps-common
Requires: perl(Asterisk::AMI)
%description
This package contains all the needed scripts and templates
to run the callback form
%changelog
* Fri Nov 18 2011 Daniel Berteaud <daniel@firewall-services.com> - 0.1
- Initiale release
%prep
%setup -q -n %{name}-%{version}
%build
perl createlinks
%{__mkdir_p} root/etc/callback
%install
/bin/rm -rf $RPM_BUILD_ROOT
(cd root ; /usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT)
/bin/rm -f %{name}-%{version}-filelist
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \
--file /usr/share/callback/cgi-bin/callback.cgi 'attr(0750,root,www)' \
> %{name}-%{version}-filelist
%files -f %{name}-%{version}-filelist
%defattr(-,root,root)
%clean
rm -rf $RPM_BUILD_ROOT
%post
%preun
true
Loading…
Cancel
Save