In this lesson, we're going to copy the VLC preferences that we generated earlier and copy them to
our target computer so that they're available to both users who have logged into the system and users
that have not yet logged into the system.
Let's go ahead and take a look at the user folder on our target machine.
And we can see that we have a user folder generated for our high Sierra network user, but we don't
have a folder for our demo user.
So what we want to do now is make sure that both users, when they log in, get our Velzy preferences.
So there's a lot of different ways that we could do this.
But let's let's do something new.
What I want to do is create a custom package now to build our own package.
We're going to use a program called Monkey Package.
And so the first step is to run the monkey package command with the create option.
And we're going to go ahead and create a package, which I'll call the press.
Now, let's go into that VLCC press folder and we'll see that there are three folders that are generated
inside.
So we have the build folder, which is going to be where the package file is generated when we're done
building it.
And the payload folder and the payload is basically all the files and folders that we want to deliver
to our target system in a relative path.
And then we have the scripts folder and you have the ability of running a post install script or preinstalled
script.
So these are scripts that will run before or after the payload files are written out to the target machine.
Now, when I build packages, the first thing that I like to do is, is create that payload.
So what we want to do in this instance is we want to copy or VLCC preferences to the user template folder
that we learned about earlier.
So what we're going to want to do is we're going to want to get the path of the user template folder.
So it is a system library user template, English library preferences.
That's where we want to copy our files to on our target machine.
So I'm going to go ahead and copy this path and notice that I'm not copying the leading forward slash.
The leading forward slash basically represents you're copying from the root of the hard drive.
Now, what we want to do is we want to copy that relative path into the payload folder.
So I'm going to go ahead and do a directory hyphen P, which will which will create an entire directory
tree.
And I'm going to go ahead and create this path inside the payload folder.
Now, remember, whatever is in the payload folder gets written to your target system from the root
level.
So in effect, we're going to be writing files to the root system, library user template, English
library preference.
So in other words, the user template folder on our target machine.
OK, so now we need files to go inside the preferences folder and we had saved the preferences that
we want to deliver to our desktop.
So what we're going to want to do is if you remember, we had a file and a folder, so we're going to
need to do a copy file recursively and we're going to be copying from our desktop folder and we're going
to be copying the VLC preferences and the DLC preference file.
The list ended and p.l.c..
But the name that you see on the screen here was the name of the folder.
So if I put this star here, it's going to copy both the folder and the previous file.
And what where we want to copy them to is our payload folder, which we're already in, and we want
to copy it into sys library user template, English library preferences.
So with our file and folder in that path, when this payload is delivered to our target machine, it
will end up in the user template folder on our target machine.
OK, so now the next thing that we need to do is we need to get those same files into each user's home
folder and to do that, we can run a script.
So let's go ahead to our scripts folder and let's go ahead and create a post install script, because
we want to run this script after the files have been written to the machine.
We can't do it before.
We won't have any ability to process those files.
So the files have to be written to our target and then we can use a script to manipulate those files.
So let's go ahead and create the post install script.
We need to make it executable.
Now, I've already actually created this script, so I'm just going to move the script that I already
created.
Before we ran this account cleanup job, and if you remember, we had a what we did is we found all
the users that were not administrators shared, and then we generated an array that we could loop through
and run some commands on it.
So we're going to do the same thing, but we're going to make a small change to it.
So.
If we run this command.
On our target machine and.
You see that it comes back with the full path of the user's home folder.
Now I've added this to the end of it and let's go ahead and discuss why.
So let's go ahead and.
Now, you can see that I'm just getting the user's name.
So what this cut does is it basically says I just want everything from the output from the eighth character
on.
All right.
So let's talk about why I've done that.
So.
What when we do our loop, we're going to copy files from the user template folder and here's our VLCC
and we're using the wild card.
So we get both the file and the folder and we have the hyphen, our option on our copy command.
And we're going to copy it to users.
And then remember, we're just getting the user name.
So the user name will go here where it's to replace this variable and it's going to copy these things
from the user template to the library preferences folder.
Now it's going to loop through it.
So if I've got five users, it's going to do it on all.
It's going to perform this copy on all five users.
Now, the reason why we ran this cut command is so we can change the ownership of the files and the
folder.
So why do we need to do that?
Well, when you run a package, you're running it as root and when you copy a file to a destination,
then the file is typically owned by the user that copies it.
So what would end up happening is we would copy the files from the template folder into the user's home
folder, but they wouldn't have access to it and the permissions were within for not apply.
So by changing the ownership of the files and folder to the actual user's name in and then here's the
path that it's changing the ownership to, then when we copy the files to the user's home folder, then
they will be owned by that user.
OK, so let's go ahead and say this, and we need to now get out of our folder and we're going to go
ahead and run the Monkey Package command and give it our project name.
And it is going to go ahead and it's going to write a package to the build folder.
All right.
So let's go ahead.
And the next step is to copy our package file to our Web server.
And then what we're going to do is we're going to simply run a package job that we've seen before.
So download the package, install the package, delete the package, and we're going to go ahead and
do that on our target machine.
So let's go ahead and go back to our target machine and let's take a listing of the high Seer folder,
library preferences.
And we can see that there is no p.l.c. files in here.
And let's go ahead and do the same thing.
For the poor, the user template folder.
And also, we can see that there are no preferences, preference files.
All right, so let's go ahead and run our custom package.
OK, so the package ran, and let's take a listing of our user template folder, and so now we can see
that we've got our VLC preferences in place and let's do the same thing for our high Siara user.
And we also can see that we have both the directory and the individual list file, and it is owned by
High Sierra.
OK, so now when we log in, is either of these users VLCC should run and it will not prompt us for
metadata, nor should it prompt us for automatic updates.
All right, so we can clearly see that this user has not been in this computer.
And let's go ahead and run the L.C.
And our preferences are set exactly as we want them.
So let's log in as our high Sierra user.
And this user has logged in before, as we saw, and we put the preferences in their user folder, so
when they launch Velzy, it should also work with the preferences that we set for them.
So let's go ahead and launch it.
And we didn't get prompted and both tickets are on.
OK.
So there you go.
We've used a custom package to not only deliver files to a system, but to manipulate those files as
well.