#!/bin/bash
# Copyright (c) 1997-2009, NeoNova BV, The Netherlands. All rights Reserved.
#
# This software is the copyrighted work of NeoNova BV.
# Use of the software is subject to the general business terms and conditions of NeoNova BV
# and its related transaction documents like license sheets or other written notices.
#
# Any reproduction or redistribution of the software not in accordance with the license terms
# is expressly prohibited by law, and may result in severe civil and criminally penalties.
# Violators will be prosecuted to the maximum extent possible.

if [ $# -eq 1 ]
then
  cd /var/lib/asterisk/keys
  name=company-$1
  /usr/sbin/astgenkey -q -n $name
  PUB=`cat $name.pub`
  KEY=`cat $name.key`
  echo "update company set astprivatekey = '$KEY', astpublickey = '$PUB' where id = '$1'" | psql -U astium
fi

