下文所用路由器型号为:WNDR3700V4
参考链接:http://dd-wrt.ca/phpBB2/viewtopic.php?t=86912&highlight=optware
http://www.openwrt.org.cn/bbs/forum.php?mod=viewthread&tid=14206#lastpost
由于WNDR3700V4的芯片是Atheros,Atheros并不支持optware,下面我们来用openwrt的opkg玩转全能服务器。
1,安装opkg到U盘
启动USB支持
Under Services->USB: * Enable Core USB Support * Disable USB Printer Support (enable it if you need printing support) * Enable USB Storage Support * Enable Automatic Drive Mount * Click Apply Settings
在U盘创建相关目录结构,U盘默认mount到了/mnt/sda1
cd /mnt/sda1
mkdir /sda_part1
cd /mnt/sda1/sda_part1
mkdir etc opt root
touch optware.enable
chmod etc opt root
mkdir opt/lib
chmod opt/lib
cp -a /etc/* /mnt/sda1/sda_part1/etc/
mount -o bind /mnt/sda1/sda_part1/etc /etc
mount -o bind /mnt/sda1/sda_part1/opt /jffs
安装libc和opkg包
wget http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/libc_0.9.33.2-1_ar71xx.ipk
ipkg install libc_0.9.33.-1_ar71xx.ipk
wget http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/opkg_618-3_ar71xx.ipk
ipkg install opkg_618-3_ar71xx.ipk
为opkg创建配置文件
cat > /etc/opkg.conf << EOF
src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
dest root /opt
dest ram /opt/tmp
lists_dir ext /opt/tmp/var/opkg-lists
EOF
mount到相关目录
umount /jffs
mount -o bind /mnt/sda1/sda_part1/root /tmp/root
mount -o bind /mnt/sda1/sda_part1/opt /opt
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
opkg update
执行此操作,你能够看到
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz. Updated list of available packages in /opt/tmp/var/opkg-lists/snapshots.
6. Set the startup script to make the changes take effect each time upon reboot
Under DD-WRT’s web interface, Administration->Commands, input the following commands in the window then click "Save Startup":
#!/bin/sh sleep
if [ -f /mnt/sda1/sda_part1/optware.enable ]; then
mount -o bind /mnt/sda1/sda_part1/etc /etc
mount -o bind /mnt/sda1/sda_part1/root /tmp/root
mount -o bind /mnt/sda1/sda_part1/opt /opt
else
exit
fi if [ -d /opt/usr ]; then
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin'
else
exit
fi
7. Modification of the profile file
SSH into your box then copy/paste the commands below to PuTTY window to create a script running each time when user root logins:
cat > /mnt/sda1/sda_part1/root/.profile << EOF
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib:/opt/usr/local/lib'
export PATH='/sbin:/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/usr/bin:/usr/sbin:/opt/usr/local/bin'
export PS1='\[\033[01;31m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
export TERMINFO='/opt/usr/share/terminfo'
EOF
安装SVN
opkg install subversion-server