WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: autostart SimpleHTTPServer  (Read 6223 times)

Offline okanagansage

  • Newbie
  • *
  • Posts: 5
autostart SimpleHTTPServer
« on: February 06, 2015, 02:54:49 AM »
Hello, I'm trying to set-up a wyse V10L as a headless machine with python's SimpleHTTPServer running automatically at boot. I'm trying to set this up for a local electronics recycling depot. I'm going to attach a dedicated wireless router to the side of it so they can easily just plug it in (and the router) to share files with customers who're on site (tutorials and documents on repurposing pc's, etc). I have no experience with web servers. 

The wyse is running tinycore off of a live-usb that I made using a coreplus cd on a laptop. The live-usb is sdb since the internal drive has not been touched. I've installed openssh and configured it to autostart for administration purposes. That involved editing /opt/bootlocal.sh and /opt/.filetool.lst . After reboot, openssh autostarts fine.

I figure I could get the SimpleHTTPServer running the same way by adding 'cd /home/Documents && python -m SimpleHTTPServer' to /opt/bootlocal.sh and adding lines to /opt/.filetool.lst  ... but I don't know what lines to add to .filetool.lst.  I've got the 'locate' command by installing findutils but I get no results by searching for SimpleHTTPServer. On lubuntu I can use locate to find /usr/lib/python2.7/SimpleHTTPServer.py but on tinycore I get nothing. Even if I try to locate just python there is no output. I've manually gone through a bunch of directories to find SimpleHTTPServer.py but have had no luck.

If anyone could point me in the right direction it would be greatly appreciated.
Paul

Edit: It's midnight now so I'm gonna crash but I'll keep keep an eye out for replies.
« Last Edit: February 06, 2015, 02:56:38 AM by okanagansage »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14812
Re: autostart SimpleHTTPServer
« Reply #1 on: February 06, 2015, 03:16:32 AM »
to locate files created after you do something, load the findutils extension and:
Code: [Select]
$ touch mymarker
$ do something
$ sudo find / -not -type 'd' -cnewer mymarker | grep -v "\/proc\/" | grep -v "^\/sys\/" | tee files
$ vi files

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: autostart SimpleHTTPServer
« Reply #2 on: February 06, 2015, 04:52:54 AM »
If you just need a web server, you'll save tens of megabytes by using busybox-httpd instead of python.
The only barriers that can stop you are the ones you create yourself.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11618
Re: autostart SimpleHTTPServer
« Reply #3 on: February 06, 2015, 10:06:04 AM »
Hi okanagansage
Are you sure you installed  python.tcz?
Quote
On lubuntu I can use locate to find /usr/lib/python2.7/SimpleHTTPServer.py but on tinycore I get nothing.
On Tinycore it would be under:
Code: [Select]
usr/local/lib/python2.7/SimpleHTTPServer.py

Offline okanagansage

  • Newbie
  • *
  • Posts: 5
Re: autostart SimpleHTTPServer
« Reply #4 on: February 06, 2015, 04:12:30 PM »
@Rich:
When I look in:
apps (program) > apps (button) > maintenance > onboot maintenance 
python.tcz is in the list.

In /usr/local/lib there is no python files/folders, but in /usr/local/tce.installed there is a file called python with the contents:
Code: [Select]
#!/bin/sh
tar xzf /usr/local/share/python/files/files.tar.gz -C /
ln -sf /usr/local/bin/python2.7 /usr/bin/python

I'm just going to see if I understand this. Python is being extracted, then a link is being created between the files /usr/local/bin/python2.7 and /usr/bin/python .
If I look in /usr/local/bin I can see python2.7 and it's text is in green where the vast majority of other files in there have blue-ish green text. I'm guessing the green text indicates that the file itself is linked to a file elsewhere.

So at this point python is only running when I run the command in the terminal, right? My question is how do I get SimpleHTTPServer to start on boot and serve whatever I have in ~/Documents ?
.........................................................
In /opt/bootlocal.sh I have just the line for openssh:
/usr/local/etc/init.d/openssh start

In /opt/.filetool.lst I have:
opt
home
etc/shadow
usr/local/etc/ssh/ssh_config
usr/local/etc/ssh/sshd_config
...........................................................
@curaga
I was trying to use SimpleHTTPServer because it is the only 'server' I've ever used. It serves access to the folder of my choosing without me having to know any html or whatever. Like I said in my original post, I have practically no experience with servers. I have a little experience with linux but very little experience with tinycore.
...................................................
@juanito
I tried your find command with SimpleHTTPServer instead of mymarker and I get 'no such file or directory'.


Offline okanagansage

  • Newbie
  • *
  • Posts: 5
Re: autostart SimpleHTTPServer
« Reply #5 on: February 06, 2015, 05:27:53 PM »
I'm going to try to wrap my head around this (I've been reading this:
http://www.parkytowers.me.uk/thin/Linux/TinycoreWS.shtml

When tinycore boots, it looks in attached storage for the tce directory which contains any option extensions I've installed. Those extensions on the storage medium are actually compressed storage file systems. So in
/mnt/sdb2/tce/optional/
it is finding python.tcz and python.tcz.dep and python.tcz.md5.txt  ...
Then it mounts python.tcz at /tmp/tmloop/python 

So if I go to
/tmp/tcloop/python/usr/local/lib/
I find two files and a folder:
libpython2.7.so    libpython2.7.so.1.0    python2.7/
AND IN python2.7/ IS >>> SimpleHTTPServer.py
I don't know why the command
Code: [Select]
sudo locate SimpleHTTPServeror
Code: [Select]
sudo locate SimpleHTTPServer.pydoes not find these files. Maybe it doesn't search in /tmp .

So...
/mnt/sdb2/tce/optional/python.tcz
is mounted to
/tmp/tcloop/python/
and that tmp directory is merged into the main system.

That means
/tmp/tcloop/python/usr/local/lib/python2.7/
is also located at
/usr/local/lib/python2.7/
Which it is.

I think I've just about got this.
I'm going to read a bit more and I'll post what I find.

Edit: That's weird. When I replied to Rich in the previous post I said that python wasn't in /usr/local/lib/
If it was installed as an onboot program, shouldn't it be there even before running the following command?
Code: [Select]
python -m SimpleHTTPServer
« Last Edit: February 06, 2015, 05:40:15 PM by okanagansage »

Offline okanagansage

  • Newbie
  • *
  • Posts: 5
Re: autostart SimpleHTTPServer
« Reply #6 on: February 06, 2015, 06:53:20 PM »
So it turns out that just adding
Code: [Select]
python -m SimpleHTTPServerto /opt/bootlocal.sh   works but if I try adding this to /opt/bootlocal.sh:
Code: [Select]
cd Documents && python -m SimpleHTTPServerit doesn't work.

Either does
Code: [Select]
cd /home/tc/Documents && python -m SimpleHTTPServer


Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: autostart SimpleHTTPServer
« Reply #7 on: February 07, 2015, 03:36:01 AM »
You can record the error messages:

cd /home/tc/Documents && python -m SimpleHTTPServer > /tmp/pyerr 2>&1
The only barriers that can stop you are the ones you create yourself.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: autostart SimpleHTTPServer
« Reply #8 on: February 07, 2015, 12:57:43 PM »
Maybe I misunderstand the issue, but there are no such thing as SimpleHTTPServer you can start. It is a Python modul what you can use to include SimpleHTTPServer to an application. You can start this apllication, but not SimpleHTTPServer. Pelase see

https://docs.python.org/2.7/library/simplehttpserver.html#module-SimpleHTTPServer
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline okanagansage

  • Newbie
  • *
  • Posts: 5
Re: autostart SimpleHTTPServer
« Reply #9 on: February 08, 2015, 09:18:07 PM »
Thanks for your suggestions. I've got this working at boot so I'm going to consider this solved.

I want to bring this wyse into the recycling depot soon and I still want to try out some command line music players.

Thanks again.
Paul