WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: "set proxy boot option" in base or as an extension?  (Read 2930 times)

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
"set proxy boot option" in base or as an extension?
« on: April 14, 2010, 05:37:53 PM »
Hello!

I've hacked together a little script that sets the proxy server environment variables by setting boot options. The question is, should it be included in the TinyCore base or should I create an extension for it?

Code: [Select]
#!/bin/sh

. /etc/init.d/tc-functions

profile="/etc/profile.d/proxy.sh"
proxy="$(getbootparam proxy)"
http_proxy="$(getbootparam http_proxy)"
https_proxy="$(getbootparam https_proxy)"
ftp_proxy="$(getbootparam ftp_proxy)"

if [ -n "${proxy}" ]; then
  [ -z "${http_proxy}" ] && http_proxy="${proxy}"
  [ -z "${https_proxy}" ] && https_proxy="${proxy}"
  [ -z "${ftp_proxy}" ] && ftp_proxy="${proxy}"
fi

rm -f ${profile}
[ -n "${http_proxy}" ] && echo "export http_proxy='${http_proxy}'" >>${profile}
[ -n "${https_proxy}" ] && echo "export https_proxy='${https_proxy}'" >>${profile}
[ -n "${ftp_proxy}" ] && echo "export ftp_proxy='${ftp_proxy}'" >>${profile}

I've hacked up this one, because it's the only way I can think of setting the proxy when booting via PXE/TFTP.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: "set proxy boot option" in base or as an extension?
« Reply #1 on: April 14, 2010, 07:31:45 PM »
Put it in bootlocal.sh in the backup to your nfs tce directory.

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: "set proxy boot option" in base or as an extension?
« Reply #2 on: April 15, 2010, 01:18:04 AM »
That won't work, because I'm not using nfs, just the "tftplist=..." boot parameter.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: "set proxy boot option" in base or as an extension?
« Reply #3 on: April 15, 2010, 05:22:48 PM »
You may be able to specify multiple initrd files, or add another extension to the tftpboot list.

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: "set proxy boot option" in base or as an extension?
« Reply #4 on: April 15, 2010, 05:28:59 PM »
Yes, that's meant about in the first place: I already have it as an extension, but it's a 4k .tcz for a 622 bytes file.

So back to my initial question: should I release this extension or wouldn't it be wiser to put that functionality into tc-config?

Offline dufus

  • Newbie
  • *
  • Posts: 12
Re: "set proxy boot option" in base or as an extension?
« Reply #5 on: April 16, 2010, 08:44:08 AM »
I have similar concerns. To add non-standard port support to the "httplist=" boot all I need is to switch these 3 lines (3 better ones are welcome) in the get_app function of tc-config:

  SERVER=$(echo $2 | awk -F: '$2~/[0-9]+/ {print $1FS$2} !($2~/[0-9]+/) {print $1}')
  FILE=$(echo $2 | awk -F: '$2~/[0-9]+/ {print $3} !($2~/[0-9]+/) { print $2 }')
  OPTS=$(echo $2 | awk -F: '$2~/[0-9]+/ {print $4} !($2~/[0-9]+/) { print $3 }')     

about 100 bytes (just guessing), but to put them in as secondary initrds or extensions doesn't feel tiny enough to me. Not to mention the changes required to all the pxelinux.cfg menus.

nfs is better if it is available to you as an option. (wiki already has good write-ups on nfs)

a little feedback on the future plans for this script would aleviate anxiety  :)

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: "set proxy boot option" in base or as an extension?
« Reply #6 on: April 17, 2010, 09:44:35 PM »
How about adding 'port=xxxx' to the options?
Ex:
httplist=openvz:TCL/nfs.list:port=8000,no-ping

I had planned on possibly adding options as needed when I wrote the nfs/tftp/http code.

Offline dufus

  • Newbie
  • *
  • Posts: 12
Re: "set proxy boot option" in base or as an extension?
« Reply #7 on: April 24, 2010, 08:48:07 AM »
yes port= option would be extra great for me !!
Not sure if it will help Svolli though. Might need to move this thread cause we're getting away from topic. It had occured to me to combine nfs/tftp/http into a single boot param like maybe "net-preload_tce=". And then parse the server type, port, file name etc. out of a standard url. Like...
"net-preload_tce=http://tincore_server:8085/dir_name/filelistname:no-ping"
it would add  a lot of complexity to a base script though; and I have not had much success getting busy-box awk to be "readable". Looks like there is a new busy-box in 211rc2, maybe I'll go play with that.

Thanx ! & sorry to be slow in response, I having network hardware woes.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: "set proxy boot option" in base or as an extension?
« Reply #8 on: April 24, 2010, 01:04:44 PM »
One option is not sufficient.
I use TFTP to load the NFS drivers to then use NFS for the tce directory.
A patch has been submitted to allow httplist=host:port/path/to/list.

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: "set proxy boot option" in base or as an extension?
« Reply #9 on: April 24, 2010, 01:40:17 PM »
Patch accepted and will be included starting with v2.11rc3.
10+ Years Contributing to Linux Open Source Projects.

Offline dufus

  • Newbie
  • *
  • Posts: 12
Re: "set proxy boot option" in base or as an extension?
« Reply #10 on: April 24, 2010, 08:54:10 PM »
Thanx mucho!