OpenWRT FullInstall
Talk0
544pages on
this wiki
this wiki
These are notes that i typed in when did this procedure, if there's something i missed or if there's something that doesn't work for you please comment at and let know.
# How to install phpMp2 on an ASUS WL500gx router by Dominic clifton / Hydra
# ==========================================================================
# Requirements:
# * ASUS WL500gx
(otherwise known as WL500g-Deluxe, buy them in the uk from www.scan.co.uk )
# * A supported USB Sound card, check hardware compatability lists on openwrt wiki)
# possible sources are ebay: search for "USB Audio", they look like pen drives
# * A supported USB 2 external hard drive enclosure fitted with a hard drive
# unplug all cables from your new wl500gx except power cable
# reset to defaults - hold the power button down for 20 seconds until
power light flashes quickly
# unplug power from router
# hold down reset button on back of router and plug in the power - keeping
the reset button
# held down until the power light flashes slowly.
# connect a network cable lead from your pc to any of your router's LAN ports
(not the WAN port)
# issue this command on your windows box:
ping -t 192.168.1.1
# wait till you get a responce - leave the ping running!
# download this file
# http://downloads.openwrt.org/people/nbd/whiterussian/openwrt-brcm-2.4-jffs2-4MB.trx
# issue this command on your windows box from another command prompt
tftp -i 192.168.1.1 PUT openwrt-brcm-2.4-jffs2-4MB.trx
# this should transfer the new firmware, after a while the ping in the other
window will fail.
# wait about 60 seconds while the firmware is flashed to the router (you get no display..)
# if you reboot too quickly the just repeat from the ping above and flash again
# get putty and connect via telnet to 192.168.1.1
reboot
# after a reboot connect via telnet and we'll update a few things
mtd erase nvram
reboot
# after you've done this setup your network as required.
# you should be able to do this from http://192.168.1.1
# i do that and then i bridge all the WAN, LAN and the wifi together on mine,
but you don't need to
# i do it like this if you're interested.
nvram set lan_ipaddr=192.168.128.3
nvram set lan_gateway=192.168.128.1
nvram set lan_netmask=255.255.255.0
nvram set lan_proto=static
nvram set lan_ifnames="vlan0 vlan1 eth1"
nvram set wan_ifname="none"
nvram set wan_hostname=wl500gx
nvram commit
reboot
# update the core system
ipkg update
ipkg install ipkg
ipkg upgrade
ipkg install dnsmasq
# edit your dns/dhcp settings if required.
vi /etc/dnsmasq.conf
# update our ipkg config
vi /etc/ipkg.conf
=== add this before the first "dest" line ===
src nico http://downloads.openwrt.org/people/nico/testing/mipsel-2.4/packages
src nico-testing http://openwrt.org/downloads/people/nico/testing/mipsel/packages
=== add end ===
# backup our ipkg config
cp /etc/ipkg.conf /etc/ipkg.conf.orig
# install some kernal modules that we need for USB and filesystem support
ipkg install kmod-usb-core
ipkg install kmod-usb2
ipkg install kmod-usb-storage
ipkg install kmod-usb-uhci
ipkg install kmod-ext2
ipkg install kmod-ext3
ipkg install kmod-vfat
# set a password on our router
passwd
# we need to reboot now and shutdown now
reboot
# quickly unlug the power cable
# plug in your USB2 hard drive
# after this reboot you'll not be able to telnet to the router, you have to use ssh
# use putty again and connect up.
ipkg install fdisk
ipkg install e2fsprogs
ipkg install swap-utils
fdisk /dev/discs/disc0/disc
# partition as follows
Device Boot Start End Blocks Id System
/dev/discs/disc0/part1 1 523 4200966 83 Linux
/dev/discs/disc0/part2 524 654 1052257+ 82 Linux swap / Solaris
/dev/discs/disc0/part3 655 4865 33824857+ c W95 FAT32 (LBA)
# the last partition can be any type you like, but since this is a removable
hdd then we
# make our lives easier by making it fat32/vfat and format it under windows
# issue this so mk2fs doesn't fail
cp /proc/mounts /etc/mtab
# format the linux ext3 partition
mke2fs -j /dev/discs/disc0/part1
# if you're using a drive with existing partitions use umount to unmount thigns
as required.
# now we can mount our new partition
mount -t ext3 /dev/discs/disc0/part1 /mnt
# setup some swap space
mkswap /dev/discs/disc0/part2
# activate it - note, it doesn't get reactivated after a reboot, yet.
swapon /dev/discs/disc0/part2
# make some folders
mkdir -p /usb /mnt
# copy everything from to the usb device
tar cvO -C / bin/ etc/ lib/ sbin/ usr/ www/ var/ | tar x -C /mnt
# make more folders
mkdir -p /mnt/tmp && mkdir -p /mnt/dev && mkdir -p /mnt/proc && mkdir -p /mnt/jffs
# unmount the usb drive
umount /mnt
# remove /sbin/init
rm /sbin/init
# replace it with this script:
vi /sbin/init
=== add start ===
#!/bin/sh
# change this to your boot partition
boot_dev="/dev/scsi/host0/bus0/target0/lun0/part1"
# install needed modules for usb and the filesystems
insmod usbcore
insmod uhci && sleep 2s
# insmod ehci-hcd && sleep 2s
insmod scsi_mod && insmod sd_mod && insmod sg && insmod usb-storage
insmod ext2 && insmod jbd && insmod ext3
sleep 2s
# mount the usb stick
mount -t ext3 -o rw "$boot_dev" /usb
# if everything looks ok, do the pivot root
if [ -x /usb/sbin/init ] && [ -d /usb/jffs ]; then
pivot_root /usb /usb/jffs
mount none /proc -t proc
mount none /dev -t devfs
mount none /tmp -t tmpfs size=50%
mkdir -p /dev/pts
mount none /dev/pts -t devpts
umount /jffs/proc /jffs/dev/pts
sleep 1s
umount /jffs/tmp /jffs/dev
fi
# finally, run the real init (from USB hopefully).
exec /bin/busybox init
=== add end ===
# make sure it's executable
chmod a+x /sbin/init
# reboot!
reboot
# hopefully the system will boot off the usb drive instead of the flash rom
# log back in and check using mount
mount
# the output should be something like this:
/dev/root on /jffs type jffs2 (rw)
none on /jffs/dev type devfs (rw)
none on /jffs/proc type proc (rw)
none on /jffs/proc/bus/usb type usbfs (rw)
/dev/scsi/host0/bus0/target0/lun0/part1 on / type ext3 (rw) #<---important line
none on /proc type proc (rw)
none on /dev type devfs (rw)
none on /tmp type tmpfs (rw)
none on /dev/pts type devpts (rw)
none on /proc/bus/usb type usbfs (rw)
# now that's ok we can make it so we automatically enable the swap space
vi /etc/init.d/S10boot
=== add this line before first ifconfig line ===
#activate swap
swapon /dev/discs/disc0/part2
=== add end ===
# i have a fancy resolv.conf which has some search domains in which can't be
set via the web interface so
# i edit it, and then make a backup of it.
vi /etc/resolv.conf
cp /etc/resolv.conf /etc/resolv.conf.orig
# after a reboot /etc/resolv.conf is lost so i need to automatically have
it restored
# from /etc/resolv.conf.orig
vi /etc/init.d/S40network
=== add this line before the line with two ;;'s on ===
cp /etc/resolv.conf.orig /etc/resolv.conf
=== add end ===
# reboot to make sure things are ok
reboot
# after we're back in the shell type in
free
# output should be similar to this:
total used free shared buffers
Mem: 30584 11368 19216 0 980
Swap: 1236996 0 1236996 # <--- the important line
Total: 1267580 11368 1256212
# anyway, network settings done for now. onto the good stuff
# plug in your USB sound card
# install USB sound card drivers
ipkg install kmod-soundcore -nodeps
ipkg install kmod-usb-audio -nodeps
reboot (or insmod soundcore && insmod audio)
# run dmesg to see if your audio card was recognised
dmesg
# output should be similar to this:
usb.c: registered new driver audio
usbaudio: device 2 audiocontrol interface 0 has 1 input and 1 output
AudioStreaming interfaces
usbaudio: device 2 interface 2 altsetting 1 channels 1 framesize 2 configured
usbaudio: valid input sample rate 48000
usbaudio: valid input sample rate 44100
usbaudio: device 2 interface 2 altsetting 1: format 0x00000010 sratelo 44100 sratehi 48000 attributes 0x01
usbaudio: device 2 interface 1 altsetting 0 does not have an endpoint
usbaudio: device 2 interface 1 altsetting 1 channels 2 framesize 2 configured
usbaudio: valid output sample rate 48000
usbaudio: valid output sample rate 44100
usbaudio: device 2 interface 1 altsetting 1: format 0x01000010 sratelo 44100 sratehi 48000 attributes 0x01
usbaudio: registered dsp 14,3
usbaudio: constructing mixer for Terminal 6 type 0x0301
usbaudio: warning: found 1 of 2 logical channels.
usbaudio: assuming that a stereo channel connected directly to a mixer is
missing in search (got Labtec headset?). Should be fine.
usbaudio: registered mixer 14,0
usbaudio: constructing mixer for Terminal 7 type 0x0101
usbaudio: registered mixer 14,16
usb_audio_parsecontrol: usb_audio_state at 811803c0
audio.c: v1.0.0:USB Audio Class driver
#you should now see files in /dev/sound/dsp
ls /dev/sound/
# output should be similar to this:
dsp mixer mixer1
# ok, sound is go! now back to the hard drive for a bit
mkdir /usr/share/ftproot1
vi /etc/fstab
=== create as follows ===
/dev/discs/disc0/part3 /usr/share/ftproot1 vfat defaults 0 0
=== create end ===
mount -a
# make it so the fat32 partition mounts upon reboot as follows
vi /etc/init.d/S10boot
=== add this before first ifconfig line ===
# mount other partitions
mount -a
=== add end ===
# test an ipkg install to the hard drive (previously ipkg was installing to
the flashrom)
ipkg install lsusb
which lsusb
# output should be similar to this:
/usr/sbin/lsusb
#install samba
ipkg install samba
mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
vi /etc/samba/smb.conf
=== create as follows ===
[global]
workgroup = HOME
server string = WL500gx Router
netbios name = wl500gx
guest account = nobody
security = share
browseable = yes
guest ok = yes
guest only = no
log level = 1
max log size = 100
encrypt passwords = yes
dns proxy = no
[public]
path=/usr/share/ftproot1
writeable = yes
browseable = yes
force create mode = 0775
force directory mode = 6775
force user = root
[wwwroot$]
path=/usr/share/www
writeable = yes
browseable = yes
force create mode = 0775
force directory mode = 6775
force user = root
=== create end ===
# the above samba config lets you access \\wl500gx\public and \\wl500gx\wwwroot$
# \\wl500gx\wwwroot$ isn't listed by windows machines if you just go to \\wl500gx
# because of the $. all files\folders are created by the root user.
# make it start after a reboot
mv /etc/init.d/samba /etc/init.d/S80samba
# edit the otpions
vi /etc/init.d/S80samba
=== add this line after the SMBD_PID line ===
SMBD_OPTIONS="-l /var/log/smbd.log"
#start it now
/etc/init.d/S80samba start
# check it's running
ps -ax | grep smbd
# output should be similar to this:
708 root 928 S smbd -D -l /var/log/smbd.log
712 root 312 S grep smbd
#copy some mp3 files to your music share via samba!!
# install mpd to the hard drive as follows
ipkg install mpd
mkdir /usr/local
mkdir /usr/local/mpd
mkdir /usr/share/ftproot1/music
#copy some mp3's to the directory above. (e.g. using winscp (slow!) or wget)
vi /etc/mpd.conf
=== edit options as follows ===
music_directory "/usr/share/ftproot1/music"
playlist_directory "/usr/share/ftproot1/music"
db_file "/usr/local/mpd/mpd.db"
log_file "/usr/local/mpd/mpd.log"
error_file "/usr/local/mpd/mpd.error"
pid_file "/usr/local/mpd/mpd.pid"
# use this if you want to use OSS audio output
audio_output {
type "oss"
name "my OSS sound card"
device "/dev/sound/dsp" # optional
format "44100:16:2" #optional
}
# OSS Mixer
mixer_type "oss"
mixer_device "/dev/sound/mixer"
mixer_control "PCM"
state_file "/usr/local/mpd/mpdstate"
=== edit end ===
# start it now
/usr/bin/mpd /etc/mpd.conf
# you should see output like this:
unable open db file "/usr/local/mpd/mpd.db": No such file or directory
current locale is "C"
setting filesystem charset to ISO-8859-1
added your.mp3
added music.mp3
added files.mp3
# check it's running by doing this command and look for use of port 6600
# e.g: tcp 0 0 0.0.0.0:6600 0.0.0.0:* LISTEN
netstat -a -n
# make it start after a reboot
vi /etc/init.d/S90mpd
== create as follows ===
#!/bin/sh
/opt/usr/bin/mpd /opt/etc/mpd.conf
=== create end ===
chmod a+x /etc/init.d/S90mpd
# at this point you could use an MPD client that communiates with the MPD server
# running on the router via tcp/ip, e.g. MPD Commander for windows!
# what follows now is how to get a web server with php and a web based music
player up
# and running.
# change the openwrt web interface so it's on port 81
vi /etc/init.d/S50httpd
=== replace with this ===
#!/bin/sh
httpd -p 81 -h /www -r WL500GX Router
=== replace end ===
# kill the old one
killall -9 httpd
# restart it on it's new port
/etc/init.d/S50httpd
# from now on, to access the web interface of the router you should
# add :81 to the url, e.g. http://192.168.1.1:81
# install lighttpd
mkdir /usr/share/www
ipkg install lighttpd
ipkg install lighttpd-mod-status
ipkg install lighttpd-mod-cgi
#install php5 and gd
ipkg install php5-cgi
ipkg install php5-mod-gd
vi /etc/php.ini
=== change as follows ===
extension=gd.so
doc_root =
=== change end ===
vi /etc/lighttpd.conf
=== change as follows (adding lines in the right place as required) ===
server.modules = (
"mod_status",
"mod_cgi"
)
#server.document-root = "/www/"
server.document-root = "/usr/share/www/"
server.errorlog = "/var/log/lighttpd/error.log"
index-file.names = ( "index.php", "index.html", "default.html", "index.htm", "default.htm" )
#### CGI module
cgi.assign = ( ".php" => "/usr/bin/php" )
#### status module
status.status-url = "/server-status"
status.config-url = "/server-config"
=== change end ===
mkdir /var/log/lighttpd
# note, when lighttpd runs it looks here to see where to gets it's default
config from
# /etc/default/lighttpd
# rename the init script so it's started after a reboot
mv /etc/init.d/lighttpd /etc/init.d/S50lighttpd
# start lighttpd
/etc/init.d/lighttpd start
# create a php test file
echo "<?php phpinfo(); ?>" > /usr/share/www/pi.php
# you should be able to test the following url's (change ip's as appropriate)
# http://192.168.1.1/pi.php
# http://192.168.1.1/server-status
# http://192.168.1.1/server-config
# feel free to install any php or other web content to /usr/share/www at this time
# install bzip2
# note: this isn't an openwrt package and would install to /opt, so we need to
# manually install this
mkdir /tmp/bzip2
cd /tmp/bzip2
wget http://ipkg.nslu2-linux.org/feeds/unslung/wl500g/bzip2_1.0.2-4_mipsel.ipk
tar -xvzf bzip2_1.0.2-4_mipsel.ipk
tar -xvzf data.tar.gz
cp -r opt/* /
# now that's installed we could double check by looking at the output
from which bzip2
# you should see output like this:
/bin/bzip2
# tidy up
cd /tmp
rm -r bzip2
# download and install phpMp2
mkdir /usr/local/phpMp2
cd /usr/local/phpMp2
wget http://mercury.chem.pitt.edu/~shank/phpMp2-0.11.0.tar.bz2
bzip2 -d phpMp2-0.11.0.tar.bz2
cd ..
tar -xf phpMp2/phpMp2-0.11.0.tar
ln -s /usr/local/phpMp2/ /usr/share/www/
cd ~
# configure it if you like, though the defaults are fine
vi /opt/share/www/phpMp2/config.php
# fire up this url (change ip's as appropriate)
http://192.168.1.1/phpMp2/
# enjoy!
TODO
====
automatic starting of lighttpd after a reboot (just create a new script in /etc/init.d)
more details on hard drive partitioning (see the ones on www.macsat.com for now)
need to use the swap partition, where's "swapon" on OpenWrt ?
Notes and Useful URL's:
=======================
http://wiki.openwrt.org/OpenWrtDocs/nas
http://www.musicpd.org/
http://mpd.wikicities.com/wiki/Main_Page
http://openwrt.org/downloads/people/nico/testing/mipsel/packages/
http://tracker.openwrt.org/repositories/
http://users.tpg.com.au/davico/openwrt/packages/
# packages fro which you don't need -d opt... be careful with these on openwrt!
http://ipkg.nslu2-linux.org/feeds/unslung/wl500g/