Thursday, December 12, 2013

Piler on Debian Wheezy

MailPiler 0.1.24 on Debian Wheezy

I was interested in setting up an email archive server.  We need to be doing this but with budgets as they are these days we need to do it on the cheap.  MailPiler looked promising.  The directions are a little shotty for a non-linux user like me.  So the instructions below are word for word what I did with my final production server.  It took me 5 reimages of the virtual machine before I got to this point!  Like I said, non-linux user.  Hopefully these instructions will help someone else.  I used the official tar.gz, but the latest source is of interest as it includes a few of the things I had to do to get things to work right, so I would suggest you load from the source.

Install Debian Wheezy - no need to install any special packages, those will be included in the install later.

apt-get update
apt-get upgrade
apt-get autoclean
apt-get autoremove

apt-get install openssl  libssl-dev apache2 php5 php5-gd mysql-server phpmyadmin libmysqlclient-dev php5-ldap memcached php5-memcache sphinxsearch libtre-dev libzip2 libzip-dev sysstat gcc libwrap0 libwrap0-dev latex2rtf latex2html catdoc libpoppler19 poppler-utils unrtf make

nano /etc/default/sphinxsearch
Edit the section to make sure it says START="no"

a2enmod rewrite
nano /etc/apache2/sites-enabled/ooo-default
Modify all lines that are AllowOverride to All at the end.
Modify DocumentRoot to location of piler web directory. (/var/www/piler)
service apache2 restart

groupadd piler
useradd -g piler -s /bin/sh -d /var/piler piler
usermod -L piler

Then download piler from the piler download location.

tar zxvf piler-x.y.z.tar.gz
cd piler-x.y.z
./configure --localstatedir=/var --with-database=mysql --enable-starttls --enable-tcpwrappers

make install

make postinstall
root (could use default if willing to adjust more mysql permissions)

nano /usr/local/etc/piler.conf
Update the mysql section at the end with settings specific to your setup.

nano /var/www/piler/config-site.php
edit site specific information
PILER_HOST (Set to IP address of server)
(My DB info was already accurate.)

sh init.d/rc.piler start
sh init.d/rc.searchd start

If you want to add these scripts to run at boot follow the below instructions.

Copy the scripts to the init.d folder and add the scripts to boot time.
cp init.d/rc.piler /etc/init.d/
cp init.d/rc.searchd /etc/init.d
insserv rc.piler
insserv rc.searchd

Add your domain to the Administration/Domain menu. ->
Adjust the default passwords to make it secure.

Now start sending mail to the server from your email server.  I use Google Apps, so I had to add my server as a forwarder.

LDAP Authentication
nano config-site.php
$config['ENABLE_LDAP_AUTH'] = 1;
$config['LDAP_HOST'] = '***';
// set this if you want to limit the scope of the ldap query
$config['LDAP_BASE_DN'] = '';
// the helper account, see the details below
$config['LDAP_HELPER_DN'] = 'CN=...';
$config['LDAP_HELPER_PASSWORD'] = '******';
$config['LDAP_MAIL_ATTR'] = 'mail';
$config['LDAP_ACCOUNT_OBJECTCLASS'] = 'user';

$config['LDAP_DISTRIBUTIONLIST_ATTR'] = 'member';

Wednesday, December 11, 2013

Raspberry Pi Internet Radio

We have a radio in the office that gets stations sometimes, and fails sometimes.  FM signal is sketchy in my neck of the woods.

So I grabbed one my stagnant Raspberry Pi's and went about a search on Google to find instructions for an Internet Streaming Radio.

Raspberry Pi Wifi Internet Radion Player

I found this site, and although it has some issues with setup it got me going.  Here is my post on what I did using the latest Debian Wheezy for Raspberry Pi and fully updated on Dec. 11, 2013.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoclean
sudo apt-get autoremove

My favorite set of commands to get things fully updated.

sudo apt-get install mpd mpc

MPD is the music player deamon.  It does the hard work/heavy lifting.  MPC is the music player client.

sudo shutdown -r now

After a restart everything just works.  Here is a great website with all of the command line tools for using mpc.

MPC - Linux Man Page

My setup is headless and actually sitting in the switch closet connected to an audio cable to the surround sound amp.

sudo apt-get install php5

Below is my php code that I created to control mpc from a webpage.  Why ssh into the system when you can keep the website open and control it from there?

exec("mpc toggle");
exec("mpc stop | mpc clear");
exec("mpc add");
}else if($_POST['s']==2){
exec("mpc add");
}else if($_POST['s']==3){
exec("mpc add");
exec("mpc play | mpc volume 90");
if(isset($_POST['v']) || isset($_POST['vol'])){
if($_POST['v']!=""){$vol = $_POST['v'];}
if($_POST['vol']!=""){$vol = $_POST['vol'];}
exec("mpc volume ".$vol);
<!DOCTYPE html><html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="30" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<title>DO Radio</title>
<style type="text/css">
<h1>District Office Radio</h1>
echo "<h3>".exec("mpc -f '%name%' current")."</h3>";
echo "<h2>".exec("mpc -f '[[%artist% ]%title%' current")."</h2>";
<form action="index.php" method="post">
<button type="submit" name="p">Play/Pause</button><br /><br />
$vol = exec("mpc volume");
echo substr($vol,strpos($vol,":")+1);
?></h4><br />
<button type="submit" name="v" value="-10">-10</button>
<button type="submit" name="v" value="-1">-1</button>
<button type="submit" name="v" value="+1">+1</button>
<button type="submit" name="v" value="+10">+10</button>
<br />
<input type="text" name="vol" /><input type="submit" value="Submit" /><br />
<br /><br />
<button type="submit" name="s" value="1">KHTR 104.3</button><br />
<button type="submit" name="s" value="2">The Christmas Station</button><br />
<button type="submit" name="s" value="3">NOAA Weather - Spokane, WA</button><br />

I have actually added a bunch of more radio stations, just grabbed the stream address from this website: