Sign up here and you can log into the forum!

can't change $PATH variable via script

This is the place to ask for how to use software that is (or isn't) included in the various wdlxtv flavours. Questions about software such as rtorrent, NZBGet, sshfs, curlftpfs, ssh, telnet, etc.

can't change $PATH variable via script   

Postby KAD » Sat May 24, 2014 11:39 am

hi all, I'm back at it again :D

and trying to add .app.bin support
but have run into a few issues

I'm attempting to do this very similiar to prior releases
Code: Select all
# cat /etc/init.d/post-init
#!/bin/bash
APPS=($(find /share -maxdepth 1 -type f -iname "*.app.bin"))
for i in ${!APPS[@]}
do
        a="`basename "${APPS[i]}" | sed -e 's/\.app\.bin$//'`"
        if ! `mountpoint -q /apps/$a` ; then
                mkdir -p "/apps/$a"
                mount -o loop "${APPS[i]}" "/apps/$a"
                [ -d "/apps/$a/lib" ] && echo "/apps/$a/lib" >> etc/ld.so.conf
                [ -d "/apps/$a/bin" ] && sudo su - -c "PATH=/apps/$a/bin:$PATH"
                [ -d "/apps/$a/sbin" ] && sudo su - -c "PATH=/apps/$a/sbin:$PATH"
        fi
done
for j in "/apps/*/etc/init.d/S[0-9][0-9]*"
do
        echo "I work too"
done



this
Code: Select all
sudo su - -c "PATH=/apps/$a/bin:$PATH"
or
Code: Select all
PATH="/apps/$a/bin:$PATH"

does not work from inside script
but from cmd line this works
Code: Select all
PATH=/apps/minidlna/bin:$PATH"


and here's some output from script
Code: Select all
# bash -x /etc/init.d/post-init
+ APPS=($(find /share -maxdepth 1 -type f -iname "*.app.bin"))
++ find /share -maxdepth 1 -type f -iname '*.app.bin'
+ for i in '${!APPS[@]}'
++ basename /share/minidlna.app.bin
++ sed -e 's/\.app\.bin$//'
+ a=minidlna
++ mountpoint -q /apps/minidlna
+ mkdir -p /apps/minidlna
+ mount -o loop /share/minidlna.app.bin /apps/minidlna
+ '[' -d /apps/minidlna/lib ']'
+ echo /apps/minidlna/lib
/etc/init.d/post-init: line 9: etc/ld.so.conf: No such file or directory
+ '[' -d /apps/minidlna/bin ']'
+ sudo su - -c PATH=/apps/minidlna/bin:/tmp/apps/minidlna/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/bin
+ '[' -d /apps/minidlna/sbin ']'
+ for j in '"/apps/*/etc/init.d/S[0-9][0-9]*"'
+ echo 'I work too'
I work too
# echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/bin
# which minidlna
#


the script appears to function, but as you can see, $PATH was not really adjusted
and minidlna is not found

I have not tried to resolve the missing /etc/ld.so.conf yet
I'll leave that for after $PATH issue is solved
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: can't change $PATH variable via script   

Postby recliq » Sat May 24, 2014 1:32 pm

setting the PATH inside the script works, but it will never get out there, the script can't change the PATH variable in the shell that called the script.
Have a look at the scripts in current WDLXTV, they write the PATH variable to /tmp/sys.path:
https://svn.wdlxtv.com/filedetails.php?repname=1.05.04-wdlxtv&path=%2Flive%2Ftrunk%2Fusr%2Fbin%2Fapp-plugman-web
That file should be sourced by the shell:
https://svn.wdlxtv.com/filedetails.php?repname=1.05.04-wdlxtv&path=%2Flive%2Ftrunk%2Fetc%2Fprofile
and that's why it's mentioned to source that file after loading apps with app-plugman-web:
http://wiki.wdlxtv.com/Creating_an_app_bin#Loading_and_unloading_app.bin
:mrgreen: :ugeek:
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: can't change $PATH variable via script   

Postby KAD » Sat May 24, 2014 1:41 pm

ok, thanks

I was looking at crazymount, and now that you point that out
the very last line of crazymount is
Code: Select all
echo PATH=$PATH > /tmp/sys.path
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: can't change $PATH variable via script   

Postby KAD » Sat Jun 07, 2014 5:44 pm

so here we are again, I've made quite a bit of progress

anybody have idea's on why this is not working
this is after a fresh reboot, all set up done by scripts, no manual $PATH or ldconfig changes

which can find ipkg
and ldd resolves the dependancies
but when try to run, it's not found

p.s. opt.app.bin is just brad's opt.bin renamed to fit my startup scripts
Code: Select all
# app-plugman-web list
/tmp/media/usb/USB1140/C1BB-8FD5/opt.app.bin
/tmp/media/usb/USB1140/C1BB-8FD5/mc.app.bin.disabled
/tmp/media/usb/USB1140/C1BB-8FD5/virtualkeyboard.app.bin.disabled
# which ipkg
/apps/opt/bin/ipkg
# ldd /apps/opt/bin/ipkg
        libipkg.so.0 => /apps/opt/lib/libipkg.so.0 (0x2aab4000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x2ab22000)
        libc.so.0 => /apps/opt/lib/libc.so.0 (0x2ab5a000)
        libc.so.6 => /lib/libc.so.6 (0x2abfc000)
        ld-uClibc.so.0 => /apps/opt/lib/ld-uClibc.so.0 (0x2ad5e000)
        /lib/ld-uClibc.so.0 => /lib/ld.so.1 (0x55550000)
# ipkg
-sh: ipkg: not found
# /apps/opt/bin/ipkg
-sh: /apps/opt/bin/ipkg: not found
# cat /tmp/sys.path
PATH=/apps/opt/sbin:/apps/opt/bin:/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#


another example where this is actually working
Code: Select all
# which update-alternatives
/apps/opt/bin/update-alternatives
# update-alternatives
update-alternatives: at least one of --install or --remove must appear

Usage: update-alternatives --install <link> <name> <path> <priority>
       update-alternatives --remove <name> <path>
       update-alternatives --help
<link> is the link pointing to the provided path (ie. /usr/bin/foo).
<name> is the name in /opt/lib/ipkg/alternatives/alternatives (ie. foo)
<path> is the name referred to (ie. /usr/bin/foo-extra-spiffy)
<priority> is an integer; options with higher numbers are chosen.



so I guess it's something with ipkg binary
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: can't change $PATH variable via script   

Postby recliq » Sun Jun 08, 2014 2:41 am

I'm not sure but I think there may be some issues here to check:
1) check ipkg with file and compare it to another wdtv binary
Code: Select all
file /apps/opt/bin/ipkg


2) optware is normally mounted to /opt not /apps/opt - there may be additional dependencies on this structure

3) check crazymount to see how it's setup normally I think there is at least a hint file created in /tmp/OPTBIN so there is some other scripts that may read and use that.

4) last but not least compare the ld-uClibc.so.0 versions, maybe SMP uses a different version, I know b-rad had quite some problems getting optware running on Live/Plus, so maybe SMP changed again.
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: can't change $PATH variable via script   

Postby KAD » Sun Jun 08, 2014 1:19 pm

of coarse your right again, opt.bin was mounted to /opt

my concearn with that originally, was that there are already binaries the WD requires located at /opt/bin/...

so how does the WD run correctly without access to those binaries, for live, all I see is a few dbus binaries
maybe those are only used at boot :?

but in the case of SMP there's /opt/bin/... /opt/lib/... and a ton of other stuff
/opt directory on SMP contains the qt web browser and all the plugins, and tons of other libraries and binaries

as I'm writing this maybe the work around, is to include that entire directory tree of binaries and libs in opt.bin , mount bind it to /opt and allow ipkg to install standard directories
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: can't change $PATH variable via script   

Postby recliq » Mon Jun 09, 2014 2:09 am

Oh if /opt is used on SMP I wouldn't combine the existing tree with optware (with eg. unionfs) chances are high that optware will overwrite something from SMP which might cause troube if different versions get mixed up.
I'm no expert on optware... I'd try to ask b-rad.
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: can't change $PATH variable via script   

Postby KAD » Mon Jun 09, 2014 7:59 am

yeah it would be nice if b-rad was around

I think something is wrong with the ipkg binary, or at least not compatible, etc ...

I ran a test using mount -o bind

and now have a working version of entware
if your unfamiliar with entware
https://github.com/Entware/entware
and available packages here http://entware.wl500g.info/binaries/entware/Packages.html

but yes, I agree this could be potentially dangerous if entware overwrites some existing binary or library

so far, I've only installed vim, really just to test if it works
and it install the needed binaries and libraries, and they run on the SMP just fine
but yes all dependancies install to /opt/lib and none of them previously existed
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: can't change $PATH variable via script   

Postby KAD » Mon Jun 09, 2014 8:12 am

in other news app.bin support is done

I'm actually considering putting out a beta firmware
needs more testing before public release, too many changes

but one thing I have yet to decide is if I should enable download of app.bin's from webend, listed as incompatible device

so far I've only found 1 app.bin that works as is, with no changes
although, I've only tested about 4 -5
and then there's another 4 -5 that I know should not be used with SMP

from what I've seen most app.bin's would only require small changes

vim.app.bin - missing libraries
DownloadDaemon.app.bin , assumed /tmp/init.d/ exist but it does not, start scripts should point to /apps/downloadd/etc/init.d/Sxx

but quite a few of the cramfs formatted app.bin's give an input/output error :?
I'm guessing something to do with the old cramfs16k , which probably does not apply to SMP
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: can't change $PATH variable via script   

Postby mad_ady » Mon Jun 09, 2014 11:00 pm

Great work, KAD.

Regarding the incompatible cramfs - we could convert all the apps to ext3 and that would solve the issue (drop support for cramfs maybe).
Regarding apps that should be marked as incompatible, we could add the maximum firmware version they can run on to 1.06 (so that they would run on the last version for live/plus).
User avatar
mad_ady
Developer
 
Posts: 4549
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Next

Return to Application Questions

Who is online

Users browsing this forum: No registered users and 1 guest