Modify

Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#10733 closed defect (not_a_bug)

luci fails when installed relocated on USB stick / no errror log for uhttp?

Reported by: wrosner@… Owned by:
Priority: normal Milestone: Barrier Breaker 14.07
Component: luci Version: Trunk
Keywords: luci uhttpd log error opkg_-d Cc:

Description

Setting up openwrt on TP-Link TL-MR3220

First setting up luci in flash - great look+feel :-), but too large :-(

Tried to install luci on USB stick, using opkg -d option, following
http://wiki.openwrt.org/doc/howto/usb.storage

works fine with simple packages like usbutils, pciutils,

Howerver, I can't geht the luci CGI working

Upon Installing, I get Errors:

....
Configuring luci-mod-admin-core.
/opt//usr/lib/opkg/info/luci-mod-admin-core.postinst: line 7: /etc/init.d/luci_fixtime: not found
/opt//usr/lib/opkg/info/luci-mod-admin-core.postinst: line 7: /etc/init.d/luci_fixtime: not found
/opt//usr/lib/opkg/info/luci-mod-admin-core.postinst: line 7: /etc/init.d/luci_dhcp_migrate: not found
/opt//usr/lib/opkg/info/luci-mod-admin-core.postinst: line 7: /etc/init.d/luci_dhcp_migrate: not found
Configuring luci-theme-base.
Configuring luci-theme-openwrt.
/opt//usr/lib/opkg/info/luci-theme-openwrt.postinst: .: line 4: can't open '/etc/uci-defaults/luci-theme-openwrt'
....

I did symlink back the /opt/etc to /etc

root@OpenWrt:/opt/www# la /opt/etc
lrwxrwxrwx    1 root     root             5 Jan  3 23:13 /opt/etc -> /etc/

before installation to have the config found in the right place
The errors at install time are gone now, and files mentioned in error messages seem to be in the right place.

I also relocated uhttpd.main.home=/opt/www

I can now open the static pages, like
http://192.168.0.12/luci-static/resources/icons/encryption.png
but in http://192.168.0.12/cgi-bin/luci I can only find a empty page.

http://192.168.0.12/ shows a short flashing black page, presumably redirection to /cgi-bin/luci

Tried to symlink back /opt/lib... files to /lib, did not help.

No more ideas. I had looked for some kind of a http server error log, but could not find any clue in googlespace how to configure such a log.

I see

root@OpenWrt:/opt/www# lsof -p 589
...
uhttpd  589 root    0u   CHR    1,3      0t0    81 /dev/null
uhttpd  589 root    1u   CHR    1,3      0t0    81 /dev/null
uhttpd  589 root    2u   CHR    1,3      0t0    81 /dev/null
...

the stdio file descriptors of uhttpd demon pointing to nirvana, but don't know wheter and/or how to get info out from there.

uhttp refuses to easily start from console

root@OpenWrt:/opt/www# uhttpd
Error: No sockets bound, unable to continue

and I could not manage to figure out the anatomy of the /etc/init.d/uhttpd script

Some more details

(bleeding edge, r29631) from

http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/

root@OpenWrt:/opt/www# echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin

root@OpenWrt:/opt/www# echo $LD_LIBRARY_PATH
/lib/:/usr/lib:/opt/lib:/opt/usr/lib

uhttpd.main.home=/opt/www

root@OpenWrt:/opt/www# mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=14720k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
root on /tmp/root type tmpfs (rw,noatime,mode=755)
overlayfs:/tmp/root on /tmp/root type overlayfs (ro,noatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
/dev/mtdblock3 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlayfs (rw,noatime)
/dev/sdb1 on /opt type ext3 (rw,sync,relatime,user_xattr,barrier=1,nodelalloc,data=ordered)
/dev/sdb4 on /home type ext3 (rw,sync,relatime,user_xattr,barrier=1,nodelalloc,data=ordered)

Attachments (0)

Change History (12)

comment:1 follow-up: Changed 6 years ago by jow

You really should include luci in squashfs, that shrinks the space requirements to 150-200K. As for debugging LuCI itself, run /opt/www/cgi-bin/luci on the cli and see what it does.

comment:2 in reply to: ↑ 1 Changed 6 years ago by anonymous

Replying to jow:

You really should include luci in squashfs,

Hm.... I'm a newbie in embedded stuff.
Hoped to avoid packing own Images on a router w/o serial line outside of the box.
Afraid of bricking those tiny things. Just to coward?

run /opt/www/cgi-bin/luci on the cli and see what it does.

sorry - what's cli? console?
Yeah, gives some hints. Thanks. Will go over it this evening.

root@OpenWrt:/opt/lib/modules/2.6.39.4# /opt/www/cgi-bin/luci
/usr/bin/lua: /opt/www/cgi-bin/luci:2: module 'luci.cacheloader' not found:
        no field package.preload['luci.cacheloader']
        no file './luci/cacheloader.lua'
        no file '/usr/share/lua/luci/cacheloader.lua'
        no file '/usr/share/lua/luci/cacheloader/init.lua'
        no file '/usr/lib/lua/luci/cacheloader.lua'
        no file '/usr/lib/lua/luci/cacheloader/init.lua'
        no file './luci/cacheloader.so'
        no file '/usr/lib/lua/luci/cacheloader.so'
        no file '/usr/lib/lua/loadall.so'
        no file './luci.so'
        no file '/usr/lib/lua/luci.so'
        no file '/usr/lib/lua/loadall.so'
stack traceback:
        [C]: in function 'require'
        /opt/www/cgi-bin/luci:2: in main chunk
        [C]: ?

comment:3 follow-up: Changed 6 years ago by jow

Edit /opt/www/cgi-bin/luci and add the following two lines below "#!/usr/bin/lua":

package.path = package.path .. ";/opt/usr/lib/lua/?.lua;/opt/usr/lib/lua/?/init.lua"
package.cpath = package.cpath .. ";/opt/usr/lib/lua/?.so;/opt/usr/lib/lua/loadall.so"

comment:4 in reply to: ↑ 3 Changed 6 years ago by anonymous

Replying to jow:

Edit /opt/www/cgi-bin/luci and add the following two lines below "#!/usr/bin/lua":

package.path = package.path .. ";/opt/usr/lib/lua/?.lua;/opt/usr/lib/lua/?/init.lua"
package.cpath = package.cpath .. ";/opt/usr/lib/lua/?.so;/opt/usr/lib/lua/loadall.so"

That's it

. Great, and lot of thanks.
Should I have found this on your homepage?
Or is doku for lua / luci somewhere on low prio on the to do list?

comment:5 Changed 6 years ago by jow

No. Thats just one particular instance of a whole class of problems that arise if one tries to relocate packages not prepared for it. In this particular case its not a LuCI issue per se but the fact that the Lua interpreter will never search modules in your relocated environment, but only ever in /usr/lib/lua (its a compile time constant).

The two lines above basically just extend the default Lua module search path to cover the new location. It happens to be in the LuCI file because thats the earliest bit of editable code that runs.

I might document this specific case but there are many more with all but the most trivial packages.

comment:6 Changed 6 years ago by ddxx0n

I have luci and the webserver (I'm using lighttpd) running 100% on external flash, it works just fine. However, the difference with my setup is:

a) After "opkg -d usb" I'm symlinking nearly every single file from the external storage to root, thus effectively merging the filesystems (due to

the amount of files this fills up the root quite a bit, but it is foolproof). Advantage to a whole usb root: I can still boot the router with the

usb drive unplugged if needed.

b) I'm running opkg twice: install, then link, then install again because some post-install scripts will throw an error otherwise.

Below I'm posting a the script "opkg-link.sh" I'm using, it's a modified version of the old one from the web. And, as a bonus, another script "mv-

opkg.sh" I made to seperate the packages already installed on root from these only compiled (so you can just opkg -dest usb *.ipk afterwards) - run it after flashing an updated OpenWrt with usb unmounted.

comment:7 Changed 6 years ago by ddxx0n

mv-ipkg.sh:

{{
#!/bin/sh
# by ddxx0n

if [ ! -d installed_same ]; then

mkdir -p installed_same

fi

if [ ! -d insalled_other ]; then

mkdir -p installed_other

fi

SPECIFIC=_ar71xx
GENERIC=_all
IPKG=.ipk
ALL=_*

opkg list-installed | while read LINE; do

PKG=echo $LINE | awk '{print $1}'
VER=_echo $LINE | awk '{print $3}'

echo -n "... $PKG$VER$IPKG"
if [ -f $PKG$VER$SPECIFIC$IPKG ]; then

mv $PKG$VER$SPECIFIC$IPKG installed_same
echo " - same"

elif [ -f $PKG$VER$GENERIC$IPKG ]; then

mv $PKG$VER$GENERIC$IPKG installed_same
echo " - same"

elif [ -f $PKG$ALL$SPECIFIC$IPKG ]; then

mv $PKG$ALL$SPECIFIC$IPKG installed_other
echo " - other"

elif [ -f $PKG$ALL$GENERIC$IPKG ]; then

mv $PKG$ALL$GENERIC$IPKG installed_other
echo " - other"

else

echo " - missing"

fi

done

if [ ! -d installed_not ]; then

mkdir -p installed_not

fi
mv *.ipk installed_not

}}

comment:8 Changed 6 years ago by ddxx0n

Wupps, again :-p

#!/bin/sh
# by ddxx0n

if [ ! -d installed_same ]; then
	mkdir -p installed_same
fi

if [ ! -d insalled_other ]; then
	mkdir -p installed_other
fi

SPECIFIC=_ar71xx
GENERIC=_all
IPKG=.ipk
ALL=_*

opkg list-installed | while read LINE; do

	PKG=`echo $LINE | awk '{print $1}'`
	VER=_`echo $LINE | awk '{print $3}'`

	echo -n "... $PKG$VER$IPKG"
	if [ -f $PKG$VER$SPECIFIC$IPKG ]; then
		mv $PKG$VER$SPECIFIC$IPKG installed_same
		echo " - same"
	elif [ -f $PKG$VER$GENERIC$IPKG ]; then
		mv $PKG$VER$GENERIC$IPKG installed_same
		echo " - same"
	elif [ -f $PKG$ALL$SPECIFIC$IPKG ]; then
		mv $PKG$ALL$SPECIFIC$IPKG installed_other
		echo " - other"
	elif [ -f $PKG$ALL$GENERIC$IPKG ]; then
		mv $PKG$ALL$GENERIC$IPKG installed_other
		echo " - other"
	else
		echo " - missing"
	fi

done

if [ ! -d installed_not ]; then
	mkdir -p installed_not
fi
mv *.ipk installed_not

comment:9 Changed 6 years ago by ddxx0n

opkg-link.sh:

#!/bin/sh
# modified by ddxx0n

COMMAND=$1
PACKAGE=$2

setdest () {
	for i in `grep dest /etc/opkg.conf | cut -d ' ' -f 3`; do
		if [ -f $i/usr/lib/opkg/info/$PACKAGE.list ]; then
			DEST=$i
		fi
	done
	if [ "x$DEST" = "x" ]; then
		echo "Can not locate $PACKAGE."
		echo "Check /etc/opkg.conf for correct dest listings";
		echo "Check name of requested package: $PACKAGE"
		exit 1
	fi
}

addlinks () {
	setdest;
	cat $DEST/usr/lib/opkg/info/$PACKAGE.list | while read LINE; do
		SRC=$LINE
		DST=`echo $SRC | sed "s|$DEST||"`
		DSTNAME=`basename $DST`
		DSTDIR=`echo $DST | sed "s|$DSTNAME\$||"`
		if [ -f "$SRC" ]; then
			echo -n "Linking $DST ... "
			if [ ! -e "$DST" ]; then
				if [ ! -d "$DSTDIR" ]; then
					mkdir -p "$DSTDIR"
				fi
				# if [ `echo $SRC | grep bin/` ] ||
				if [ `echo $SRC | grep /lib/python` ] || [ `echo $SRC | grep /lib/perl` ] || [ `echo $SRC | grep /lib/php/PEAR` ]; then
  					echo "skipped"
				else
					echo "ok"
					ln -sf "$SRC" "$DST"
				fi
			else
				echo "warning: already exists"
			fi
		else
			if [ ! -d "$SRC" ]; then
				echo -n "Creating $DST ... "
				if [ ! -e $DST ]; then
					echo "ok"
					mkdir -p $DST
				else
					echo "warning: already exists"
				fi
			else
				echo "error: source $SRC does not exist"
			fi
		fi
	done
}

removelinks () {
	setdest;
	cat $DEST/usr/lib/opkg/info/$PACKAGE.list | while read LINE; do
		SRC=$LINE
		DST=`echo $LINE | sed "s|$DEST||"`
		DSTNAME=`basename $DST`
		DSTDIR=`echo $DST | sed "s|$DSTNAME\$||"`
		if [ -f $DST ]; then
			echo -n "Unlinking $DST ... "
			if [ -h $DST ]; then
				echo "ok"
				rm -f $DST
			else
				echo "warning: regular file"
			fi
			test -d $DSTDIR && rmdir $DSTDIR 2>/dev/null
		else
			echo -n "Removing $DST ... "
			if [ -d $DST ]; then
				rmdir $DST
				if [ $? = 0 ]; then
					echo "ok"
				else
					echo "warning: not empty"
				fi
			else
				echo "error: does not exist"
			fi
		fi
	done
}

mountdest () {
	if [ ! -d $PACKAGE ]; then
		echo "Mount point does not exist"
		exit 1
	fi
	for i in $PACKAGE/usr/lib/opkg/info/*.list; do
		$0 add `basename $i .list`
	done

	touch /etc/flags/usb_mounted
}

umountdest () {
	if [ ! -d $PACKAGE ]; then
		echo "Mount point does not exist"
		exit 1
	fi
	for i in $PACKAGE/usr/lib/opkg/info/*.list; do
		$0 remove `basename $i .list`
	done
	
	rm -f /etc/flags/usb_mounted
}

case "$COMMAND" in
  add)
	addlinks
  ;;
  remove)
	removelinks
  ;;
  mount)
	mountdest
  ;;
  umount)
	umountdest
  ;;
   *)
	echo "Usage: $0  "
	echo "       Commands: add, remove, mount, umount"
	echo "       Targets: , "
	echo "Example:  $0 add linux-kernel"
	echo "Example:  $0 remove linux-kernel"
	echo "Example:  $0 mount /usr/local/openwrt"
	echo "Example:  $0 umount /usr/local/openwrt"
	exit 1
	;;
esac
exit 0

comment:10 Changed 5 years ago by nbd

  • Resolution set to not_a_bug
  • Status changed from new to closed

you can just use your USB storage as overlay

comment:11 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

comment:12 in reply to: ↑ description Changed 3 years ago by anonymous

copy this and then works good.

/etc/config/luci

config core 'main'

option resourcebase '/luci-static/resources'
option mediaurlbase '/luci-static/bootstrap'
option lang 'auto'

config extern 'flash_keep'

option uci '/etc/config/'
option dropbear '/etc/dropbear/'
option openvpn '/etc/openvpn/'
option passwd '/etc/passwd'
option opkg '/etc/opkg.conf'
option firewall '/etc/firewall.user'
option uploads '/lib/uci/upload/'

config internal 'languages'

option en 'English'

config internal 'sauth'

option sessionpath '/tmp/luci-sessions'
option sessiontime '3600'

config internal 'ccache'

option enable '1'

config internal 'themes'

option Bootstrap '/luci-static/bootstrap'

Replying to wrosner@…:

Setting up openwrt on TP-Link TL-MR3220

First setting up luci in flash - great look+feel :-), but too large :-(

Tried to install luci on USB stick, using opkg -d option, following
http://wiki.openwrt.org/doc/howto/usb.storage

works fine with simple packages like usbutils, pciutils,

Howerver, I can't geht the luci CGI working

Upon Installing, I get Errors:

....
Configuring luci-mod-admin-core.
/opt//usr/lib/opkg/info/luci-mod-admin-core.postinst: line 7: /etc/init.d/luci_fixtime: not found
/opt//usr/lib/opkg/info/luci-mod-admin-core.postinst: line 7: /etc/init.d/luci_fixtime: not found
/opt//usr/lib/opkg/info/luci-mod-admin-core.postinst: line 7: /etc/init.d/luci_dhcp_migrate: not found
/opt//usr/lib/opkg/info/luci-mod-admin-core.postinst: line 7: /etc/init.d/luci_dhcp_migrate: not found
Configuring luci-theme-base.
Configuring luci-theme-openwrt.
/opt//usr/lib/opkg/info/luci-theme-openwrt.postinst: .: line 4: can't open '/etc/uci-defaults/luci-theme-openwrt'
....

I did symlink back the /opt/etc to /etc

root@OpenWrt:/opt/www# la /opt/etc
lrwxrwxrwx    1 root     root             5 Jan  3 23:13 /opt/etc -> /etc/

before installation to have the config found in the right place
The errors at install time are gone now, and files mentioned in error messages seem to be in the right place.

I also relocated uhttpd.main.home=/opt/www

I can now open the static pages, like
http://192.168.0.12/luci-static/resources/icons/encryption.png
but in http://192.168.0.12/cgi-bin/luci I can only find a empty page.

http://192.168.0.12/ shows a short flashing black page, presumably redirection to /cgi-bin/luci

Tried to symlink back /opt/lib... files to /lib, did not help.

No more ideas. I had looked for some kind of a http server error log, but could not find any clue in googlespace how to configure such a log.

I see

root@OpenWrt:/opt/www# lsof -p 589
...
uhttpd  589 root    0u   CHR    1,3      0t0    81 /dev/null
uhttpd  589 root    1u   CHR    1,3      0t0    81 /dev/null
uhttpd  589 root    2u   CHR    1,3      0t0    81 /dev/null
...

the stdio file descriptors of uhttpd demon pointing to nirvana, but don't know wheter and/or how to get info out from there.

uhttp refuses to easily start from console

root@OpenWrt:/opt/www# uhttpd
Error: No sockets bound, unable to continue

and I could not manage to figure out the anatomy of the /etc/init.d/uhttpd script

Some more details

(bleeding edge, r29631) from

http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/

root@OpenWrt:/opt/www# echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin

root@OpenWrt:/opt/www# echo $LD_LIBRARY_PATH
/lib/:/usr/lib:/opt/lib:/opt/usr/lib

uhttpd.main.home=/opt/www

root@OpenWrt:/opt/www# mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=14720k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
root on /tmp/root type tmpfs (rw,noatime,mode=755)
overlayfs:/tmp/root on /tmp/root type overlayfs (ro,noatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
/dev/mtdblock3 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlayfs (rw,noatime)
/dev/sdb1 on /opt type ext3 (rw,sync,relatime,user_xattr,barrier=1,nodelalloc,data=ordered)
/dev/sdb4 on /home type ext3 (rw,sync,relatime,user_xattr,barrier=1,nodelalloc,data=ordered)

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.