Replace screen_it() with run_process() throughout

run_process will use screen if USE_SCREEN=True (the default),
otherwise it will simply start the requested service. Therefore
wherever screen_it used, run_process can be instead.

Where stop_screen was found it has been replaced with stop_process.

A tail_log function has been added which will tail a logfile in a
screen if USE_SCREEN is True.

lib/template has been updated to reflect the use of the new
functions.

When using sg the quoting in run_process gets very complicated.
To get around this run_process and the functions it calls accepts
an optional third argument. If set it is a group to be used with sg.

Change-Id: Ia3843818014f7c6c7526ef3aa9676bbddb8a85ca
diff --git a/lib/keystone b/lib/keystone
index da5cf89..66ab3db 100644
--- a/lib/keystone
+++ b/lib/keystone
@@ -474,11 +474,11 @@
 
     if [ "$KEYSTONE_USE_MOD_WSGI" == "True" ]; then
         restart_apache_server
-        screen_it key "cd $KEYSTONE_DIR && sudo tail -f /var/log/$APACHE_NAME/keystone.log"
-        screen_it key-access "sudo tail -f /var/log/$APACHE_NAME/keystone_access.log"
+        tail_log key /var/log/$APACHE_NAME/keystone.log
+        tail_log key-access /var/log/$APACHE_NAME/keystone_access.log
     else
         # Start Keystone in a screen window
-        screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF --debug"
+        run_process key "$KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF --debug"
     fi
 
     echo "Waiting for keystone to start..."
@@ -499,7 +499,7 @@
 # stop_keystone() - Stop running processes
 function stop_keystone {
     # Kill the Keystone screen window
-    screen_stop key
+    stop_process key
     # Cleanup the WSGI files and VHOST
     _cleanup_keystone_apache_wsgi
 }