tags:

views:

257

answers:

8

I'm going to rebuild my Linux box [yet] again. I have to create a few user groups, user accounts and install my standard packages. Until now I've just used the GUI tools. I was wondering if anyone has any recommendations on writing a script to create users, groups and install standard packages after I do a minimal install of my latest Fedora build? Sometimes I run Ubuntu so I'd like the script to be somewhat generic.

+1  A: 

Fedora and Ubuntu use totally different package managers, so you won't be able to easily do it in any sort of generic way.

In CentOS (which is RedHat Enterprise Edition with the serial numbers filed off, and so therefore pretty close to Fedora), we did this using Kickstart files. These files have a simple syntax that enabled you to specify users, groups and packages to install, and even to script some custom stuff.

Paul Tomblin
+1  A: 

While I haven't done this yet, I have a similar problem. I'm considering a virtualization host and multiple client OS (Ubuntu and CentOS being the top 2 candidates) - that way once I get the client configured as I want it, I can save it off for reloading as needed.

Doesn't get around the original setup issue, but does limit the "rebuild my Linux box [yet] again" problem.

You may want to consider it.

Ken Gentle
A: 

Another option to help with constantly rebuilding a box is Norton Ghost, with ghost you can make an image and then just re-image the drive as needed. You install it and configure it to your liking, then take an image.

vfilby
dd is also an option, especially when combined with compression utility like gz or bzip2.
sep332
If you use dd like that, make sure you make the blocksize much higher than the default or it goes really slowly.
Mark Baker
+1  A: 

It may be overkill but you can check out Puppet.

From their website:

Puppet is a system for automating system administration tasks.

I'm just starting looking for ways to automate system administration, so I don't have much experience with it yet.

jmohr
A: 

It's gonna be difficult to make the script generic, but you could use any sort of scripting tool (bash, or ruby or whatever) and try and check what distro is running and then run the appropriate commands to install software. There are various ways to check what distro is running here

Creating groups should be the same on all distros, and you may even be able to drop in an already configured /etc/passwd and /etc/groups (though I haven't tried that, and it may not work).

robintw
+1  A: 

If all you need to do is create users and groups and install packages then I would suggest that you just write two separate scripts.

It might be that you could share the users and groups part but only if all the distributions you use have the same policy for creating them (for example Ubuntu creates a group for each user while I am sure some distributions have a "users" group as well).

You could take a look at the useradd and groupadd commands which should be available everywhere. For Ubuntu there is also the friendlier adduser and addgroup and I would not be surprised if Fedora has a set of similar commands.

After groups are setup you just need to feed the package manager a big list of packages you need to have installed. Trying to install packages which are already installed should be safe, so you could install the packages you need on a "clean" new install and then dump a package list.

So to summarize: If you don't plan to support more than two distributions then I suggest just writing the two scripts separately.

kigurai
A: 

The response above, about the different distros using different methods is dead on. It's like trying to use the same part for a Chevy and a Ford (there's the car analogy, for you).

The easiest method I've found is to learn about setting up partitions for the different mount points i.e. / ; /home ; /var ; /opt are the big ones.

This lets you keep your users, groups, and many of your apps during your rebuilds. Changing distros will break a lot of things, but your user accounts should still be there.

+1  A: 

For .deb distros, use FAI. For .rpm distros, use Kickstart. For system management after installation, use cfengine.

Krunch
What does FAI give you that just using debian-installer with a preseed file doesn't?
Mark Baker