LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-22-2011, 02:43 AM   #1
NeilJ
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Rep: Reputation: 0
Configure Slackware derivative automatically for large network


I am responsible for the prepararation and installation of a large network of machines running a Slackware derivative.

I am currently configuring these machines manually and need a way to streamline the operation.

The various things I have to confiure are:

* IP addresses in rc.inet1.conf
* various system paramenters, peripheral IP addresses, ports etc in a file called registry.txt
* Site and User ID numbers into two seperate txt files

Ideally it would be nice to be able to use a standard form with prompt boxes that is filled in at config time. When everything is filled in, a script is run that extracts the relevant data and automatically edits the various files.

I have looked at using SED but cannot find a way to extract the required information from the initial "configuration" file.

I look forward to your suggestions.

Thanks
 
Old 04-23-2011, 05:50 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello NeilJ,

I have some questions. Why do you post this issue in the Desktop-forum of LQ. I think "Server" or "Slackware" would be more suitable. You may use the "report" button and ask a Moderator to move this thread to the appropriate forum.

Don't you use DHCP? Slackware comes with a PXE installer, it should be easy to create an image of a preconfigured Slackware-machine and boot this via network. But I think this would require DHCP in your network.

In order to distribute settings to many computers it may be a solution to pack all the scripts into one tar file which is to be executed in the / directory so that every file ends up in the right place.

Markus
 
Old 04-24-2011, 02:55 AM   #3
NeilJ
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by markush View Post
Hello NeilJ,

I have some questions. Why do you post this issue in the Desktop-forum of LQ. I think "Server" or "Slackware" would be more suitable. You may use the "report" button and ask a Moderator to move this thread to the appropriate forum.

Don't you use DHCP? Slackware comes with a PXE installer, it should be easy to create an image of a preconfigured Slackware-machine and boot this via network. But I think this would require DHCP in your network.

In order to distribute settings to many computers it may be a solution to pack all the scripts into one tar file which is to be executed in the / directory so that every file ends up in the right place.

Markus
I apologise for upsetting the applecart but, because the question is not related only to Slackware, I thought this forum would be able to help.

This is an embedded system that cannot use DHCP.

All I want to know is how to extract information out of one file and use that information to edit other files.

Neil
 
Old 04-24-2011, 03:25 AM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Quote:
Originally Posted by NeilJ View Post
...All I want to know is how to extract information out of one file and use that information to edit other files...
Well, I think that a tar file is the solution. On a device which is completely configured with all the necessary files go to the / directory and create a tar-archive with all this files. When you copy this tar file onto a new machine into the / directory and extract the archive, all the files will be in the right places.

If you need different configurations for the devices, you may look at the manpage for tar, as far as I know one can remove and add single files from a tar-archive.

For the whole system you may as well use an image. Look at clonezilla or use the dd-command, there is an interessting link: http://softpanorama.org/Tools/dd.shtml

BTW: I did not realize that you have a Slackware-derivative on an embedded device, but hope that I could help.

Good luck

Markus
 
Old 04-24-2011, 06:42 AM   #5
foottuns
Member
 
Registered: Nov 2009
Location: London
Distribution: Fedora 16
Posts: 92

Rep: Reputation: 17
Why don't you create an image from one PC with CloneZilla and after that you can deploy through network to all of your PC's.
 
Old 04-24-2011, 08:54 AM   #6
NeilJ
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by foottuns View Post
Why don't you create an image from one PC with CloneZilla and after that you can deploy through network to all of your PC's.
Thanks for your help.

I am already creating "clones" - using dd. Every suystem starts off being identical. I plug the Disk Module into an adapter, run dd (copying an image file to the solid state Disk Module) and then, edit the disk module using gedit (so we do not have to use vi which can be problematic).

The problem is that every site has different parameters as I mentioned in my first post. The IP, of two ports plus the gateway, the IP's of the peripherals - there can be up to eight of these and they must all be unique (within a certain range in each site), unique site and user ID's - all stored in different files.

At the moment I manually edit each file (unique in each system) in turn to prepare the systems.

I wanted to have a standard for (even a sprreadsheet) that the admin department filled out and then simply run a script which would take this information and edit the files automatically.

SED seemed to be promising, but I cannot find a way to extract data from a file. There is no problem editing the file with data in each SED statement - but to get that unique data into the SED command is the problem.

Thought it would be easy!

Thanks again.

Neil
 
Old 04-24-2011, 02:49 PM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Are these devices on the same network, or configured and shipped.

One tool that manages configurations on a large network is cfengine. It is designed to work on large heterogeneous networks.

---
You mentioned that you are creating clones of an image, onto devices, and then editing files that are on the device.
It's possible to mount a clone of the image before writing them to a device (loop device) and edit the files locally.

---
Sed and awk are often used to edit configuration files. Awk is good for highly structured text tables. I think the first part, reading the configuration filename and the modification to make from a table, may be better done by awk then sed.

In sed, you can use the form sed '/pattern in line to edit/s/oldpattern/newpattern/' file. The first pattern will select which line to edit.

This could be done in a script where the pattern, s command LFS, and RFS values are variables.
sed "/$PAT/s/$OLDPAT/$NEWPAT/q" "$file". The variable values could be extracted from a database text file.

One trick I often use is to have a sed script extract the information I use in the form of bash assignment, and then use eval to create these variables. For example, I have a script to convert OGG files to MP3s. A function extracts information about ogg files returning tag values in VARIABLE=value form. The output of the function is eval'ed, setting the variables, which are used as arguments to a command setting the tags.

Another possibility is to use HERE documents to create the configuration files on the target.
HERE documents take their input from text in the script.
Code:
~> cat genfiles.sh
IPADDR1='192.168.2.100'
IPADDR2='192.168.2.110'
HOSTNAME1=dopey.site
HOSTNAME2=sleepy.site
ALIAS1=${HOSTNAME1%%.*}
ALIAS2=${HOSTNAME2%%.*}

cat >hosts <<- EOF
        #
        # hosts         This file describes a number of hostname-to-address
        #               mappings for the TCP/IP subsystem.  It is mostly
        #               used at boot time, when no name servers are running.
        #               On small systems, this file can be used instead of a
        #               "named" name server.
        # Syntax:
        #    
        # IP-Address  Full-Qualified-Hostname  Short-Hostname
        #

        127.0.0.1       localhost

        # special IPv6 addresses
        ::1             localhost ipv6-localhost ipv6-loopback

        fe00::0         ipv6-localnet

        ff00::0         ipv6-mcastprefix
        ff02::1         ipv6-allnodes
        ff02::2         ipv6-allrouters
        ff02::3         ipv6-allhosts
        127.0.0.2       $HOSTNAME1      $ALIAS1 
        $IPADDR1        $HOSTNAME1      $ALIAS1 
        $IPADDR2        $HOSTNAME2      $ALIAS2 
EOF

cat >HOSTNAME <<- EOF
        $HOSTNAME1
EOF
Code:
~> cat hosts
#
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.
# Syntax:
#    
# IP-Address  Full-Qualified-Hostname  Short-Hostname
#

127.0.0.1       localhost

# special IPv6 addresses
::1             localhost ipv6-localhost ipv6-loopback

fe00::0         ipv6-localnet

ff00::0         ipv6-mcastprefix
ff02::1         ipv6-allnodes
ff02::2         ipv6-allrouters
ff02::3         ipv6-allhosts
127.0.0.2       dopey.site      dopey 
192.168.2.100   dopey.site      dopey 
192.168.2.110   sleepy.site     sleepy
Code:
cat HOSTNAME
dopey.site
Here I parametrized the values which would change from one device to another. The variable values could have been read in by `read' or `awk' or `sed', or sourced from a file with a bunch of NAME=VALUE entries. This script has 2 HERE documents, creating hosts and hostname. I removed the "/etc/" from target filenames to prevent modifying the real files for a real test.

A spreadsheet could be exported to a csv file. Or you could use libreoffice and use xsltproc in a script, to translate the tables to a text table that your script can read in.

You could use variables of the form FILENAME_VARIABLE to prevent collisions.

---
Sed also has other commands that can insert lines or add lines. You could match a comment line in a template file and add a line after it with sed's 'a' command.

You can also have template files with dummy values that sed can find easily, and replace with real values.

_UNIT10_IPADDRESS_ _UNIT10_HOSTNAME_ _UNIT10_ALIAS_

Last edited by jschiwal; 04-24-2011 at 03:24 PM.
 
Old 04-25-2011, 02:24 AM   #8
NeilJ
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you jschiwal!

This is what I was looking for - I am sure I can get something going from all the inforamtion and examples provided.
 
Old 04-25-2011, 11:39 AM   #9
foottuns
Member
 
Registered: Nov 2009
Location: London
Distribution: Fedora 16
Posts: 92

Rep: Reputation: 17
one short question? what about if you create a image server. and let's say you have your image on your server and all you need is to boot through network and before the installation you can run your script and also edit the IP parameters as required.

regarding to SED and extracting the data from your files at the moment I don't have any info but once done I will share it with you...

Last edited by foottuns; 04-25-2011 at 11:52 AM.
 
Old 04-26-2011, 05:21 AM   #10
NeilJ
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks for your interest Footuns!

It is an embedded system - the nework is very limited and very restricted because of finacial information being transferred. Unfortunately, I cannot give out too many details of the system because of these restrictions.

I have to prepare each system's Solid State Hard Disk Module in a controlled environment. Once this is done, the Hard Disk Module is plugged into the system (it does not have a keyboard or screen) and the system goes out to be installed.

I am keeping an image of each site in case of any breakdown in the field. Thus it will be easy to create a new drive for any site that needs it.

I simply want to make the process of preparing the site specific Disk Module quicker and more reliable than the manual process.
 
Old 04-26-2011, 06:42 AM   #11
foottuns
Member
 
Registered: Nov 2009
Location: London
Distribution: Fedora 16
Posts: 92

Rep: Reputation: 17
no problem, i know what you mean, i build once a cluster and had the same problem so in the end i choose to go with rocks cluster, in this way the work was easy and not headaches... hope you will find your way...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Making Slackware and Slackware Derivative Linux Distros Speak Your Language LXer Syndicated Linux News 0 01-29-2009 12:30 AM
HOWTO configure new network card in Slackware 12.1?? Cuetzpallin Slackware 17 06-02-2008 11:58 AM
How do I get X to automatically configure/re-configure at boot? BaptismOfFire Linux - Hardware 4 08-08-2005 09:37 AM
how to configure my network on slackware 10.0 so i can access a windows network salviadud Linux - Newbie 2 02-11-2005 01:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 02:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration