View previous topic :: View next topic |
Author |
Message |
Anonymous Guest
|
Posted: Tue Aug 09, 2005 2:20 am Post subject: Ices Reload PHP Script |
|
|
Code: |
<?php
/********************************************************/
/* Version .03 */
/* William J. Galway */
/* http://www.galwayland.com */
/* */
/* .03 Released 8-Aug-2005 */
/* Changed exec("ps -A | grep ices | cut -c 0-6") */
/* to exec("ps -o \"%p\" --noheaders -C ices") */
/* Thanks Jens.. */
/* */
/* .02 Released 21-Jul-2005 */
/* ------------------------ */
/* Ices attempts to start only if Icecast is running. */
/* Fixed Ices Running But Could not Be loaded */
/* Condition. */
/* Cleaned up code. */
/* */
/* .01 Initial Release 18-Jul-2005 */
/* ------------------------------- */
/* */
/********************************************************/
header("Cache-Control: no-store, no-cache");
error_reporting(E_ALL);
$ICECAST_LOG_DIR = "/usr/local/var/log/icecast/";
$ICECAST_LOG_FILE = "playlist.log";
$ICECAST_SERVER = "http://www.galwayland.com";
$ICECAST_PORT = "8081";
$ICECAST_MOUNT_POINT = "/tunes.m3u";
/*--------------*/
/* Header */
/*--------------*/
echo "<a href=\"http://www.galwayland.com/admin.php?op=IcecastAdmin\">Return to Icecast Admin</a><br><br>";
$date = date("l dS of F Y h:i:s A");
echo "$date<br>";
/*----------------------*/
/* Reload Ices */
/*----------------------*/
echo "---------------------------------------------<br>";
$pid = exec("ps -o \"%p\" --noheaders -C ices");
if ($pid >=1) {
echo "Ices Running On PID $pid <br>";
echo "Sending SIGINT to Stop Ices<br>";
echo "kill -s INT $pid <br>";
echo exec("kill -s INT $pid 2>&1 ", $out, $error);
sleep (3);
}
/* Starting Ices */
$pid2 = exec("ps -o \"%p\" --noheaders -C ices");
$pidicecast = exec("ps -o \"%p\" --noheaders -C icecast");
if ($pid2 <=1 and $pidicecast >=1) {
$handle = popen('ices -c /usr/local/etc/ices.conf 2>&1', 'r');
$read = fread($handle, 1024);
echo "<pre>$read</pre><br>";
pclose($handle);
sleep(3);
}
echo "<br>";
echo "---------------------------------------------<br>";
/*******************/
/* Checking Status */
/*******************/
echo "<br><br>";
echo "--------------------<br>";
echo "---Ices Status---<br>";
echo "--------------------<br>";
$pid3 = exec("ps -o \"%p\" --noheaders -C ices");
if ($pid <=1 && $pid3 >=1) {
echo "Ices Started<br>";
}
if ($pid >=1 && $pid3 > $pid) {
echo "Ices Reloaded<br>";
}
if ($pid >=1 && $pid==$pid3) {
echo "Ices Running But Could Not Be Reloaded<br>";
}
if ($pid3 >=1) {
sleep (10);
# The line below limited this file to Unix only. It has been replaced
# by the line below that.
#$lastsong_in_log = exec("tail -n 1 ".$ICECAST_LOG_DIR.$ICECAST_LOG_FILE);
$log_array = @file($ICECAST_LOG_DIR.$ICECAST_LOG_FILE);
$lastsong_in_log = $log_array[(count($log_array) - 1)];
$curr_song = explode("|",$lastsong_in_log);
echo "Ices Running On PID $pid3<br>";
echo "Ices Now Playing   <a href=\"".$ICECAST_SERVER.":".$ICECAST_PORT.$ICECAST_MOUNT_POINT."\">";
echo $curr_song[(count($curr_song) - 1)];
echo "</a><br>";
}
else {
echo "Ices Not Running...Failed to Reload";
}
?>
|
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group subRebel style by ktauber
|