The correct components to install the script?

I am writing a bash script to create a production server. Tasks at hand include compiling software, creating users and directories, copying files, etc.

I'm wondering what to do next. Perhaps go to the file? check output status 0? What can I add to make this script great and not just "it works"?

+1


source to share


3 answers


Perhaps you should rethink how you deploy your software to a production server:

  • Compiling the software should be done in a development environment, not on a production server. There is no need to install compilers on production servers. And there are many reasons not to do this (mostly security reasons).

  • Use a package management system to deploy your software. If you are using linux use deb, rpm or whatever box your distribution uses. This will give you complete control over the version and also provide dependency functionality.

  • The package that installs your software must contain all the files your software needs (unless those files can be provided by other packages), and also configure users, directories, permissions, and whatever else your software requires.

  • Basically you can write a bash script in the post post and post remove section of the package.

  • Be sure to check that after installation the package brings in and builds everything needed to run the program, as well as uninstalling the package, removing all files, and undoing what the postinstall script did.

  • Make sure that the package upgrade from version X to X + 1 works as expected.



As for the script itself. You should, of course, check the exit status of the commands you run. You can use a Wrapper script so that you don't have to repeat the exit code check and logging for each command.

Good luck!

+4


source


In my work, we have shell scripts to automate almost everything when it comes to building a server. OS installation is fully automated based on some profiles and whatnots. Patch, add users, etc., all scripts to make life easier.

However, when we need to deploy an enterprise application, these servers are the "application servers" that you are interested in, this is a completely different process. We are dealing with a completely different set of administrators, intermediaries. We provide them with binaries that have been promoted through dev, to qa, and then into prod.



It's perfectly fine for automating box customization, but you don't want them to "build" applications in a production box. If for some reason the performance hitting any live application sees a big nasty compilation process going on in the box.: D

0


source


@tom: An example of a stable and successful Linux distribution would be Gentoo, where all the binaries are compiled on the server before installation (there are no binaries in the distribution). It has been used by big production servers like isohunt.com.

Building the binaries on the server is a good idea, as it will ensure that your binaries are optimized at some level for the host platform if the installer provides the correct flags to the compiler.

The presence of GCC on the server does not bother anyone :)

@Lars:

You must -

Save the log file, adding the steps needed to fix the errors and move forward.

Early in the development process, handle exceptions with messages on stdout and provide handlers when testing the script.

All in all, try to make things easier for your user, who may not really be aware of the micromanagement your script is doing (copying files, installing daemons, creating filesystems, setting permissions, blah) and you only have your installer to complete the process successfully.

Testing your script on multiple systems ensures it will work

0


source







All Articles