Copyright © 2002 by Avi Alkalay
v2.1, 2002-08-24
Revision History | ||
---|---|---|
Revision 2.1 | 24 Aug 2002 | Revised by: avi |
Rewrite of the /opt /usr/local section.Cosmetics on graphical user interface and plugins sections.Fixed screens and programlistings width. | ||
Revision 2.0 | 07 May 2002 | Revised by: avi |
Final XML conversion. Files reorganization. | ||
Revision 1.9.9 | 20 Apr 2002 | Revised by: avi |
Included other document locations. | ||
Revision 1.98 | 14 Apr 2002 | Revised by: avi |
Title changed from "Creating" to "Designing". | ||
Revision 1.97 | 09 Apr 2002 | Revised by: avi |
Converted to XML 4.1.2, and started to use real XSLT. Spell checked the english version. | ||
Revision 1.96 | 23 Mar 2002 | Revised by: avi |
Better HTML style sheets. | ||
Revision 1.95 | 17 Mar 2002 | Revised by: avi |
Last chapter: One Body, Many Souls. Created appendix. Still have to translate some words here and there. | ||
Revision 1.9 | 16 Mar 2002 | Revised by: avi |
Added universal software table with FHS. | ||
Revision 1.7 | 16 Mar 2002 | Revised by: avi |
Everything is now translated except some words. | ||
Revision 1.3 | 27 Feb 2002 | Revised by: avi |
Translated and reviewed the most important section of the article: The /opt and /usr/local section. | ||
Revision 1.2 | 23 Feb 2002 | Revised by: avi |
English translation at 65%. Doing some corrections to potuguese version also. | ||
Revision 1.1 | 17 Feb 2002 | Revised by: avi |
Started english translation. | ||
Revision 1.0 | 16 Feb 2002 | Revised by: avi |
First final version of proposed skeleton. | ||
Revision 0.9.6 | 16 Feb 2002 | Revised by: avi |
Finished Plugin chapter. | ||
Revision 0.9.5 | 15 Feb 2002 | Revised by: avi |
Finished chapter about boot and subsystems. | ||
Revision 0.9.4 | 14 Feb 2002 | Revised by: avi |
Finished chapter describing the boot process. | ||
Revision 0.9.3 | 08 Feb 2002 | Revised by: avi |
Text and style updates. | ||
Revision 0.9.2 | 07 Feb 2002 | Revised by: avi |
Text updates. | ||
Revision 0.9 | 06 Feb 2002 | Revised by: avi |
First translation to DocBook. |
The examples run on Red Hat Linux, and should be compatible with other distributions based on Red Hat (Conectiva, Turbolinux, Caldera, PLD, Mandrake, etc).
Read more README files that appeared in the installation environment
Edit OS files to include the presence of the new product (e.g. /etc/inetd.conf, /etc/inittab)
And the worse: Change security permissions of OS directories and files to let the product run OK
The Install-And-Use glory is easily achieved using a 3 ingredients receipt:
We'll discuss here what are these ingredients and how to implement them.
These are files that define how the Software will run, how to use the Content, security, performance etc. Without them, the Software on its own is usually useless.
Depending on your Software, specific privileged users may change these files, to make the Software behave as they want.
It is important to provide documentation about the configuration files.
Let's see how universal is this concept analyzing some types of softwares:
Table 1. Universality of 4 Parts
Software on its Own | Configurations | Content | Logs, Dumps etc | |
---|---|---|---|---|
Data Base Server | Binaries, libraries, documentations. | Files that define the directory of the data files. For this type of Software, the remaining configurations usually are in special tables inside the database. | Table files, index files, etc. This software use to have whole trees under the same directory. And many times they need several filesystems to guarantee performance. Their local in the system is defined by they Configurations. | For DBs, there are the backup, generated in a daily basis. And the logs are used by the DBA to define indexing strategy. His local on the system is also defined by the Configurations. |
Text Processor | The same, templates, modular file format filters, etc | As a user-oriented Software, its configurations must be put in each user's $HOME directory, and are files that defines standard fonts and tabulation, etc. | The documents generated by the user, and they go some place in his $HOME | They show as temporary files that can be huge. User can define their location with a user-friendly dialog (that saves it in some Configuration file) |
MP3 generator | Same, audio modular filters | Each user has a configuration file in his $HOME, and contains bitrate preferences etc | Similar to Text Editor | Similar to Text Editor |
Web Server | Similar to Data Base | Files that define the Content directory, network and performance parameters, security, etc | Directories where the webmaster deposits his creativity. Again defined by the Configurations | Preciouses access logs, vital for Marketing Intelligence, that are generated in a location and format defined by Configurations |
e-Mail Server | Similar to Database and Web-Server | Files that define how to access user database, mail routing rules, etc | The preciouses users mail boxes. Again defined by the Configurations | Mail transfer log, virus detection log, etc. Again defined by the Configurations |
Pay attention that the Software on its Own contains all your product business logic, which could be useless if you hadn't a Configuration to define how to work with a data bundle, provided by the user. So, Configurations are what connects your product to the user.
We can use a metaphor about a Sculptor (business logic), that needs Bronze (content) and a Theme or Inspiration (configuration) from a Mecenas (user), to produce a beautiful work (content). He make annotations in his Journal (logs) about his day-by-day activities, to report to his Mecenas (user).
OK, so let's be more practical. The fact is, if we correctly use the universal parts concept, we greatly improve the quality of our Product. We'll do that simply separating, encapsulating, each one of these parts in different system directories (having only different files for each part is not sufficient). There is a standard called FHS that defines the Linux directories for each part, and we'll discuss it later in Section 4.
By now let's see the value of this separation to the user:
He gains a clear vision about where is each part, specially his Configurations and Content, and he feels your Product as something completely under control. The clareza brings ease of use, security and confidence in your Product. And in practice it permits him manipulate each part independently
It is clear now that, for instance, when backing up, user action is needed only for Configurations and Content (the puritans will also backup some logs). The user don't have to care about Software on its Own, because it is safe, original, on the product CD, in his shelf.
For upgrades, the new package will overwrite only the business logic, leaving intact the user's precious Configurations and Content. Here is very important to keep old content and configuration compatible, or to provide some tools help migration of data
The logs being kept in a separate filesystem (obviously suggested in your documentation), avoids that their exaggerated growth interfere with the Content, or with the stability of the whole system
If your Software follows some directory standards, the user don't have to reconfigure his system or environment to use it. He will simply Install-and-Use.
Let's make some exercise with separation using as example a system called MySoftware, in which the business logic is in Example 1 and the configuration is in Example 2.
Example 1. A Shell program referring an external configuration file
Example 2. File containing only the configurations for MySoftware
When I was a system administrator for IBM e-business Hosting Services, I was fascinated by Apache's flexibility letting us do things like this:
bash# /usr/sbin/httpd & bash# /usr/sbin/httpd -f /etc/httpd/dom1.com.br.conf & bash# /usr/sbin/httpd -f /etc/httpd/dom2.com.br.conf & bash# /usr/sbin/httpd -f /etc/httpd/dom3.com.br.conf & |
If we don't pass any parameter (like the first example), Apache loads its default, hardcoded configuration file from /etc/httpd/conf/httpd.conf. We built other configs, one for each customer, with a completely different structure, IP address, loaded modules, content directory, passwords, domains, log strategy etc.
This same concept is used by a text editor of a multiuser desktop (like Linux). When the code is loaded, it looks for a configuration file on the user's $HOME, and depending who invoked him (user A or B), it will appear differently because each user has its own personal configuration.
The obvious conclusion is that the Software's body (business logic) is pure e completely oriented by his manipulator's spirit (configuration). But the competitive advantage lays on how easy we switch from one spirit to another, like in Apache's example. It is very healthy to promote it to your user. You'll be letting him create intimacy, reliability, confort with your Product.
We used this approach with many different Softwares in that e-business Hosting time, and it was extremely usefull for maintenance etc. In a version migration we had total control over where were each of its parts, and upgraded and downgraded Software with no waste of time, with obvious success.
But there were some Products that refused to work this way. They had so many hardcoded parameters, that we couldn't see what divided the body from their spirit (or other parts). These Softwares were marked as bad guys and discarded/replaced as soon as possible.
We concluded that the good guys Softwares were intuitively blessed by their developer's four parts vision. And they made our life easyer. In fact, in that time we formulated this theory, that continues to prove itself.
Do you want to deploy bad guy or good guy Software?
By now, all discussion are OS independent. On Linux, the Four Software Parts theory is expressed in his directory structure, which is classified and documented in the Filesystem Hierarchy Standard. The FHS is part of the LSB (Linux Standard Base), which makes him a good thing because all the industry is moving thowards it, and is a constant preoccupation to all distributions. FHS defines in which directories each peace of Apache, Samba, Mozilla, KDE and your Software must go, and you don't have any other reason to not use it while thinking in developing your Software, but I'll give you some more:
FHS is a standard, and we can't live without standards
This is the most basic OS organization, that are related to access levels and security, where users intuitively find each type of file, etc
Makes user's life easyer
This last reason already justifies FHS adoption, so allways use the FHS !!!
More about FHS importance and sharing the same directory structure can be found in Red Hat website.
So let's summarize what the FHS has to say about Linux directories:
Contains dynamic libraries and support static files for the executables at /usr/bin and /usr/sbin. You can create a subdirectory like /usr/lib/myproduct to contain your helper files, or dynamic libraries that will be accessed only by your Software, without user intervention. A subdirectory here can be used as a container for plugins and extensions.
Like /usr/lib but contains dynamic libraries and support static files needed in the boot process. You'll never find an executable at /bin or /sbin that needs a library that is outside this directory. Kernel modules (device drivers) are under /lib.
Contains configuration files. If your Software uses several files, put them under a subfolder like /etc/myproduct/
The name comes from "variable", because everything that is under this directory changes frequently, and the package system (RPM) doesn't keep control of. Usually /var is mounted over a separate high-performance partition. In /var/log logfiles grow up. For web content we use /var/www, and so on.
Contains the user's (real human beings) home directories. Your Software package should never install files here (in installation time). If your business logic requires a special UNIX user (not a human being) to be created, you should assign him a home directory under /var or other place outside /home. Please, never forget that.
The "share" word is used because what is under /usr/share is platform independent, and can be shared among several machines across a network filesystem. Therefore this is the place for manuals, documentations, examples etc.
These are obsolete folders. When UNIX didn't have a package system (like RPM), sysadmins needed to separate an optional (or local) Software from the main OS. These were the directories used for that.
You may think is a bad idea to break your Software (as a whole) in many pieces, instead of keeping it all under a self-contained directory. But a package system (RPM) has a database that manages it all for you in a very professional way, taking care of configuration files, directories etc. And if you spread your Software using the FHS, beyond the user friendliness, you'll bring an intuitive way to the sysadmin configure it, and work better with performance and security.
Now that we know where each part of our software must be installed, lets review the Universal Parts Table applied to the FHS.
Table 2. Same Software, applying FHS
Software on its Own | Configurations | Content | Logs, Dumps etc | |
---|---|---|---|---|
Data Base Server | /usr/bin/, /usr/lib/, /usr/share/doc/mydb/, /usr/share/doc/mydb/examples/ | /etc/mydb/ | /var/db/instance1/, /var/db/instance2/, etc | /var/db/instance1/transactions/, /var/log/db/access-instance1.log, /var/log/db/access-instance2.log |
Text Editor | /usr/bin/, /usr/lib/, /usr/lib/myeditor/plugins/, /usr/share/myeditor/templates/, /usr/share/doc/myeditor/ | $HOME/.myeditor.conf | $HOME/Docs/ | $HOME/.myeditor-tmp/ |
MP3 Generator | /usr/bin/, /usr/lib/, /usr/lib/mymp3/plugins/, /usr/share/doc/mymp3/ | $HOME/.mymp3.conf | $HOME/Music/ | $HOME/.mymp3-tmp/ |
Web Server | /usr/sbin/, /usr/bin/, /usr/lib/httpd-modules/, /usr/share/doc/httpd/, /usr/share/doc/httpd/examples/ | /etc/httpd/, /etc/httpd/instance1/, /etc/httpd/instance2/ | /var/www/, /var/www/instance1/, /var/www/instance2/ | /var/logs/httpd/, /var/logs/httpd/instance1/, /var/logs/httpd/instance2/ |
E-Mail Server | /usr/sbin/, /usr/bin/, /usr/lib/, /usr/share/doc/mymail/ | /etc/mail/, /etc/mailserver.cf | /var/mail/ | /var/spool/mailqueue/, /var/logs/mail.log |
With RPM is different. RPM (or any other package system) is an installation "process" by itself. It is self-documented in his database and pre and post-install actions, which permits total control. Turns installations independent from who did it, turning installtions in a business process.
Installations based on coping files into /opt or /usr/local are far from providing the organization, system visibility and control that RPM provides. I can say /opt and /usr/local would be obsoleted when all softwares become RPMized.
It is very important to Linux evolution and popularization (especially in the desktop battlefield), that developers stop using this hell directories, and start using the FHS. After reading this section, if you still think this folders are good business, please drop me an e-mail.
Products that are entirely installed under one directory, use the self-contained approach, that has several problems:
Forces the user to change environment variables like $PATH and $LD_LIBRARY_PATH to use your product easily.
Puts files in non-standard places, complicating system integration, and future installation of extensions to your product.
The sysadmin probably didn't prepared disk space in these partitions, generating problems in installation time.
It is an accepted approach only for pure graphical application, without the command line concept. This is why it were well accepted in Windows. But...
...even using this approach, you can't avoid installing or changing files in standard locations to, for instance, make your icons appear in the user desktop.
Many developers believe that the "self-contained" approach let them work with several versions of the same product, for testing purposes, or whatever. Yes, agree, with this or any good reason in the planet. But remember that a High Quality Software (or Commercial Grade Software) objective is to be practical for the final user, and not to be easy to their developers and testers. Invite yourself to visit an unexperienced user (but potential customer) and watch him installing your product.
Developer, don't be afraid of spreading your files according to FHS because RPM will keep an eye on them.
If you have a business reason to let the user work with several versions of your Product simultaneously (or any other reason), make a relocatable package, which is described in the Maximum RPM book. Be also aware about the implications of using this feature, described in the same book.
Red Hat and derivated distributions allways use the directory standard, instead of /opt or /usr/local. Read what Red Hat says about this subject, and think about it.
![]() | The Makefiles of an OpenSource Software that is portable to other UNICES must have the standard installation in /usr/local for compatibility reasons. But must also give the option, and induct the packager, to create the package using FHS specifications. |
You'll probably let other Software vendors plug extensions to your product. Since you are the author of the initial Software, is your responsability to organize it in such a way that the user can simply install the extension RPM and use it, without forcing him modify any configuration file. It is again the famous Install-and-Use that guarantees ease-of-use.
Well, and extension is nothing more that some files in a right format (DLLs that implements the API your Software defined), put in the right folders (directories your Software looks for extensions).
We can see many applications requesting the user to change configuration files to "declare" the presence of a new plugin. This is a bad approach that must be avoided because makes user's or plugin provider's life harder.
The most important thing to consider in your plugin architecture is to not share files between plugins and your Software. You should provide an architecture where plugins will be able to fully install and uninstall themselves by simply putting and removing files in specific directories, documented in you Software. Good candidates are /usr/lib/myproduct/plugins as the plugins directory, and /etc/myproduct/plugins as the plugins configuration files directory. Your Software and plugins must be sufficient intelligent to know how to find files, specially configurations, in these directories.
Using this approach, no post-install procedures is required from the user, and from the plugin provider.
This is extremely important for many reasons:
Intelligently manages configuration files, documentation etc, providing more control in an upgrade
Manages interdependencies with other packages and versions, guaranteeing good functionality.
The book Maximum RPM, also available on-line and in printable PostScript format.
RPM-HOWTO which is smaller and more straight-forward.
The desktops today in Linuxland are KDE and GNOME. Try to allways use one of them, or both.
KDE is the most outstanding, offering a true consistent desktop, flexible, with an extremely elegant architecture, using components (like Microsoft's COM and COM+), intercommunication, performance etc. It is constantly evolving, and is developed in C++. Its applications have an familiar integrated look-and-feel, is light and mature. People say that KDE 3 is shiny diamond, ready to be used, and is my first suggestion to you.
GNOME also brings the integrated desktop proposal, but it is far from the maturity and ease-of-use of KDE. From the other side, is very well supported by the comunity, and good improvements are appearing.
Motif isn't an integrated desktop. It is a widgets library (button, scrollbar etc), plus a window-manager. It was born commercial, is mature and popular in commercial applications. But is considered obsolete in front of KDE and GNOME, that integrates the desktop. Motif source code was opened by the OpenGroup and because that was renamed to OpenMotif.
Java is being used more and more for graphical interfaces, specially in server Software, where the graphics are only helpers to configuration and administration.
A wizard should not do more than this:
Ask which modules to install, experienced by the user as checkboxes.
Get the necessary info to build an initial configuration (the soul) for the Software.
Install the selected modules, that are in fact RPM files. Each checkbox must represent one or more RPMs, because each RPM is a indivisible (atomic) portion of a Software.
After RPMs installation, change the configuration (soul) files (marked this way in the RPMs), or create some content, based on the data the user gave to the wizard.
So the wizard hides the RPM installation and writes initial personalization. RPM is still responsable for putting all your software files in the correct places. This role should never be of your installer. Think that an experienced user (there are a lot of them in the Linux world) should be able to reproduce your Product installation without the graphical help, using only RPM commands. In fact, in big data centers, where people make mass installations, a graphical installer only disturbs.
RPM provides tools that help your graphical installer interact with them, like installation percentage viewer. Documentation for use are allways in the RPM manual (man rpm) and in the Maximum RPM book.
The way Linux starts (and stops) all its subsystems is very simple and modular. Lets you define initialization order, runlevels etc
The default runlevel is defined in /etc/inittab with a line like this:
Example 3. Default runlevel (3, in this case) line in /etc/inittab
id:3:initdefault: |
Runlevels are numbers from 0 to 6 and each one of them is used following this standard:
bash# runlevel N 3 bash# telinit 5 bash# runlevel 3 5 bash# |
Subsystems are organized under the /etc/init.d and /etc/rc.d/rcN.d directories:
All installed Subsystems put in this directory a control program, which is a script that follows a simple standard described bellow. This is a simplified listing of this directory:
Example 4. Subsystems installed in /etc/init.d
bash:/etc/init.d# ls -l -rwxr-xr-x 1 root root 9284 Aug 13 2001 functions -rwxr-xr-x 1 root root 4984 Sep 5 00:18 halt -rwxr-xr-x 1 root root 5528 Nov 5 09:44 firewall -rwxr-xr-x 1 root root 1277 Sep 5 21:09 keytable -rwxr-xr-x 1 root root 487 Jan 30 2001 killall -rwxr-xr-x 1 root root 7958 Aug 15 17:20 network -rwxr-xr-x 1 root root 1490 Sep 5 07:54 ntpd -rwxr-xr-x 1 root root 2295 Jan 30 2001 rawdevices -rwxr-xr-x 1 root root 1830 Aug 31 09:29 httpd -rwxr-xr-x 1 root root 1311 Aug 15 14:18 syslog |
Example 5. /etc/rc3.d listing
bash:/etc/rc3.d# ls -l lrwxrwxrwx 1 root root 18 Jan 14 11:59 K92firewall -> ../init.d/firewall lrwxrwxrwx 1 root root 17 Jan 14 11:59 S10network -> ../init.d/network lrwxrwxrwx 1 root root 16 Jan 14 11:59 S12syslog -> ../init.d/syslog lrwxrwxrwx 1 root root 18 Jan 14 11:59 S17keytable -> ../init.d/keytable lrwxrwxrwx 1 root root 20 Jan 14 11:59 S56rawdevices -> ../init.d/rawdevices lrwxrwxrwx 1 root root 16 Jan 14 11:59 S56xinetd -> ../init.d/xinetd lrwxrwxrwx 1 root root 18 Jan 14 11:59 S75httpd -> ../init.d/httpd lrwxrwxrwx 1 root root 11 Jan 13 21:45 S99local -> ../rc.local |
Example 6. Skeleton of a Subsystem control program in /etc/init.d
bash# /etc/init.d/mysystem Usage: mysystem {start|stop|restart|reload|condrestart|status} |
The mysystem subsystem methods you implemented will be called by users with the service command like this example:
Example 7. service command usage
bash# service mysystem start Starting MySystem: [ OK ] bash# service mysystem status Subsysten MySystem is active with pid 1234 bash# service mysystem reload Reloading MySystem: [ OK ] bash# service mysystem stop Stopping MySystem: [ OK ] bash# |
Example 8. Using the chkconfig command
bash# chkconfig --add mysystem bash# chkconfig --del mysystem |
Read the chkconfig manual page to see what more it can do for you.
This text was taken from The Official Red Hat Linux Reference Guide
An operating system's filesystem structure is its most basic level of organization. Almost all of the ways an operating system interacts with its users, applications, and security model are dependent upon the way it stores its files on a primary storage device (normally a hard disk drive). It is crucial for a variety of reasons that users, as well as programs at the time of installation and beyond, be able to refer to a common guideline to know where to read and write their binary, configuration, log, and other necessary files.
A filesystem can be seen in terms of two different logical categories of files:
Shareable vs. unsharable files
Variable vs. static files
Shareable files are those that can be accessed by various hosts; unsharable files are not available to any other hosts. Variable files can change at any time without system administrator intervention (whether active or passive); static files, such as documentation and binaries, do not change without an action from the system administrator or an agent that the system administrator has placed in motion to accomplish that task.
The reason for looking at files in this way has to do with the type of permissions given to the directory that holds them. The way in which the operating system and its users need to utilize the files determines the directory where those files should be placed, whether the directory is mounted read-only or read-write, and the level of access allowed on each file. The top level of this organization (/ directory)is crucial, as the access to the underlying directories can be restricted or security problems may manifest themselves if the top level is left disorganized (security=organization) or without a widely-utilized structure.
However, simply having a structure does not mean very much unless it is a standard. Competing structures can actually cause more problems than they fix. Because of this, Red Hat has chosen the most widely-used filesystem structure and extended it only slightly to accommodate special files used within Red Hat Linux.
This document must be distributed under the terms of GNU Free Documentation License, which makes him sufficiently free. Everybody in invited to contribute to his content and ideas.
Copyright 2002, Avi Alkalay.
This document is published in the following locations:
Linux and Main essay (24th March 2002)
It was written originally in brazilian portuguese, and then translated to english. SGML and the more-then-incredible DocBook was used, that made possible this document being distributed in other formats, found in website.
It got ready (potuguese+english) in mid march 2002. Everything changed after this epoch is cosmetics.
I wrote it to help commercial companies and OpenSource developers make plug-and-play, easy-to-use software for Linux, and this way improve Linux usability and popularity.
All concepts (from a high level perspective) described here, can be used in any UNIX flavor, or even other OS, like Windows. Maybe some day I'll write one of these for Windows....or Mac....