NSLU2-Linux
view · edit · print · history

Unslung.DiversionScripts History

Hide minor edits - Show changes to markup

December 23, 2007, at 05:28 PM by ShadowJK -- Clariffy script locations
Changed lines 5-6 from:

Diversion scripts can go into three places. The three locations are: /unslung (directory off the rootfs), /share/hdd/data/unslung (directory off a hard drive enclosure), or /share/flash/data/unslung (directory off a plugged in flash drive). These last two locations are used for "Pluggable Personalities" - meaning that the diversion scripts placed in those two locations are ONLY run when either the hard drive or flash drive is plugged in and recognized at boot time. If you always want a diversion script to run - independent of what disks/flash drives are plugged in, then put the diversion script into /unslung (you will have to create that directory first). WARNING: if you make a bad mistake with a diversion script in /unslung, you may have to reflash to fix the error.

to:

The normal boot scripts check for the presence of Diversion scripts in /unslung, however, it's not quite as simple as it sounds. During the boot process, if external storage is detected and contains the unslung device, the root filesystem will be changed over to the external storage. /unslung will now contain the scripts stored on the external device (harddrive or flash). If no external storage device is attached, then /unslung will continue to have the scripts that are stored in the internal flash.

Therefore, it is important that no scripts that are stored on the internal flash require any programs or functionality stored on external storage. So, how do you tell which is which? The login message when you log in via ssh or telnet tells you whether you are running on internal flash or not, and the "Home" page on the web interface has the same information at the bottom. If you are running on external storage, /unslung will be on the external storage, and when not running from disk, /unslung will be the internal flash.

Additionally, you can access the internal flash when running from external storage, from /initrd/unslung/. You can also access your flash or harddrive's /unslung if you booted to internal flash but later attached harddrive, the location will be either /share/hdd/data/unslung (hard drive) or /share/flash/data/unslung (flash). This comes in handy if you make a mistake with your scripts.

If you always want a diversion script to run - independent of what disks/flash drives are plugged in, then put the diversion script into both locations. WARNING: if you make a bad mistake with a diversion script on the internal flash, you may have to reflash to fix the error.

October 04, 2007, at 11:18 PM by BrianZhou -- vlc question deleted, should discuss on mailing list or IRC
Deleted lines 68-96:

Getting VLC to work Via diversion script (/unslung/rc.vlc):

Hi, I am a complete newbie to using the Slug and also Linux and am as such having trouble trying to get VLC media server to run whilst the NSLU2 is booting.

I have installed the unslung V6.8 and a number of ipkg's including VLC and all the other ipkg's it recomended.

my problem is I cannot get it to run on boot up. I have created the following diversion script called rc.vlc in the /unslung folder

(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 

#! /bin/sh
/opt/bin/vlc
return 1


(:tableend:)

I know it's pretty basic and probably needs extending but I think it should be enough to get vlc to work at least.

Could someone please tell me where I'm going wrong.

Thanks

Adam

October 04, 2007, at 06:15 PM by AdamG -- VLC Media Server Problems
Added lines 69-97:

Getting VLC to work Via diversion script (/unslung/rc.vlc):

Hi, I am a complete newbie to using the Slug and also Linux and am as such having trouble trying to get VLC media server to run whilst the NSLU2 is booting.

I have installed the unslung V6.8 and a number of ipkg's including VLC and all the other ipkg's it recomended.

my problem is I cannot get it to run on boot up. I have created the following diversion script called rc.vlc in the /unslung folder

(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 

#! /bin/sh
/opt/bin/vlc
return 1


(:tableend:)

I know it's pretty basic and probably needs extending but I think it should be enough to get vlc to work at least.

Could someone please tell me where I'm going wrong.

Thanks

Adam

February 26, 2007, at 12:53 PM by gothick -- s/usefull/useful/
Changed lines 49-50 from:

The default smb.conf file contains an erroneous entry username map = no which can safely be removed. The only effect of leaving this erroneus entry is regular error messages complaining about this line logged to the /var/log/samba/log.smbd file. This example makes use of the script text editor - sed - to 'search and delete' the erroneous line. Sed is also very usefull for 'search and replace' and 'search and insert' operations.

to:

The default smb.conf file contains an erroneous entry username map = no which can safely be removed. The only effect of leaving this erroneus entry is regular error messages complaining about this line logged to the /var/log/samba/log.smbd file. This example makes use of the script text editor - sed - to 'search and delete' the erroneous line. Sed is also very useful for 'search and replace' and 'search and insert' operations.

February 04, 2006, at 07:54 PM by Bob Quinn rcqsocketscom -- change directory from .../conf/unslung to .../data/unslung
Changed lines 5-6 from:

Diversion scripts can go into three places. The three locations are: /unslung (directory off the rootfs), /share/hdd/conf/unslung (directory off a hard drive enclosure), or /share/flash/conf/unslung (directory off a plugged in flash drive). These last two locations are used for "Pluggable Personalities" - meaning that the diversion scripts placed in those two locations are ONLY run when either the hard drive or flash drive is plugged in and recognized at boot time. If you always want a diversion script to run - independent of what disks/flash drives are plugged in, then put the diversion script into /unslung (you will have to create that directory first). WARNING: if you make a bad mistake with a diversion script in /unslung, you may have to reflash to fix the error.

to:

Diversion scripts can go into three places. The three locations are: /unslung (directory off the rootfs), /share/hdd/data/unslung (directory off a hard drive enclosure), or /share/flash/data/unslung (directory off a plugged in flash drive). These last two locations are used for "Pluggable Personalities" - meaning that the diversion scripts placed in those two locations are ONLY run when either the hard drive or flash drive is plugged in and recognized at boot time. If you always want a diversion script to run - independent of what disks/flash drives are plugged in, then put the diversion script into /unslung (you will have to create that directory first). WARNING: if you make a bad mistake with a diversion script in /unslung, you may have to reflash to fix the error.

October 12, 2005, at 11:39 PM by Peter J Holmes -- Was having a bad day!!! The error was a typo in my script NOT the WIKI
Changed line 38 from:

if ( [ ! -f /etc/inetd.conf ] || !(grep telnetd /etc/inetd.conf -q) ; then

to:

if ( [ ! -f /etc/inetd.conf ] || !(grep telnetd /etc/inetd.conf -q) ) then

October 03, 2005, at 08:37 PM by Peter J Holmes -- Error in \'Enable Telnet On Boot\' script ) instead of ; on line 2.
Changed line 38 from:

if ( [ ! -f /etc/inetd.conf ] || !(grep telnetd /etc/inetd.conf -q) ) then

to:

if ( [ ! -f /etc/inetd.conf ] || !(grep telnetd /etc/inetd.conf -q) ; then

August 24, 2005, at 11:36 AM by rcsuk -- Correct typo
Changed lines 5-6 from:

Diversion scripts can go into three places. The three locations are: /unslung (directory off the rootfs), /share/hdd/conf/unslung (directory off a hard drive enclosre), or /share/flash/conf/unslung (directory off a plugged in flash drive). These last two locations are used for "Pluggable Personalities" - meaning that the diversion scripts placed in those two locations are ONLY run when either the hard drive or flash drive is plugged in and recognized at boot time. If you always want a diversion script to run - independent of what disks/flash drives are plugged in, then put the diversion script into /unslung (you will have to create that directory first). WARNING: if you make a bad mistake with a diversion script in /unslung, you may have to reflash to fix the error.

to:

Diversion scripts can go into three places. The three locations are: /unslung (directory off the rootfs), /share/hdd/conf/unslung (directory off a hard drive enclosure), or /share/flash/conf/unslung (directory off a plugged in flash drive). These last two locations are used for "Pluggable Personalities" - meaning that the diversion scripts placed in those two locations are ONLY run when either the hard drive or flash drive is plugged in and recognized at boot time. If you always want a diversion script to run - independent of what disks/flash drives are plugged in, then put the diversion script into /unslung (you will have to create that directory first). WARNING: if you make a bad mistake with a diversion script in /unslung, you may have to reflash to fix the error.

August 20, 2005, at 03:25 PM by radale -- minor comment to Samba diversion
Changed line 68 from:

NOTE: Do not use this script or remove this line if you plan to implement user authentication and map Windows usernames to Unix usernames. In that case, you will need the username map file (maybe like /etc/samba/smbusers). See http://www.samba.org for documentation of usermap.

to:

NOTE: You shouldn't use this script or remove this line from the file if you plan to implement Samba user authentication and map Windows usernames to Unix usernames. In that case, you will need the username map file (maybe like '/etc/samba/smbusers'). See http://www.samba.org for documentation of usermap.

August 20, 2005, at 05:25 AM by radale --
Changed lines 68-69 from:

NOTE: Do not use this script or remove this line if you plan to implement user authentication and map Windows usernames to Unix usernames. In that case, you will need the username map file (maybe like /etc/samba/smbusers). See http://www.samba.org for documenation of usermap.

to:

NOTE: Do not use this script or remove this line if you plan to implement user authentication and map Windows usernames to Unix usernames. In that case, you will need the username map file (maybe like /etc/samba/smbusers). See http://www.samba.org for documentation of usermap.

August 20, 2005, at 05:16 AM by radale --
Deleted lines 66-67:

NOTE: Do not use this script to remove this line if you plan to implement use authentication and map Windows usernames to Unix usernames. In that case, you will need the username map file (maybe like /etc/samba/smbusers). See http://www.samba.org for documenation of usermap.

Added lines 68-69:

NOTE: Do not use this script or remove this line if you plan to implement user authentication and map Windows usernames to Unix usernames. In that case, you will need the username map file (maybe like /etc/samba/smbusers). See http://www.samba.org for documenation of usermap.

August 19, 2005, at 10:01 PM by Dale Hanych -- Samba conf warning per usermap removal
Added lines 67-68:

NOTE: Do not use this script to remove this line if you plan to implement use authentication and map Windows usernames to Unix usernames. In that case, you will need the username map file (maybe like /etc/samba/smbusers). See http://www.samba.org for documenation of usermap.

July 31, 2005, at 09:27 PM by RobHam -- Working example added to modify the Samba Config file using the - sed - script text editor
Changed lines 49-50 from:

The default smb.conf file contains an erroneous entry username map = no which can safely be removed. The only effect of leaving this erroneus entry is regular error messages complaining about this line logged to the /var/log/samba/log.smbd file. This example makes use of the script text editor - sed - to locate and delete the erroneous line. Sed is also very usefull for 'search and replace' and 'search and insert' operations.

to:

The default smb.conf file contains an erroneous entry username map = no which can safely be removed. The only effect of leaving this erroneus entry is regular error messages complaining about this line logged to the /var/log/samba/log.smbd file. This example makes use of the script text editor - sed - to 'search and delete' the erroneous line. Sed is also very usefull for 'search and replace' and 'search and insert' operations.

July 31, 2005, at 09:16 PM by RobHam -- Working example added to modify the Samba Config file using 'sed' script text editor.
Changed line 21 from:
  #!/bin/sh
to:
  #! /bin/sh
Changed lines 34-38 from:
  #!/bin/sh
  if ( [ ! -f /etc/inetd.conf ] || !(grep telnetd /etc/inetd.conf -q) ) then
    echo "telnet stream tcp nowait root /usr/sbin/telnetd" >> /etc/inetd.conf
  fi
  return 1
to:

(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 
#! /bin/sh
if ( [ ! -f /etc/inetd.conf ] || !(grep telnetd /etc/inetd.conf -q) ) then
echo "telnet stream tcp nowait root /usr/sbin/telnetd" >> /etc/inetd.conf
fi
return 1


(:tableend:)

Modify the Samba Config file - a working example diversion script (/unslung/rc.samba):

The default smb.conf file contains an erroneous entry username map = no which can safely be removed. The only effect of leaving this erroneus entry is regular error messages complaining about this line logged to the /var/log/samba/log.smbd file. This example makes use of the script text editor - sed - to locate and delete the erroneous line. Sed is also very usefull for 'search and replace' and 'search and insert' operations.

(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 
#! /bin/sh
# Diversion script: to modify the Samba smb.conf file
# First - make sure we have a backup copy of /etc/samba/smb.conf
if [ ! -e /etc/samba/smb.conf.orig ]; then 
cp -p /etc/samba/smb.conf  /etc/samba/smb.conf.orig 
fi
# Script section to delete the faulty username map line
#
sed -i -e '/username map \= no/d' /etc/samba/smb.conf
#
return 1


(:tableend:)

January 26, 2005, at 09:15 PM by ByronT --
Changed line 5 from:

Diversion scripts can go into three places. The three locations are: /unslung (directory off the rootfs), /share/hdd/conf/unslung (directory off a hard drive enclosre), or /share/flash/conf/unslung (directory off a plugged in flash drive). These last two locations are used for "Pluggable Personalities" - meaning that the diversion scripts placed in those two locations are ONLY run when either the hard drive or flash drive is plugged in and recognized at boot time. If you always want a diversion script to run - independent of what disks/flash drives are plugged in, then put the diversion script into /unslung (you will have to create that directory first). WARNING: if you make a bad mistake with a diverion script in /unslung, you may have to reflash to fix the error.

to:

Diversion scripts can go into three places. The three locations are: /unslung (directory off the rootfs), /share/hdd/conf/unslung (directory off a hard drive enclosre), or /share/flash/conf/unslung (directory off a plugged in flash drive). These last two locations are used for "Pluggable Personalities" - meaning that the diversion scripts placed in those two locations are ONLY run when either the hard drive or flash drive is plugged in and recognized at boot time. If you always want a diversion script to run - independent of what disks/flash drives are plugged in, then put the diversion script into /unslung (you will have to create that directory first). WARNING: if you make a bad mistake with a diversion script in /unslung, you may have to reflash to fix the error.

Changed line 7 from:
Note: In the old README and older versions of Unslung (anything prior to 3.16), /unslung was a symlinked directory to the /share/???/conf/unslung. With unslung 3.16 and later, that symlink DOES NOT need to exist (and should not exist) as any diversion script located in the pluggable locations will be run IF the hard drive or flash unit is plugged in and recognized at boot time.
to:
Note: In the old README and older versions of Unslung (anything prior to 3.16), /unslung was a symlinked directory to the /share/hdd/conf/unslung. With unslung 3.16 and later, that symlink DOES NOT need to exist (and should not exist) as any diversion script located in the pluggable locations will be run IF the hard drive or flash unit is plugged in and recognized at boot time.
January 26, 2005, at 06:43 PM by ByronT --
Changed line 1 from:

Diversion scripts can go into /unslung (directory off the rootfs), /share/hdd/conf/unslung (to be run only when that disk is plugged in before booting), or /share/flash/conf/unslung (to be run only when that flash is plugged in before booting). You may divert as many or as few scripts as you like. Simply add the name of the standard rc script into the appropriate /unslung directory and it will be run.

to:

Diversion Script Information

Changed lines 3-13 from:

For example, I have a script /unslung/rc.local:

to:

Diversion scripts are used to start packages, set variables or function definitions at the time of the NSLU2 boot. They "divert" the normal boot scripts to perform the needed action(s) and then can either "return 1" to continue normal factory script progress or "return 0" to abort the factory script.

Diversion scripts can go into three places. The three locations are: /unslung (directory off the rootfs), /share/hdd/conf/unslung (directory off a hard drive enclosre), or /share/flash/conf/unslung (directory off a plugged in flash drive). These last two locations are used for "Pluggable Personalities" - meaning that the diversion scripts placed in those two locations are ONLY run when either the hard drive or flash drive is plugged in and recognized at boot time. If you always want a diversion script to run - independent of what disks/flash drives are plugged in, then put the diversion script into /unslung (you will have to create that directory first). WARNING: if you make a bad mistake with a diverion script in /unslung, you may have to reflash to fix the error.

Note: In the old README and older versions of Unslung (anything prior to 3.16), /unslung was a symlinked directory to the /share/???/conf/unslung. With unslung 3.16 and later, that symlink DOES NOT need to exist (and should not exist) as any diversion script located in the pluggable locations will be run IF the hard drive or flash unit is plugged in and recognized at boot time.

You may divert as many or as few scripts as you like. Simply add the name of the standard rc script into the appropriate /unslung directory and it will be run.

Diversion Script Programming

Example: I have a script /unslung/rc.local:

Changed lines 29-30 from:

DIVERSION SCRIPT EXAMPLES

to:

Specific Diversion Script Examples

[Append further script examples to bottom of page]
Changed lines 35-37 from:
  echo "telnet  stream  tcp     nowait  root    /usr/sbin/telnetd" > /etc/inetd.conf
  # Additional lines must append (using >>), ie:
  # echo "ftp   stream  tcp     nowait  root    /usr/sbin/ftpd -a=passwd" >> /etc/inetd.conf
to:
  if ( [ ! -f /etc/inetd.conf ] || !(grep telnetd /etc/inetd.conf -q) ) then
    echo "telnet stream tcp nowait root /usr/sbin/telnetd" >> /etc/inetd.conf
  fi
January 13, 2005, at 06:34 PM by ByronT --
Changed line 22 from:

""Enable Telnet On Boot"" diversion script (/unslung/rc.xinetd):

to:

Enable Telnet On Boot diversion script (/unslung/rc.xinetd):

January 13, 2005, at 06:31 PM by ByronT --
Changed line 22 from:

Enable Telnet on boot diversion script (/unslung/rc.xinetd):

to:

""Enable Telnet On Boot"" diversion script (/unslung/rc.xinetd):

January 08, 2005, at 07:00 AM by ByronT --
Changed line 22 from:

Enable Telnet on boot diversion script:

to:

Enable Telnet on boot diversion script (/unslung/rc.xinetd):

January 08, 2005, at 03:27 AM by ByronT --
Changed line 22 from:

Enable Telnet on boot diversion script

to:

Enable Telnet on boot diversion script:

January 08, 2005, at 03:27 AM by ByronT --
Changed lines 1-28 from:

Describe DiversionScripts here.

to:

Diversion scripts can go into /unslung (directory off the rootfs), /share/hdd/conf/unslung (to be run only when that disk is plugged in before booting), or /share/flash/conf/unslung (to be run only when that flash is plugged in before booting). You may divert as many or as few scripts as you like. Simply add the name of the standard rc script into the appropriate /unslung directory and it will be run.

For example, I have a script /unslung/rc.local:

  #! /bin/sh
  /opt/bin/do_foo
  return 1

That will run at the beginning of the normal /etc/rc.d/rc.local, and then the rest of the factory rc.local will be executed. If I do NOT want to run the factory rc.local, my script would be:

  #!/bin/sh
  /opt/bin/do_foo
  return 0

That is, if the diversion script returns with something other than 0, it will run the rest of the factory script.

Note that any variable definitions or function declarations are allowed to happen before the diversion script is called. This allows you to use the variables and functions defined by the factory script.

DIVERSION SCRIPT EXAMPLES

Enable Telnet on boot diversion script

  #!/bin/sh
  echo "telnet  stream  tcp     nowait  root    /usr/sbin/telnetd" > /etc/inetd.conf
  # Additional lines must append (using >>), ie:
  # echo "ftp   stream  tcp     nowait  root    /usr/sbin/ftpd -a=passwd" >> /etc/inetd.conf
  return 1
view · edit · print · history · Last edited by ShadowJK.
Based on work by BrianZhou, AdamG, gothick, Bob Quinn rcqsocketscom, Peter J Holmes, rcsuk, radale, Dale Hanych, RobHam, and ByronT.
Originally by ByronT.
Page last modified on December 23, 2007, at 05:28 PM