![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Auto create local account with winbind. | d_ark | Linux | 1 | 06-02-2008 07:15 AM |
| Local shell script need to be executed on a remote linux box | rajeshomallur | Linux | 6 | 05-02-2008 01:05 PM |
| shell script to create dirs | sjajimi | Shell Programming and Scripting | 2 | 07-24-2007 07:34 AM |
| create a shell script | maykap100 | Shell Programming and Scripting | 3 | 08-31-2005 10:17 PM |
| shell script, reading and resetting local variables | b888c | UNIX for Dummies Questions & Answers | 1 | 08-20-2001 04:52 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Shell script to create local homes
Hi
I am trying to write a login script for network based clients (OSX) that looks up local accounts eg admin, root, etc and exits the script so that it doesn't apply to them. Then for everyone else I make folders eg movies, music, etc that are placed in local harddrive rather than the default place on the server harddrive. At the moment this script creates the desired effect for the root user no matter who logs in. If I remove the first couple of lines that try to sort out the admin users it works for everyone who logs in. However I want it to work for everyone except root and local users. ie #!/bin/sh # CURRUSER=`whoami` ADMINGROUP=`groups | grep admin` if [ `expr "$ADMINGROUP" != ""` = 1 ] then exit 1 fi mkdir -p /Users/Shared/$CURRUSER/Movies mkdir -p /Users/Shared/$CURRUSER/Music mkdir -p /Users/Shared/$CURRUSER/Pictures mkdir -p /Users/Shared/$CURRUSER/Music/iTunes mkdir -p /Users/Shared/$CURRUSER/Music/GarageBand mkdir -p /Users/Shared/$CURRUSER/Pictures/iPhoto Library rm -R ~/Movies rm -R ~/Music rm -R ~/Pictures ln -s /Users/Shared/$CURRUSER/Movies ~/Movies ln -s /Users/Shared/$CURRUSER/Music ~/Music ln -s /Users/Shared/$CURRUSER/Pictures ~/Pictures Hope someone can help. Ta |
|
||||
|
Hi I tried it and it makes sense but the script does not quite work yet , a bit of progress has been made at this link.
http://discussions.info.apple.com/we...736.689d315b/3 My script currently looks like this #!/bin/sh # CURRUSER=`whoami` ADMINGROUP=`groups | egrep -c admin` if [ "$ADMINGROUP" > 0 ] then exit 1 fi mkdir -p /Users/Shared/$CURRUSER mkdir -p /Users/Shared/$CURRUSER/Movies mkdir -p /Users/Shared/$CURRUSER/Music mkdir -p /Users/Shared/$CURRUSER/Music/iTunes mkdir -p /Users/Shared/$CURRUSER/Music/GarageBand rm -R ~/Movies rm -R ~/Music ln -s /Users/Shared/$CURRUSER/Movies ~/Movies ln -s /Users/Shared/$CURRUSER/Music ~/Music I will add the chown part but it still needs something to create the $CURRUSER directories rather than roots . This last sentence makes sense if you read the input at the link above. Last edited by Steve Adcock; 10-20-2004 at 04:18 AM.. |
|
||||
|
Would I do that just before I make the directories in the script and I am not quite sure how.
I guess I don't understand how your trying to use su. Could you give an example in my script how you might do it. Thanks |
|
|||||
|
Quote:
#executed by root and not the everyday user Are you saying it works for root but not others? Are you getting any permission errors, unable to create directory errors? How are you executing the script? Does root own the script and do you have the SUID permission bit set? This would allow anyone who executes the script to run the script as if they were root (security issues with SUID's). What permissions are set for this script? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|