#!/usr/bin/php
<?php
/*
  vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
  Codificación: UTF-8
  +----------------------------------------------------------------------+
  | Issabel version 4.0                                                  |
  | http://www.issabel.org                                               |
  +----------------------------------------------------------------------+
  | Copyright (c) 2006 Palosanto Solutions S. A.                         |
  +----------------------------------------------------------------------+
  | The contents of this file are subject to the General Public License  |
  | (GPL) Version 2 (the "License"); you may not use this file except in |
  | compliance with the License. You may obtain a copy of the License at |
  | http://www.opensource.org/licenses/gpl-license.php                   |
  |                                                                      |
  | Software distributed under the License is distributed on an "AS IS"  |
  | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See  |
  | the License for the specific language governing rights and           |
  | limitations under the License.                                       |
  +----------------------------------------------------------------------+
  | The Initial Developer of the Original Code is PaloSanto Solutions    |
  +----------------------------------------------------------------------+
*/

/* Write whatever we have in stdin to /etc/issabel.key, then set chown 600 
 * asterisk.asterisk on it*/ 

if(is_file("/etc/elastix.key")) {
    if(!is_file("/etc/issabel.key")) {
        rename("/etc/elastix.key","/etc/issabel.key");
    } else {
        unlink("/etc/elastix.key");
    }
}

if(!is_file("/etc/issabel.key")) {
    chmod('/etc/issabel.key', 0600);
    chown('/etc/issabel.key', 'asterisk');
    chgrp('/etc/issabel.key', 'asterisk');
}
?>
