Difference between revisions of "Lissetup.sh"


From Knoppix Documentation Wiki
Jump to: navigation, search
m
(I lost the TOC. It was added.)
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
__TOC__
 +
= Introduction =
 +
 +
Please pay attention when you copy this script.  There are three for commands that span several lines for formating here.  The last line of each of these commands must end with a backslash, '''\'''.  The backslash must be the very last character on the line!  Even a space after the backslash will make the script useless.
 +
 +
= [[lissetup.sh]] code listing =
 +
 +
<!--Note to editors:  You must have a pre tag start and ending this code.  Also note the leading space.  Mediawiki sets this off in a box if a space starts each line.  -->
 +
<pre>
 +
 
  #!/bin/bash
 
  #!/bin/bash
 +
#
 +
# lissetup.sh
 +
#
 
  # This is a script for automated configuration of
 
  # This is a script for automated configuration of
 
  # lisa daemon for live cd linux like morphix or
 
  # lisa daemon for live cd linux like morphix or
Line 7: Line 20:
 
  #
 
  #
 
  # Made by Gasper Zejn <mk-klavz at owca dot info>
 
  # Made by Gasper Zejn <mk-klavz at owca dot info>
  # for ttp://linux.slo-tech.com
+
  # for http://linux.slo-tech.com
 
  #
 
  #
 
  # last change: 12.mar.2004
 
  # last change: 12.mar.2004
Line 16: Line 29:
 
  #location of ifconfig
 
  #location of ifconfig
 
  IFCONFIG=/sbin/ifconfig
 
  IFCONFIG=/sbin/ifconfig
 
 
 
   
 
   
 
  #first kill running instances of lisa deamon (if they're running)
 
  #first kill running instances of lisa deamon (if they're running)
  <nowiki>PROCNUM=`ps ax | grep lisa | grep -v grep | awk '{print $1 }'`/nowiki><br>
+
  PROCNUM=`ps ax | grep lisa | grep -v grep | awk '{print $1 }'`
 
  kill -9 $PROCNUM $1 > /dev/null $2 > /dev/null
 
  kill -9 $PROCNUM $1 > /dev/null $2 > /dev/null
 
   
 
   
Line 29: Line 40:
 
  # for loop if there are multiple network cards with
 
  # for loop if there are multiple network cards with
 
  # similar addresses
 
  # similar addresses
  <nowiki>for NET in `$IFCONFIG |grep addr:10. | awk '{ split($0,a,":"); print a[awk '{split($0,b," ");</nowiki><br>
+
  for NET in `$IFCONFIG |grep addr:10. | \
<nowiki>printf "%s/%s\n",b[[3 [2]],a[[3]],a[[4]] }']],b[[5]] }'`</nowiki><br>
+
    awk '{ split($0,a,":"); print a[awk '{split($0,b," "); \
 +
    printf "%s/%s\n",b[[3 [2]],a[[3]],a[[4]] }']],b[[5]] }'`
 
  do
 
  do
<nowiki> if [[ -z $NETWORKS ]]</nowiki><br>
+
if [[ -z $NETWORKS ]]
 
  then
 
  then
 
  NETWORKS=$NET
 
  NETWORKS=$NET
Line 42: Line 54:
 
   
 
   
 
  # 192.168.x.x/16
 
  # 192.168.x.x/16
  <nowiki>for NET in `$IFCONFIG |grep addr:192.168. | awk '{ split($0,a,":"); print a[awk '{split($0,b," ");/nowiki><br>
+
  for NET in `$IFCONFIG |grep addr:192.168. | \
<nowiki>printf "%s/%s\n", b[[3 [2]],a[[3]],a[[4]] }']],b[[5]]}'`</nowiki><br>
+
    awk '{ split($0,a,":"); \
 +
        print a[awk '{split($0,b," "); \
 +
      printf "%s/%s\n", b[[3 [2]],a[[3]],a[[4]] }']],b[[5]]}'`
 
  do
 
  do
  <nowiki>if [[ -z $NETWORKS ]]</nowiki><br>
+
  if [[ -z $NETWORKS ]]
 
  then
 
  then
 
  NETWORKS=$NET
 
  NETWORKS=$NET
Line 54: Line 68:
 
  # 172.16x.x.x/12
 
  # 172.16x.x.x/12
 
   
 
   
  <nowiki>for NET in `$IFCONFIG |grep addr:172. | awk '{ split($0,a,":"); print a[awk '{split($0,b," ");</nowiki><br>
+
  for NET in `$IFCONFIG |grep addr:172. |  
<nowiki>printf "%s/%s\n", b[[3 [2]],a[[3]],a[[4]]}']],b[[5]]}'`</nowiki><br>
+
  awk '{ split($0,a,":"); \
 +
      print a[awk '{split($0,b," "); \
 +
      printf "%s/%s\n", b[[3 [2]],a[[3]],a[[4]]}']],b[[5]]}'`
 
  do
 
  do
  <nowiki>RANGE=`echo $NET | awk '{ split($0,a,"."); print a[[2]] }'`</nowiki><br>
+
  RANGE=`echo $NET | awk '{ split($0,a,"."); print a[[2]] }'`
  <nowiki>if [[ -n RANGE ]]</nowiki><br>
+
  if [[ -n RANGE ]]
 
  then
 
  then
  <nowiki>if [[ $RANGE -le 32 ]]</nowiki><br>
+
  if [[ $RANGE -le 32 ]]
 
  then
 
  then
<nowiki> if [[ $RANGE -ge 16 ]]</nowiki><br>
+
if [[ $RANGE -ge 16 ]]
 
  then
 
  then
<nowiki> if [[ -z $NETWORKS ]]</nowiki><br>
+
if [[ -z $NETWORKS ]]
 
  then
 
  then
 
  NETWORKS=$NET
 
  NETWORKS=$NET
Line 75: Line 91:
 
  done
 
  done
 
   
 
   
  <nowiki># then create a new conf file with correct info</nowiki><br>
+
  # then create a new conf file with correct info
  <nowiki>rm $LISA</nowiki><br>
+
  rm $LISA
  <nowiki>touch $LISA</nowiki><br>
+
  touch $LISA
  <nowiki>echo [[Second Wait]] = -1 >> $LISA #ping only once</nowiki><br>
+
  echo [[Second Wait]] = -1 >> $LISA #ping only once
  <nowiki>echo [[Search UsingNmblookup]] = 1 >> $LISA</nowiki><br>
+
  echo [[Search UsingNmblookup]] = 1 >> $LISA
  <nowiki>echo [[Deliver UnnamedHosts]] = 1 >> $LISA</nowiki><br>
+
  echo [[Deliver UnnamedHosts]] = 1 >> $LISA
  <nowiki>echo [[First Wait]] = 100 >> $LISA #wait 1 second for reply</nowiki><br>
+
  echo [[First Wait]] = 100 >> $LISA #wait 1 second for reply
  <nowiki>echo [[Max PingsAtOnce]] = 256 >> $LISA</nowiki><br>
+
  echo [[Max PingsAtOnce]] = 256 >> $LISA
  <nowiki>echo [[Update Period]] = 300 >> $LISA</nowiki><br>
+
  echo [[Update Period]] = 300 >> $LISA
  <nowiki>echo -e "[[Ping Addresses]] = $NETWORKS" >> $LISA</nowiki><br>
+
  echo -e "[[Ping Addresses]] = $NETWORKS" >> $LISA
  <nowiki>echo -e "[[Allowed Addresses]] = $NETWORKS" >> $LISA</nowiki><br>
+
  echo -e "[[Allowed Addresses]] = $NETWORKS" >> $LISA
  <nowiki>echo -e "[[Broadcast Network]] = $NETWORKS" >> $LISA</nowiki><br>
+
  echo -e "[[Broadcast Network]] = $NETWORKS" >> $LISA
  <nowiki>echo [[Ping Names]] = >> $LISA</nowiki><br>
+
  echo [[Ping Names]] = >> $LISA
 
   
 
   
 
  #start lisa if network card has a private address
 
  #start lisa if network card has a private address
Line 94: Line 110:
 
   
 
   
 
  #End of script
 
  #End of script
 +
</pre>
 +
 +
 +
= [[lissetup.sh]] Install Instructions =
 +
 +
 +
# Use your editor to create a file called [[lissetup.sh]]. 
 +
# Paste the contents of this wiki page into the file.
 +
# Save the file.
 +
# Make the file executible with the change mod command, chmod.
 +
 +
chmod ugo+x lissetup.sh
 +
 +
 +
[[Category:Useful Linux Commands]]
 +
[[Category:Useful knoppix Commands]]

Latest revision as of 06:54, 19 September 2005

Introduction

Please pay attention when you copy this script. There are three for commands that span several lines for formating here. The last line of each of these commands must end with a backslash, \. The backslash must be the very last character on the line! Even a space after the backslash will make the script useless.

lissetup.sh code listing


 #!/bin/bash
 #
 # lissetup.sh
 #
 # This is a script for automated configuration of
 # lisa daemon for live cd linux like morphix or
 # knoppix. I you find it useful, go ahead, use it.
 # It requires root priviliges due to kill and
 # restart of lisa daemon.
 #
 # Made by Gasper Zejn <mk-klavz at owca dot info>
 # for http://linux.slo-tech.com
 #
 # last change: 12.mar.2004
 #
 
 #location of lisarc conf file
 LISA=/etc/lisarc
 #location of ifconfig
 IFCONFIG=/sbin/ifconfig
 
 #first kill running instances of lisa deamon (if they're running)
 PROCNUM=`ps ax | grep lisa | grep -v grep | awk '{print $1 }'`
 kill -9 $PROCNUM $1 > /dev/null $2 > /dev/null
 
 
 #then get eth settings for private networks
 #########
 # 10.x.x.x/8
 # for loop if there are multiple network cards with
 # similar addresses
 for NET in `$IFCONFIG |grep addr:10. | \
    awk '{ split($0,a,":"); print a[awk '{split($0,b," "); \
    printf "%s/%s\n",b[[3 [2]],a[[3]],a[[4]] }']],b[[5]] }'`
 do
 	if [[ -z $NETWORKS ]]
 	then
 		NETWORKS=$NET
 	else
 		NETWORKS=${NETWORKS}\;${NET}
 	fi
 done
 
 
 # 192.168.x.x/16
 for NET in `$IFCONFIG |grep addr:192.168. | \
    awk '{ split($0,a,":"); \
        print a[awk '{split($0,b," "); \
       printf "%s/%s\n", b[[3 [2]],a[[3]],a[[4]] }']],b[[5]]}'`
 do
 	if [[ -z $NETWORKS ]]
 	then
 		NETWORKS=$NET
 	else
 		NETWORKS=${NETWORKS}\;${NET}
 	fi
 done
 # 172.16x.x.x/12
 
 for NET in `$IFCONFIG |grep addr:172. | 
   awk '{ split($0,a,":"); \
      print a[awk '{split($0,b," "); \
      printf "%s/%s\n", b[[3 [2]],a[[3]],a[[4]]}']],b[[5]]}'`
 do
 RANGE=`echo $NET | awk '{ split($0,a,"."); print a[[2]] }'`
 if [[ -n RANGE ]]
 then
 	if [[ $RANGE -le 32 ]]
 	then
 	if [[ $RANGE -ge 16 ]]
 		then
 			if [[ -z $NETWORKS ]]
 			then
 				NETWORKS=$NET
 			else
 				NETWORKS=${NETWORKS}\;${NET}
 			fi
 		fi
 	fi
 fi
 done
 
 # then create a new conf file with correct info
 rm $LISA
 touch $LISA
 echo [[Second Wait]] = -1 >> $LISA			#ping only once
 echo [[Search UsingNmblookup]] = 1 >> $LISA
 echo [[Deliver UnnamedHosts]] = 1 >> $LISA
 echo [[First Wait]] = 100 >> $LISA			#wait 1 second for reply
 echo [[Max PingsAtOnce]] = 256 >> $LISA
 echo [[Update Period]] = 300 >> $LISA
 echo -e "[[Ping Addresses]] = $NETWORKS" >> $LISA
 echo -e "[[Allowed Addresses]] = $NETWORKS" >> $LISA
 echo -e "[[Broadcast Network]] = $NETWORKS" >> $LISA
 echo [[Ping Names]] = >> $LISA
 
 #start lisa if network card has a private address
 
 /usr/sbin/lisa &
 
 #End of script


lissetup.sh Install Instructions

  1. Use your editor to create a file called lissetup.sh.
  2. Paste the contents of this wiki page into the file.
  3. Save the file.
  4. Make the file executible with the change mod command, chmod.
chmod ugo+x lissetup.sh