I have a small issue here at work and I am trying to script out a way to automate a fix for it. I have a small number of users (I work in a 1:1 with 6,000 macbooks) that aren't really managed in my deployment. They are managed with a few policies, but the policies are broken because they never turn their laptops in or get them reimaged. I have had to wipe LDAP a few times for upgrades/maintenance/fixes and their synchronized portable home directory has a different UID than the new UID since I did fresh imports of user accounts both times I destroyed and rebuilt LDAP.
So, I have a script written which seems to be going the correct way of doing this, but I am not exactly a Unix wizard so I have some basic questions hopefully someone here can help me with.
The script's function will be to copy all local user accounts in /Users to /Users/username.bu for a full back up of the account. Then, it will initiate a log out, and a log out hook that will run the second script that will verify all data is copied to the back up folder (.bu) and then delete the account from directory services and wipe the original data out of their local user account.
This way, when the user logs in next, they will have pulled down the new account to their machine that has the exact same user/password but this time it will be the right UID. Then they will be in the proper OD groups and get group policy as normal.
I hope that makes sense. Also, only accounts that have a UID higher than 1000+ are directory accounts, so I want to ignore all accounts with an UID less than 999.
So far here is my script I wrote, and like I mentioned, I am completely self taught and have no formal education in programming.
Now the second script will just copy that data back after the user logs in again and resynchronizes their PHD with the proper UID. Then the last bit will apply ownership to that new UID and exit.
A few questions....
1) Should I have used an integer comparison when comparing the current UID to it being greater than 999?
2) There are probably some issues with this script as I have not tested it out fully yet, because I was wanting some feed back to see if there was a better way to go. Is there a more efficient way to go about this?
Thanks for anyone who can help, it is greatly appreciated.
I am not understanding this.
This lists all of the users with UID >= 1000
You can change the login directory for any user by using the the equivalent of the useradd utility. Editing the /etc/passwd file is not a great idea on some systems. What flavor of unix do you have?
You can also create a common login entry:
modify /etc/profile
You do not need to put code in each users home directory. If you put code in /etc/profile it is protected from modification by users.
But - then I'm confused as to what you are really doing.
I am using OS X 10.5.8 from Apple. All of there user accounts either local or network are handled by directory services. All local accounts have a range of UID 500 to 999 and all directory accounts have UID 1001 and up, with UID 1000 being that of the directory admin account.
I am on my third year of my 1:1 and some staff members have never had their laptops wiped and reimaged. During that time I have completely destroyed and recreated LDAP, so all those user accounts got new UIDs. Some of those faculty members that have their old PHD synchronized to their machines have a mismatching UID in Open Directory, thus that account is not a member of any OD groups.
Sorry if I am not making any sense.
So I need to loop through all users in /Users and check their UID. If the account is local, I don't want to touch it and I want it to be skipped. So any account that is UID 500 to 999 should not be touched. Any account that is in the OD account UID range of 1001+ needs to be copied to a back up folder, then have the account erased and when the new account is created I will have a self service script where the user can execute it and it will copy all data back where it was and apply ownership to the new user account.
what is the best way to move the contents of a folder to another one without deleting the structure of the first one. the contents could include subfolder too.
both folder, the source-folder and the target-folder are on the same host.
any idea is appreciated . (7 Replies)
I'm looking for a script that sums the contents of a folder,
When you give a parameter to the script , i want to know the size of the directory, the number of files, number of folders,
These are commands that I have already found
du -s
find . -type f | wc -l
find . -type d | wc -ly
... (19 Replies)
Hi one of the output of the command is as below
# sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/'
Resource List : <br>
*************************** 1. row ***************************<br>
... (2 Replies)
Hi
I have 2 files
1.del
----
1,2,3,4,5
1,2,3,4,4
1,1,1,1,2
2.del
----
1,2,3,4,5
1,
1,2,3,4,4
1,1,1,1,2
I need to compare the above two files in unix, as in the output should only tell the difference in contents as I should get only the line
1 ( from 2.del) , rest all lines are... (4 Replies)
Hi experts,
I am coming to you with this basic question on copying a folder and its content from one location to another folder using PERL script.
This is my requirement.
I have a folder AB under /users/myhome
I want to copy AB and its contents to /user/workspace.
Finally it should... (1 Reply)
I am working on HP Unix. Require a script for the below requirement.
Requirement are:
1. Need to create a folder with files.
2. The folder should have a naming convention like - LRIC_ARCHIVE_ddmmyyhhmmss_version_nnn, the version number needs to be selected from an oracle table.
3. When the... (4 Replies)
Hi everyone,
I have different folders which looks like this:
/mnt/ecrm/master/ecrm/templates/brochure/de_DE/zeitlos.ott
/mnt/ecrm/master/ecrm/templates/mail/en_US/default.html
/templates/header_and_footer/en_US/default.txt
I want to get the bold text only in a variable. I already have a... (3 Replies)
Hi,
I have few files in a directory. I have the same set of files in another directory. I need to remove the lines starting with the word 'HDR' and 'FTR' if present from all the files in both the directories. Then i need to sort the contents from all the files in both the directories and then... (10 Replies)
I need to make a new dir in side the dir lab5 the new dir is called testLab5
without changing directories copy all files from your lab5 directory into your testLab5 directory
then i have to
without chaning directories and using exactly one command remove all files that start with the... (1 Reply)
Hi,
I'm trying to allow people to access the contents of a folder on a web site, I am automatically placing files in this folder for people to download. I'm using Apache on Mac OS X, if that makes a difference.
Can anyone help with this? I've found no documentation on this so far...
... (6 Replies)