diff options
author | Steven Dake <sdake@redhat.com> | 2012-04-24 15:29:08 -0700 |
---|---|---|
committer | Steven Dake <sdake@redhat.com> | 2012-04-24 15:29:30 -0700 |
commit | 724b5f3902c2117040d21b830f7b276bb5dc4e1e (patch) | |
tree | a22dcc79dc9d9f64f72c4b4d58fa7ccf824982d8 | |
parent | 83e6754c823bdba656c8073e24d4a696b1d7b592 (diff) | |
download | heat-cfntools-724b5f3902c2117040d21b830f7b276bb5dc4e1e.tar.gz |
Make heat-db-setup generic enough to run on RPM or DEB distributions
Signed-off-by: Steven Dake <sdake@redhat.com>
-rwxr-xr-x | bin/heat-db-setup (renamed from bin/heat-db-setup-fedora) | 46 | ||||
-rwxr-xr-x | setup.py | 2 |
2 files changed, 38 insertions, 10 deletions
diff --git a/bin/heat-db-setup-fedora b/bin/heat-db-setup index 9dc6374..5eef229 100755 --- a/bin/heat-db-setup-fedora +++ b/bin/heat-db-setup @@ -23,8 +23,10 @@ Set up a local MySQL database for use with heat. This script will create a 'heat' database that is accessible only on localhost by user 'heat' with password 'heat'. -Usage: heat-db-setup [options] +Usage: heat-db-setup <rpm|deb> [options] Options: + select a distro type (rpm or debian) + --help | -h Print usage information. --heatpw <pw> | -n <pw> @@ -49,14 +51,14 @@ EOF install_mysql_server() { if [ -z "${ASSUME_YES}" ] ; then - yum install mysql-server + $PACKAGE_INSTALL mysql-server else - yum install -y mysql-server + $PACKAGE_INSTALL -y mysql-server fi } start_mysql_server() { - systemctl start mysqld.service + $SERVICE_START } MYSQL_HEAT_PW_DEFAULT="heat" @@ -64,6 +66,32 @@ MYSQL_HEAT_PW=${MYSQL_HEAT_PW_DEFAULT} HEAT_CONFIG="/etc/heat/heat-engine.conf" ASSUME_YES="" +if [ $# -eq 0 ] +then + usage +fi + +case "$1" in + rpm) + echo "Installing on an RPM system." + PACKAGE_INSTALL="yum install" + PACKAGE_STATUS="rpm -q" + SERVICE_MYSQLD="mysqld" + SERVICE_START="service $SERVICE_MYSQLD start" + SERVICE_STATUS="service $SERVICE_MYSQLD status" + SERVICE_ENABLE="chkconfig" + ;; + deb) + echo "Installing on a Debian system." + PACKAGE_INSTALL="apt-get install" + PACKAGE_STATUS="dpkg-query -s" + SERVICE_MYSQLD="mysql" + SERVICE_START="service $SERVICE_MYSQLD start" + SERVICE_STATUS="service $SERVICE_MYSQLD status" + SERVICE_ENABLE="" + ;; +esac + while [ $# -gt 0 ] do case "$1" in @@ -93,7 +121,7 @@ done # Make sure MySQL is installed. NEW_MYSQL_INSTALL=0 -if ! rpm -q mysql-server > /dev/null +if ! $PACKAGE_STATUS mysql-server > /dev/null then if [ -z "${ASSUME_YES}" ] ; then printf "mysql-server is not installed. Would you like to install it now? (y/n): " @@ -118,16 +146,16 @@ fi # Make sure mysqld is running. -if ! systemctl status mysqld.service > /dev/null +if ! $SERVICE_STATUS > /dev/null then if [ -z "${ASSUME_YES}" ] ; then - printf "mysqld is not running. Would you like to start it now? (y/n): " + printf "$MYSQL_SERVICE is not running. Would you like to start it now? (y/n): " read response case "$response" in y|Y) ;; n|N) - echo "mysqld must be running. Please start it before proceeding." + echo "$MYSQL_SERVICE must be running. Please start it before proceeding." exit 0 ;; *) @@ -139,7 +167,7 @@ then start_mysql_server # If we both installed and started, ensure it starts at boot - [ $NEW_MYSQL_INSTALL -eq 1 ] && chkconfig mysqld on + [ $NEW_MYSQL_INSTALL -eq 1 ] && $SERVICE_ENABLE $SERVICE_MYSQLD on fi @@ -90,7 +90,7 @@ setup( scripts=['bin/heat', 'bin/heat-api', 'bin/heat-engine', - 'bin/heat-db-setup-fedora'], + 'bin/heat-db-setup'], data_files=[('/etc/heat', ['etc/heat-api.conf', 'etc/heat-api-paste.ini', 'etc/heat-engine.conf', |