<?php

if ($_SERVER['argc'] < 2) {
	die("usage: php calendar_change_port.php [port]\n");
}

$port = $_SERVER['argv'][1];

if (!is_numeric($port)) {
        die("port must numeric\n\nusage: php calendar_change_port.php [port]\n");
}

require_once(dirname(dirname(dirname(__FILE__))) . "/library/Atmail/Apache_Utility.php");

$confPath = webserverFindConfig();

$basePath = dirname($confPath);
$davConf = "$basePath/conf.d/atmail-dav.php";

if (file_exists($davConf)) {
	$confPath = $davConf;
}

webserverBackupConf($confPath);
webserverEditConf($confPath, "Listen 8008", "Listen $port");
webserverEditConf($confPath, ":8008>", ":$port>");

