Drivers script
-
@george1421 i finding something odd:
[Wed Jun 01 root@fogclient ~]#
[Wed Jun 01 root@fogclient ~]# machine=dmidecode -s system-product-name
;
[Wed Jun 01 root@fogclient ~]# ${machine}
-sh: OptiPlex: command not foundSo with the tick marks at the start and end of the command it doesn’t seem to resolve the rest, so then i added " marks instead and i got this:
[Wed Jun 01 root@fogclient ~]# machine=“dmidecode -s system-product-name”
[Wed Jun 01 root@fogclient ~]# ${machine}
OptiPlex 790then i tried to run the remove spaces and it didn’t appears to remove the space.
[Wed Jun 01 root@fogclient ~]# machine=“${machine%”${machine##*[![:space:]]}“}”;
[Wed Jun 01 root@fogclient ~]# ${machine}
OptiPlex 790
[Wed Jun 01 root@fogclient ~]#More so, why would the tick marks you have in your scirpt cause this, but quotes provide the output. If for some reason the ticks are giving a partial name, maybe thats why it can’t find the drivers, because it doesn’t populate the ln command correctly. Not sure why I am having a hard time with this. does this make sense?
Furthermore, looking at your script and Lee’s, the tick marks are there, which seems to me they should work, but I have no clue why they are for me.
-
will on the dmidecod… the back ticks tell bash to take the output of the dmidecode command and set the variable machine to that value.
for your output you might want to
echo ${machine}
Since how you have it, bash thinks you want to run a command called OptiPlex with a single parameter of 790. Very useful in other situations, but for you not so much.The space removal command is a bit of bash regular expression magic that will blow your mind if I try to explain it because of all of the short hand junk that it contains. It does work.
-
[Wed Jun 01 root@fogclient /tmp]# osdiskpart=“/dev/sda2”;
[Wed Jun 01 root@fogclient /tmp]# driverver=“Win7”
[Wed Jun 01 root@fogclient /tmp]# osdiskpart=“/dev/sda2”;
[Wed Jun 01 root@fogclient /tmp]# driverver=“Win7”
[Wed Jun 01 root@fogclient /tmp]# mkdir /ntfs 2>/dev/null
[Wed Jun 01 root@fogclient /tmp]# mount.ntfs-3g “${osdiskpart}” /ntfs 2>/tmp/mntfail
[Wed Jun 01 root@fogclient /tmp]# mkdir /ntfs/Drivers 2>/dev/null
[Wed Jun 01 root@fogclient /tmp]# mkdir /ntfs/Drivers/TEST 2>/dev/null
[Wed Jun 01 root@fogclient /tmp]# cd /ntfs/Drivers/
[Wed Jun 01 root@fogclient /ntfs/Drivers]# dir
TEST machine.txt
[Wed Jun 01 root@fogclient /ntfs/Drivers]# nano machine.txt
-sh: nano: command not found
[Wed Jun 01 root@fogclient /ntfs/Drivers]# vi machine.txt
[Wed Jun 01 root@fogclient /ntfs/Drivers]# vi machine.txt
[Wed Jun 01 root@fogclient /ntfs/Drivers]# rm -f /tmp/mydrivers;
[Wed Jun 01 root@fogclient /ntfs/Drivers]# ln -s “/images/Drivers/${driverver}/${machine}/${setarch}/” /tmp/mydrivers;
[Wed Jun 01 root@fogclient /ntfs/Drivers]# if [ -d “/tmp/mydrivers” ]then
cp -r /tmp/mydrivers/* /ntfs/Drivers;
else
fi
-sh: syntax error near unexpected token `fi’Everything seems to go smoothly until the bottom. I was able to cd into the ntfs mount, and create and new folder called TEST, and view the machine.txt. Ihave tried with a space in the model name. no space. Here is the file structure as well: (they all have spaces in them currently, but I am working with the 790)
-
@adukes40 OK it looks like where it failed was the directory test (you can’t type that in via command line). Manually check to see if /tmp/mydrivers directory exists. If it does then execute the cp command.
FWIW
if [ -d “/tmp/mydrivers”] check looks for a directory
if [ -f “/tmp/mydrivers”] check looks for a file named mydrivers in the /tmp directory
Both are conditional checks to make sure things exist in the filesystem.
-
Looks there, but says it’s not. And it shows up a different color. I don’t know if that is normal or not.
-
@adukes40 The different color reporesents a symbolic link. But in the code you posted there is no reference to creating this link. The command should be
ln -S <sourcepath> <destination path>
If you do als -la
on that temp directory you can see the target of the link.Stick with it, you are progressing nicely. And just think about how much you’ve learned today. Don’t get discouraged at the end of the process you WILL understand how this works.
-
@george1421 hmm, ok I think the tmp/mydrivers is throwing me off.
When you say ln -s <source path> <Dest path> It registers to me to mean ln -s “/images/Drivers/${driverver}/${machine}/${setarch}/” /ntfs/Drivers;
Now does that mean the x86 folder get moved, or the contents WITHIN the x86 get moved. Does /tmp/mydrivers part need to be done, or can it copy straight from the server to the /ntfs/Drivers
-
What a symbolic link is (its similar to join in windows) it allows you to map one directory to another location.
so in the ln command you are saying to create a shortcut from that long path full of variables to the /nfs/Drivers… wait your link is wrong it should be to /tmp/mydrivers directory. You are trying to create a symbolic link to the target computer’s hard drive. What you will want to do after the link is established is to copy the content of /tmp/mydrivers to /ntfs/Drivers. Thus moving the drivers from the FOG server disk to the target computer disk.
[edit] your inserted picture is showing the link was created OK. Actually I had to use the link command to get around the devices having a space in the name (your welcome). Otherwise this script would have fallen down.
-
@george1421
Ok so:-
the ln command is the same as net use to windows. Except here it is ln -s <SP> <DP> where in windows it is net use x: \server\share<rest of path if needed>
-
Being mydrivers is a symbolic link, it doesn’t technically have a directory, just a location to point to.
3.the ls -la /tmp command shows the OptiPlex 790 having a space. Does this mean the folder on the server needs to have a space as well?
- If the link is there, and pointing to the correct location, what is casuing this to not pull the files from the server to the ntfs mount.
-
-
@adukes40 not sure if I can explain this well, but
- No the net use command is for connecting to network attached storage. This is different (at this point in the script) what is equivalent to the net use command nfsmount command
- In the case of this script the symbolic link (directory) is a representation of the correct driver for this deployment.
- No because you are copying the “contents” of that location and not the directory and its contents.
- ??
You have to remember this script (when its tested) will execute from the perspective of the target computer. This script establishes a nfs mount back to the images share on the FOG server and it mounts the local windows partition. Then based on the model name it finds in smbios it creates a symbolic link from a known location to a location built based on the information its collected during execution. The last bit is to copy the files from the known location /tmp/mydrivers/* to the windows partition mounted under /nfs/Drivers. That is the general concept of the script. Of course there is some error checking along the way to ensure things are where they are suppose to be but that is the script in a nut shell.
-
since the /tmp/mydrivers link is created make sure you can list the contents of
ls /ntfs/Drivers
If both checkout then just issue the copy command manuallycp -R /tmp/mydrivers/* /ntfs/Drivers
That should copy the files to the windows drive.