Made stop scripts more consistent

stopFrontend and stopFactory now both accept the -f/-force option
to try to kill a second time and try a hard kill at the end
To maintain the previous behavior stopFrontend always does a forced stop, even
without the option on the command line
Changed the loop in stopFactory to wait only instead of reissuing a kill on
each iteration. Multiple kill commands with the same signal are not improving
the effectivenessmay and may cause a race condition (if processes are created
recycling the same process number, rare but possible)
The processes may still be recreated with the same number in the current version
but worse case the signal in the second and 3rd attempt would be sent to a wrong
process that could ignore it

The total wait in stopFrontend is now 60 sec (.6*100)
The total wait in stopFactory is now 65 sec (.5*130)
Added 30 sec a wait loop in the restart command

If the frontend/factory is not shut down it waits up to 30 sec
(checking every sec). A failure message is printed if shutdown
failed and no start is attempted
Improved verbosity and notifications in failures to acquire lock files during startup

Old processes may remain stuck (e.g. on IO) or the lock files may remain in incosistent.
Files may have to be cleared or processes may have to be killed by the administrator
sometime even with a reboot.
The previous message was confusing (AlreadyRunning)
The current is more explicit on the failure to acquire the lock, specifies the lock
file and logs also the exception in the log file
Return different code when stopping and already stopped

Both the factory and frontend stop procedure now return:
- 0 if stop was successfull
- 1 if invoked incorrectly or unable to stop the services (some unkillable process)
- 2 if it was already stopped

Exit code 1 will block composite actions like restart, reconfig, ...
Exit code 2 is OK (will continue to the next steps), like 0.
added frontend RPM init script and harmonized spacing in frontend template
added correct frontend RPM init script (removed wrong one) and small change in frontend template
pushd/popd for reconfig_glidein fixed
added factory RPM init script and harmonized factory template, added pushd/popd around reconfig_glidein
single quote is not escaped in double quote string in echo
fix AlreadyRunning reference error
stdout was not initialized if exception happened
was using range that does not exist in shell
Adding this_is_rpm_install variable for template

in create_initd_startup(startup_fname, frontend_dir, glideinWMS_dir, cfg_name, is_rpm='')
Usinf the value of parameter is_rpm
By default it has value '', that enable autodiscovery in the startup script.
A value of 'yes' would create a startup script for RPM, anything else a startup script for tarballs.
unified template for tarball and RPM

Now the script can be invoked as root or the service user and the template will generate both the RPM and tarball script

SU_COMMAND su and runuser if available
invoke_as_factory/frontend (wrapper function)

used some local variables when possible

removed export for FRONTEND/FACTORY_USER - no subprocess is checking env var
left export for $HOME $X509_CERT_DIR, some python code checks $HOME

removed downtime from frontend (not reachable) only in factory

echo $”some string” -> echo “some string”

reconfig: better parameter handlin

unified usage string in both scripts
- would be good to change command syntax
fixed % in template, finction get_user() because logname rerutns roos also after su
removed pushd/popd output
replaced logname w/ whoami (current user)
fix typo
script to generate RPM init.d files from templates
fixed template selection