Support the possibility of using entry-points.

If console scripts are generated via entry-points, they will go into
/usr/local/bin on python setup.py develop and they will not be found in
/opt/stack/$PROJECT/bin any more. This patch supports a transition to
entry-points console scripts, but should still allow the old thing too.

Change-Id: I816f5f796ad00ac55a8352743ba01723df140072
diff --git a/lib/ceilometer b/lib/ceilometer
index 069e539..4c3bb52 100644
--- a/lib/ceilometer
+++ b/lib/ceilometer
@@ -23,6 +23,12 @@
 
 # set up default directories
 CEILOMETER_DIR=$DEST/ceilometer
+# Support potential entry-points console scripts
+if [ -d $CEILOMETER_DIR/bin ] ; then
+    CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin
+else
+    CEILOMETER_BIN_DIR=/usr/local/bin
+fi
 CEILOMETER_CONF_DIR=/etc/ceilometer
 CEILOMETER_AGENT_CONF=$CEILOMETER_CONF_DIR/ceilometer-agent.conf
 CEILOMETER_COLLECTOR_CONF=$CEILOMETER_CONF_DIR/ceilometer-collector.conf
@@ -54,7 +60,7 @@
 
 # start_ceilometer() - Start running processes, including screen
 function start_ceilometer() {
-    screen_it ceilometer-acompute "cd $CEILOMETER_DIR && $CEILOMETER_DIR/bin/ceilometer-agent-compute --config-file $CEILOMETER_AGENT_CONF"
-    screen_it ceilometer-acentral "cd $CEILOMETER_DIR && $CEILOMETER_DIR/bin/ceilometer-agent-central --config-file $CEILOMETER_AGENT_CONF"
-    screen_it ceilometer-collector "cd $CEILOMETER_DIR && $CEILOMETER_DIR/bin/ceilometer-collector --config-file $CEILOMETER_COLLECTOR_CONF"
+    screen_it ceilometer-acompute "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-agent-compute --config-file $CEILOMETER_AGENT_CONF"
+    screen_it ceilometer-acentral "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-agent-central --config-file $CEILOMETER_AGENT_CONF"
+    screen_it ceilometer-collector "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-collector --config-file $CEILOMETER_COLLECTOR_CONF"
 }
diff --git a/lib/cinder b/lib/cinder
index 796c107..525b6c6 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -25,6 +25,11 @@
 
 # set up default directories
 CINDER_DIR=$DEST/cinder
+if [ -d $CINDER_DIR/bin ] ; then
+    CINDER_BIN_DIR=$CINDER_DIR/bin
+else
+    CINDER_BIN_DIR=/usr/local/bin
+fi
 CINDERCLIENT_DIR=$DEST/python-cinderclient
 CINDER_CONF_DIR=/etc/cinder
 CINDER_CONF=$CINDER_CONF_DIR/cinder.conf
@@ -134,7 +139,7 @@
         mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE cinder;'
 
         # (re)create cinder database
-        $CINDER_DIR/bin/cinder-manage db sync
+        $CINDER_BIN_DIR/cinder-manage db sync
     fi
 
     if is_service_enabled c-vol; then
@@ -198,9 +203,9 @@
         fi
     fi
 
-    screen_it c-api "cd $CINDER_DIR && $CINDER_DIR/bin/cinder-api --config-file $CINDER_CONF"
-    screen_it c-vol "cd $CINDER_DIR && $CINDER_DIR/bin/cinder-volume --config-file $CINDER_CONF"
-    screen_it c-sch "cd $CINDER_DIR && $CINDER_DIR/bin/cinder-scheduler --config-file $CINDER_CONF"
+    screen_it c-api "cd $CINDER_DIR && $CINDER_BIN_DIR/cinder-api --config-file $CINDER_CONF"
+    screen_it c-vol "cd $CINDER_DIR && $CINDER_BIN_DIR/cinder-volume --config-file $CINDER_CONF"
+    screen_it c-sch "cd $CINDER_DIR && $CINDER_BIN_DIR/cinder-scheduler --config-file $CINDER_CONF"
 }
 
 # stop_cinder() - Stop running processes (non-screen)