Skip to content

Instantly share code, notes, and snippets.

@chrisstaite
chrisstaite / stream.php
Created June 22, 2016 20:05
PHP script to load balance between Icecast servers using 302 redirect
<?php
// This is a very noddy script to do 302 redirects to load balance between servers
// as listeners connect. It does no caching, supports a single stream only and requires
// Icecast 2.4 or above (because it uses the status-json.xsl page).
// The server, the minimum users before load balancing, the maximum users, the servers
// are considered in order from top to bottom
$servers = array(
array("http://server1:8000/", 10, 100),
@chrisstaite
chrisstaite / update_ipv6.sh
Last active October 3, 2020 21:39
Update /etc/hosts with IPv6 addresses given their IPv4 hostname
#!/bin/sh
zeroize_macaddrs ()
{
sed -e 's/\(\s\)\([0-9a-f]\):/\10\2:/' -e 's/\([^0-9a-f]\)\([0-9a-f]\):/\10\2:/g' -e 's/:\([0-9a-f]\)$/:0\1/'
}
find_ip4 ()
{
grep 'on-dhcp-event' /etc/hosts | zeroize_macaddrs | grep "$1" | while read ip dns _ mac ; do