(bash) echo "#!/bin/bash" event not found - trying to generate profiles automatically
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian and Fedora for play and RHEL + Solaris for work
Posts: 172
Rep:
(bash) echo "#!/bin/bash" event not found - trying to generate profiles automatically
Hi all,
I'm trying to write a simple bash script to create users on Linux and Solaris systems. Part of the spec is that I have to be able to generate a bash profile on the Solaris systems (this is done automatically on our Linux distros), so I wrote some code a bit like this:
Just to add some more information:
Create a template file, e.g. bash_profile.template and simple copy it to the home directory, changing the name in the copy command.
If you will use the useradd command, the "-m -k" options will create the home dir and copy the files from a template dir to the user's home dir.
Distribution: Debian and Fedora for play and RHEL + Solaris for work
Posts: 172
Original Poster
Rep:
*slaps forehead* I could have sworn I'd tried that and failed with the same result Oh well. Need more coffee I suppose.
BTW I thought of that idea of copying the profile, but you can't guarantee that the template is going to be in any specific location, especially when you're working cross platform. I had considered scp'ing it from somewhere, but this is just supposed to be a simple script and I don't want to mess around with keys or passwords.
Why not use /etc/skel to store the file. Both linux and slorais (9 at least) support this. If the content of /etc/skel isn't put in the (new) homedir automatically during user creation you could try to force it with useradd's -k skeleton_dir option.
Distribution: Debian and Fedora for play and RHEL + Solaris for work
Posts: 172
Original Poster
Rep:
This is more just a way to configure a user on any server, until we get some kind of centralised authentication mechanism going. I don't really want to have to put a default profile on every server on the network just yet.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.