Pogoplug: Debian extra programs

# configure hostname
echo hs > /etc/hostname
 
# congigure network
mv /etc/network/interfaces /etc/network/interfaces.org
cat <<EOF> /etc/network/interfaces
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
address 192.168.2.1
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.254
dns-nameservers 192.168.2.254
dns-search panticz
EOF
 
# configure dns
cat <<EOF> /etc/resolv.conf
search panticz
nameserver 192.168.2.254
EOF
 
# install dhcp server
apt-get install -y dhcp3-server
mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.org
cat <<EOF> /etc/dhcp/dhcpd.conf 
default-lease-time 86400;
max-lease-time 172800;
ddns-update-style none;
option domain-name "panticz";
option domain-name-servers 192.168.2.254;
option broadcast-address 192.168.2.255;
option routers 192.168.2.254;
option subnet-mask 255.255.255.0;
option root-path "192.168.2.1:/var/lib/tftpboot";
use-host-decl-names on;
next-server 192.168.2.1;
authoritative;
 
subnet 192.168.2.0 netmask 255.255.255.0 {
    range 192.168.2.100 192.168.2.200;
    filename "pxelinux.0";
}
 
host xbmc {
    hardware ethernet 00:25:22:b4:d9:dd;
    fixed-address 192.168.2.3;
    option host-name "xbmc";
}
EOF
/etc/init.d/isc-dhcp-server restart
 
# configure mounts
mkdir /export /export/hs /export/xbmc /export/music /export/video /export/image /export/openelec
cat <<EOF>> /etc/fstab
/dev/sdb1       /media           ext4    defaults   0 0
/media          /export/hs       none    bind       0 0
#/media/xbmc    /export/xbmc     none    bind       0 0
/media/mp3      /export/music    none    bind       0 0
/media/video    /export/video    none    bind       0 0
/media/images   /export/image    none    bind       0 0
/media/openelec /export/openelec none    bind       0 0
EOF
mount -a
 
# configure nfs
# do we need this? # echo 65536 > /proc/fs/nfsd/max_block_size
apt-get install -y nfs-kernel-server
mv /etc/exports /etc/exports.org
cat <<EOF> /etc/exports
/export                 192.168.2.0/24(rw,fsid=0,insecure,no_subtree_check,async)
/export/hs              192.168.2.0/24(rw,nohide,insecure,no_subtree_check,async)
/export/xbmc            192.168.2.0/24(rw,nohide,insecure,no_subtree_check,async)
/export/music           192.168.2.0/24(rw,nohide,insecure,no_subtree_check,async)
/export/video           192.168.2.0/24(rw,nohide,insecure,no_subtree_check,async)
/export/image           192.168.2.0/24(rw,nohide,insecure,no_subtree_check,async)
/export/openelec        192.168.2.0/24(rw,nohide,insecure,no_subtree_check,async)
/var/lib/tftpboot/xbmc  192.168.2.0/24(ro,sync,no_subtree_check)
EOF
/etc/init.d/nfs-kernel-server restart
 
# install tftp-hpa
sudo debconf-set-selections <<\EOF
tftpd-hpa tftpd-hpa/directory string /var/lib/tftpboot
EOF
 
apt-get install -y tftpd-hpa #--force-yes
mv /var/lib/tftpboot /var/lib/tftpboot.old
ln -s /media/tftpboot /var/lib/tftpboot
/etc/init.d/tftpd-hpa restart
 
# install rsync
apt-get install -y rsync bzip2
 
# hdparm
apt-get install -y hdparm
cat <<EOF>> /etc/hdparm.conf
/dev/sda {
   spindown_time = 240
}
EOF
 
# install printserver - http://www.panticz.de/node/416
apt-get install python
wget http://launchpadlibrarian.net/14035814/jetpipe -O /usr/sbin/jetpipe
chmod a+x /usr/sbin/jetpipe
 
cat <<EOF> /etc/udev/rules.d/90-printer.rules 
KERNEL=="lp*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0482", ACTION=="add", RUN+="/usr/sbin/jetpipe /dev/usb/lp0 9100"
EOF
 
# install minidlna - http://www.panticz.de/Install-MiniDLNA
echo "deb http://ftp.de.debian.org/debian sid main" > /etc/apt/sources.list.d/sid.list
apt-get update
apt-get install -y minidlna
rm /etc/apt/sources.list.d/sid.list
 
# OPTIONAL: configure for Yamaha RX-V3800
sed -i 's|#notify_interval=895|notify_interval=86400|g' /etc/minidlna.conf
 
# do we need this?
mkdir /run/minidlna
sed -i "s|#friendly_name=|friendly_name=$(cat /etc/hostname)|g" /etc/minidlna.conf
echo "media_dir=A,/media/mp3/_einzellieder" >> /etc/minidlna.conf
 
/etc/init.d/minidlna restart
 
 
cat <<EOF> /etc/init.d/ntpdate
#!/bin/sh -e
 
# Provides:          ntpdate
# Required-Start:    $remote_fs $network $syslog
# Required-Stop:     $remote_fs $network $syslog
# Should-Start:      $local_fs slapd $named
# Should-Stop:       $local_fs slapd
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
 
case "$1" in
  start)
    # update date on boot
    ntpdate ntp.ubuntu.com
  ;;
esac
 
exit 0
EOF
 
chmod a+rx /etc/init.d/ntpdate
update-rc.d ntpdate defaults 99
 
/etc/rc.local
echo 65536 > /proc/sys/fs/inotify/max_user_watches
 
 
#
# OLD
#
## config rc
#cp /etc/rc.local /etc/rc.local.org
 
#cat <<EOF> /etc/rc.local
##!/bin/sh -e
#mount -a
#/etc/init.d/nfs-kernel-server restart
#mkdir -p /var/cache/apt/archives/partial
#exit 0
#EOF
# screen hddtemp smartmontools
 
locale-gen en_US.UTF-8
echo LANG=en_US.UTF-8 >> /etc/environment
echo LC_ALL=en_US.UTF-8 >> /etc/environment
 
 
# install ssh server (alredy installed?)
#apt-get install -y openssh-server
 
# sed -i 's|RUN_DAEMON="no"|RUN_DAEMON="yes"|g' /etc/default/tftpd-hpa
#sed -i 's|INTERFACES=""|INTERFACES="eth0"|g' /etc/default/isc-dhcp-server 
# create soft links
 
# delete ttys
#rm /etc/event.d/tty6
#rm /etc/event.d/tty5
#rm /etc/event.d/tty4
#rm /etc/event.d/tty3
#rm /etc/event.d/tty2
#rm /etc/event.d/tty1
 
# todo
# ftp
# rc.local