This section is intended for those who are familiar with Linux based systems. If you are just learning Linux, it is recommended that you skip this section for now and come back to it later when you feel a bit more comfortable at the command line.
After using the Network Security Toolkit for awhile, you'll find yourself wishing their was a means to simplify the initialization process. If you have a thumb drive, flash drive, floppy disk, a hard disk, or even a web server, you are in luck - the lnstcustom command can simplify your setup.
It should be noted, that this automation is not completely hands free. You will need to invoke lnstcustom each time you boot, but you won't have to type much else.
You need to be familiar with writing bash (or sh) scripts prior to doing much automating. However, the Network Security Toolkit makes an excellent environment to hone those scripting skills.
This section is going to walk you through the creation
of a simple setup.sh script that can be
used by lnstcustom to automate the
following:
Changing the default password.
Starting X.
After following these steps, you should be able to boot the Network Security Toolkit, log in, plug in your thumb drive, and type the following command:
[root@probe root]#lnstcustom test
After typing the above, you should see that the password is being changed, and after what seems a long time, the X desktop should come up (you will be be presented with the X configuration utility the first time invoked, but it will remember your settings for future invocations).
For this example, I'm going to borrow my wife's Creative Muvo Nomad MP3 player which also acts as a standard thumb drive (do me a favor and don't mention this to my wife). After plugging the MP3 player into a USB port, the following commands are entered:
[root@probe root]#mount -t vfat /dev/sda1 /mnt/memstick![]()
[root@probe root]#mkdir /mnt/nst/test![]()
[root@probe root]#jed /mnt/nst/test/setup.sh
This mount command will work
for many thumb drives, however, you may need to change
the | |
This command creates a directory for our "test"
customization. This means we will need to specify
| |
This line is used to edit the
|
Here are the commands we will type into the
setup.sh script.
#!/bin/bash printf "letmein\nletmein\n" | nstpasswdif [ -f "$NSTHOME/XF86Config" ]; then
cp "$NSTHOME/XF86Config" "/etc/X11" /etc/rc.d/init.d/xfs start startx else
setup_x if [ -f "/etc/X11/XF86Config" ]; then cp "/etc/X11/XF86Config" "$NSTHOME/" startx fi fi
This line makes use of the
printf command to print the word
| |
This section checks to see if a configuration file for X is already available on the thumb drive. If it is, it copies it to the proper location, starts the X font server, and then starts X. | |
This section is run if a configuration file is needed for X in this case, we invoke the setup_x command to configure our system, save the configuration created (so we won't have to next time), and then start X. |
The above assumes that you will be using the
X configuration on the same
system (or another system with identical hardware). NEVER
use a X configuration created for
one system on a different system (you may damage
something). If you plan on using the same thumb drive on
different systems, you should create a different directory
for each system, or change the setup.sh
script such that it ALWAYS invokes
setup_x before invoking
startx.
After saving the file (Control-X Control-S) and leaving the editor (Ctonrol-X Control-C), we will find ourselves back at the command prompt ready to try out the customization.
[root@probe root]#umount /mnt/memstick![]()
[root@probe root]#lnstcustom test sda1 vfat... Lots of output as passwords are changed and X starts ...
Before trying out our custom setup script we will umount the thumb drive (as it wouldn't have been mounted if we just started the system). | |
We invoke the lnstcustom
command specifying the name of the directory that our
|
This should be enough information to get you started in
creating your own customization scripts. You can do a lot if
you use your imagination and just keep adding to your
setup.sh script.
Whether you are using lnstcustom with a thumb drive, hard drive, floppy or some other type of hard disk, the basic concept and preparation is the same. However, if you want to use the lnstcustom with a web server, there are some differences:
The entire customization directory must be archived into
a single tar.gz file.
You won't be able to easily write any changes back (in the previous example, the thumb drive was able to "learn" by simply copying a configuration file if the user adjusted it).
Assuming you still have your thumb drive mounted from
the previous session, the following is all that is required to
create and install the custom configuration on a fictional web
server 192.168.0.17:
[root@probe root]#tar czf /tmp/test.tgz -C /mnt/nst test[root@probe root]#tar tzf /tmp/test.tgztest/ test/XF86Config test/setup.sh[root@probe root]#scp /tmp/test.tgz root@192.168.0.17:/var/www/htmlWarning: Permanently added '192.168.0.17' (RSA) to the list of known hosts. root@192.168.0.17's password: test.tgz 100% |*****************************| 1633 00:00[root@probe root]#
Now that we've created and installed our custom setup on a web server, lets try it out. Let's reboot the Network Security Toolkit probe, remove the thumbdrive, log back in, and then invoke lnstcustom in the following manner:
[root@probe root]#lnstcustom test http://192.168.0.17/test.tgz... Lots of output - X finally comes back up ...
That's about all there is to it. We now have our custom
setup.sh script available on the
network.
You should be careful when using this method for loading Network Security Toolkit customization scripts. NEVER load someone else's customization script as you are handing them the keys to your system. You should also avoid placing any plain text passwords or security sensitive data in customization scripts placed on the network (as it will probably be possible for someone to find your files and view them).