Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Senior Member
    Join Date
    Sep 2009
    Posts
    104

    LMS 8.1 - Webserver folder structure and CGI/PHP scripts

    Hi,

    I have searched this forum, the web and tried to the best of my abilities without any luck.

    I am currently exploring the LMS' built in webserver in hopes of running some web pages/scripts without the need for a separate web server running on my aging Raspberry Pi server with Raspberry Pi OS.

    1. Is it correct, as I think I have found, that the webpages for http://lms_server_ip:9000 are located in the folder /usr/share/squeezeboxserver/HTML/EN?

    2. Is it possible and how to to configure the LMS built-in webserver to run CGI and/or PHP scripts to generate simple webpages?
    (whenever I put a .pl or .php file in any of the ../HTML/EN, ../HTML/Default or ../HTML/Classic folders and restart LMS, I only get e.g. 404 Not Found: test.pl... Permissions are 755 and owner:group = squeezeboxserver:nogroup)

    Any help is greatly appreciated!
    Br,
    Vegard


    2x SB Touch, 5x SB Radio, LMS on a (modified)Max2Play RPi 3, iPeng on iOS
    Xindak XA6950, CA DacMagic, Klipsch RF-7, B&W ASW610XP
    last.fm/user/vegarlu / github.com/Vegz78/GRUVI / retrospill.ninja

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,714

    LMS 8.1 - Webserver folderstructure and CGI/PHP scripts

    > 1. Is it correct, as I think I have found, that the webpages for
    > -http://lms_server_ip:9000- are located in the folder
    > -/usr/share/squeezeboxserver/HTML/EN-?


    Yes, most of them. EN is the name of the basic skin, from which most
    other skins inherit. Plugins can add more pages and skins.

    > 2. Is it possible and how to to configure the LMS built-in webserver to
    > run CGI and/or PHP scripts to generate simple webpages?


    Not on a stock LMS. LMS isn't a general purpose web server like Apache
    or nginx. It's really an application server which, among other things,
    exposes a web UI. But any page you'd want to add would require a plugin
    to implement a handler for it.

    You might be able to write a LMS plugin to execute CGI scripts. But I'm
    not sure this is a reasonable approache.


  3. #3
    Senior Member
    Join Date
    Sep 2009
    Posts
    104
    Wow, that was quick, @mherger! -Just like lightnin'...

    Thank you!
    Quote Originally Posted by mherger View Post
    You might be able to write a LMS plugin to execute CGI scripts. But I'm
    not sure this is a reasonable approache.
    That might be a little much work for the task at hand; I am only trying to serve some images and a list of images in a html-file, which the players' built-in image viewer app can utilize, but without the need of an additional external web server(but an interesting idea for a fairly complex training project!). ;-)

    My next thought was to modify my existing PHP script to generate a static html file, which then is set up to run regularly through cron with output of this html file to the /usr/share/squeezeboxserver/HTML/EN folder.

    However, the "application server" with the web UI:
    -seems not to find any additionally added new html files, like test.html(but I can replace and modify e.g. firmware.html), and
    -the contents of the modified firmware.html seems only to load once and stay unchanged between LMS server restarts, and
    -I can not get the app server to serve/show the images that the links in firmware.html point to inside the same folder on the Squeezebox Touch ImageViewer screen.

    But, I also notice that some of the standard app server pages are dynamic with various JavaScript parts and .js files, which also show different images from the images folder.

    Might there be a way to serve the images to the player's ImageViewer app, with a combination of a hijacked(or somehow to include a new html file when the LMS starts) (dynamic e.g. firmware.)html file, where the list of images to display/slideshow will be dynamically updated by JavaScript, which also somehow help actually serve/show the images(jpg or png) onto the ImageViewer screen?
    Br,
    Vegard


    2x SB Touch, 5x SB Radio, LMS on a (modified)Max2Play RPi 3, iPeng on iOS
    Xindak XA6950, CA DacMagic, Klipsch RF-7, B&W ASW610XP
    last.fm/user/vegarlu / github.com/Vegz78/GRUVI / retrospill.ninja

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,714

    LMS 8.1 - Webserver folderstructure and CGI/PHP scripts

    > That might be a little much work for the task at hand; I am only trying
    > to serve some images and a list of images in a html-file, which the
    > players' built-in image viewer app can utilize, but without the need of
    > an additional external web server(but an interesting idea for a fairly
    > complex training project!). ;-)


    If it's static files, then you can drop them in the EN/html folder.
    Files in that folder are considered static and don't require any custom
    code to be served.

    > My next thought was to modify my existing PHP script to generate a
    > static html file, which then is set up to run regularly through cron
    > with output of this html file to the
    > -/usr/share/squeezeboxserver/HTML/EN- folder.


    add the html folder, and you should be good.

  5. #5
    Senior Member
    Join Date
    Sep 2009
    Posts
    104
    Quote Originally Posted by mherger View Post
    If it's static files, then you can drop them in the EN/html folder.
    Files in that folder are considered static and don't require any custom
    code to be served.
    Thanks again for the lightning-fast reply, @mherger!!!

    That worked pretty well. -That is, the LMS app server loaded and served any new html or jpg file pretty quickly after putting it into the .../EN/html folder. But it seems to somehow cache both html and image files, so when changing or replacing any file, it still shows the first version loaded.

    The image files I might just solve by making some sequence of unique file names for every new image that I want to load(if I don't quickly run out of memory/cache), but somehow I need to keep the name of the html file with image addresses constant inside the player's ImageViewer source settings, while being able to update the image address list periodically inside this html file. I'll check further if this is possible with some JavaScript, or maybe the cron job could restart the LMS server or empty the cache periodically, once a week, or something, when I want some changes to the image slideshows.

    Any tips for quicker/better solutions is of course appreciated, but i think I have what I need now to kludge together some sort of solution in a reasonable amount of time. ;-)
    Br,
    Vegard


    2x SB Touch, 5x SB Radio, LMS on a (modified)Max2Play RPi 3, iPeng on iOS
    Xindak XA6950, CA DacMagic, Klipsch RF-7, B&W ASW610XP
    last.fm/user/vegarlu / github.com/Vegz78/GRUVI / retrospill.ninja

  6. #6
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,714

    LMS 8.1 - Webserver folderstructure and CGI/PHP scripts

    > That worked pretty well. -That is, the LMS app server loaded and served
    > any new html or jpg file pretty quickly after putting it into the
    > -.../EN/html- folder. But it seems to somehow cache both html and image
    > files, so when changing or replacing any file, it still shows the first
    > version loaded.


    I tried to understand the cache time. Can you double check whether it's
    more than 1h? That's a value I found. How time critical are your updates?

  7. #7
    Senior Member
    Join Date
    Sep 2009
    Posts
    104
    Quote Originally Posted by mherger View Post
    I tried to understand the cache time. Can you double check whether it's
    more than 1h? That's a value I found. How time critical are your updates?
    I am unable to find the cache time settings of 1h that you mention in either server.prefs or the web settings interface. Where did you find it?

    On the other hand, I found that the LMS app server web UI both serves and doesn't cache .txt files, which the players' ImageViewer also reads as URL lists in addition to html files.

    I am therefore now able to immediately see changes to the produced URL lists inside .txt files while modifying the script, and if the cache time for images is only 1h, that's more than fast enough for a slideshow selection of pictures that may need to be changed at most once a day, maybe enough with once a week.

    Thanks!
    Br,
    Vegard


    2x SB Touch, 5x SB Radio, LMS on a (modified)Max2Play RPi 3, iPeng on iOS
    Xindak XA6950, CA DacMagic, Klipsch RF-7, B&W ASW610XP
    last.fm/user/vegarlu / github.com/Vegz78/GRUVI / retrospill.ninja

  8. #8
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,714

    LMS 8.1 - Webserver folderstructure and CGI/PHP scripts

    > I am unable to find the cache time settings of 1h that you mention in
    > either -server.prefs- or the web settings interface. Where did you find
    > it?


    It's something I've found in the code, not configurable.

    > On the other hand, I found that the LMS app server web UI both serves
    > and doesn't cache .txt files, which the players' ImageViewer also reads
    > as URL lists in addition to html files.


    Nice!

  9. #9
    Senior Member
    Join Date
    Dec 2020
    Posts
    256
    Honestly, I think you'll be better off installing nginx or lighttp. As you noticed LMS caches files it considers static for faster serving, while likely also not really responding to cache requests from your browser (so serving the same file over and over again) but you can probably verify that yourself. The problem here is that if you keep adding graphic content to use in some alternating rotation LMS will keep storing those files in memory even though you no longer access the older ones in your present rotation, until you run out of memory.

  10. #10
    Senior Member
    Join Date
    Sep 2009
    Posts
    104
    Quote Originally Posted by gordonb3 View Post
    Honestly, I think you'll be better off installing nginx or lighttp.
    You are probably right, @gordonb3! -And thanks for the info!

    But I am overly optimistic now that I've found that .txt files that weren't cached and indications from @mherger about only 1h cache time.

    I would really like to try to get this project running with as little as possible needed apart from the LMS, and I am simultaneously stripping my old Raspberry Pi of not and seldom used apps and services, in an attempt to identify and squash a kernel panic that is bothering me intermittently. Since a reboot solves this problem when the panic occurs, I am also thinking about a periodic reboot with fsck(bad SD card, maybe), which would probably also mitigate any problems from LMS cache memory build-up.
    (...even though I made a major mistake from the beginning, by choosing PHP, which probably is the only scripting language known to man which is not included pre-installed with the regular Raspberry OS images...) ;-)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •