. /usr/share/debconf/confmodule
-NOVA_COM_DEF=/etc/default/nova-common
+CINDER_COM_DEF=/etc/default/cinder-common
# Set the debconf value to whatever is in the config file
-if [ -f ${NOVA_COM_DEF} ] ; then
- . ${NOVA_COM_DEF}
+if [ -f ${CINDER_COM_DEF} ] ; then
+ . ${CINDER_COM_DEF}
fi
-if ! [ "${NOVA_ENABLE}" = "true" ] ; then
- NOVA_ENABLE=false
+if ! [ "${CINDER_ENABLE}" = "true" ] ; then
+ CINDER_ENABLE=false
fi
-db_set nova-common/start_services ${NOVA_ENABLE}
+db_set cinder-common/start_services ${CINDER_ENABLE}
-db_input low nova-common/start_services || true
+db_input low cinder-common/start_services || true
db_go
# Write a default config file if it doesn't exist yet
# note that the value will be overwritten by the postinst
-if ! [ -f ${NOVA_COM_DEF} ] ; then
- echo "# defaults file for nova daemons
+if ! [ -f ${CINDER_COM_DEF} ] ; then
+ echo "# defaults file for cinder daemons
-# start nova daemons from init.d script?
+# start cinder daemons from init.d script?
# only allowed values are \"true\" and \"false\"
-NOVA_ENABLE=true" >${NOVA_COM_DEF}
+CINDER_ENABLE=true" >${CINDER_COM_DEF}
fi
+db_input high nova-common/configure_db || true
+db_go
+
+db_get cinder-common/configure_db
+if [ "$RET" = "true" ]; then
+ if [ -f /usr/share/dbconfig-common/dpkg/config ]
+ then
+ dbc_dbtypes="sqlite3, mysql, pgsql"
+ dbc_authmethod_user="password"
+ dbc_basepath="/var/lib/cinder"
+ dbc_dbname="cinder"
+ . /usr/share/dbconfig-common/dpkg/config
+ dbc_go cinder-common $@
+ fi
+fi
#!/bin/sh -e
-if [ "$1" = "configure" ]; then
+if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then
if ! getenv group cinder > /dev/null 2>&1; then
- addgroup --system cinder >/dev/null
+ addgroup --quiet --system cinder >/dev/null
fi
if ! getenv passwd cinder > /dev/null 2>&1; then
- adduser --system --home /var/lib/cinder --ingroup cinder --no-create-home \
+ adduser --quiet --system --home /var/lib/cinder --ingroup cinder --no-create-home \
--shell /bin/false cinder
fi
+ # Create config files if they don't exist
+ if ! [ -d /etc/cinder ] ; then
+ mkdir /etc/cinder
+ fi
+ if ! [ -e /etc/cinder/cinder.conf ] ; then
+ cp /usr/share/doc/cinder-common/cinder.conf.dist /etc/cinder/cinder.conf
+ fi
+
chown -R cinder:adm /var/log/cinder
chmod 0750 /var/log/cinder
chown -R cinder:cinder /var/lib/cinder /etc/cinder
chmod 0750 /etc/cinder
chmod 0440 /etc/sudoers.d/cinder_sudoers
+ . /usr/share/debconf/confmodule
+
+ db_get cinder-common/configure_db
+
+ if [ "$RET" = "true" ]; then
+ . /usr/share/dbconfig-common/dpkg/postinst
+
+ db_get cinder-common/database-type
+ if [ "$RET" = "sqlite3" ]
+ then
+ dbc_name="cinder.sqlite"
+ db_set cinder-common/db/dbname $dbc_name
+ fi
+
+ dbc_dbfile_owner="cinder:cinder"
+ dbc_go cinder-common $@
+
+ if [ "$dbc_install" = "true" ]
+ then
+
+ case "$dbc_dbtype" in
+ mysql)
+ [ -n "$dbc_dbport" ] && dbport=:$dbc_dbport
+ SQL_CONNECTION="mysql://$dbc_dbuser:$dbc_dbpass@${dbc_dbserver:-localhost}$dbport/$dbc_dbname"
+ ;;
+ pgsql)
+ [ -n "$dbc_dbport" ] && dbport=:$dbc_dbport
+ SQL_CONNECTION="pgsql://$dbc_dbuser:$dbc_dbpass@${dbc_dbserver:-localhost}$dbport/$dbc_dbname"
+ ;;
+ *)
+ SQL_CONNECTION="sqlite:///$dbc_basepath/$dbc_dbname"
+ ;;
+ esac
+
+ sed -e "s,^[- \t]*sql_connection=.\+,sql_connection=$SQL_CONNECTION," -i /etc/cinder/cinder.conf
+
+ fi
+ fi
+
if ! grep -q sql_connection /etc/cinder/cinder.conf
then
su -s /bin/sh -c 'cinder-manage db sync' cinder
fi
- if [ -e /var/lib/cinder/cinder.sqlite ]; then
- chown cinder:cinder /var/lib/cinder/cinder.sqlite
- chown 0600 /var/lib/cinder/cinder.sqlite
- fi
-
- . /usr/share/debconf/confmodule
-
- db_get nova-common/start_services
+ db_get cinder-common/start_services
if [ " $RET" = "false" ]; then
- sed -e "s,^NOVA_ENABLE=.\+,NOVA_ENABLE=false," -i /etc/default/nova
+ sed -e "s,^CINDER_ENABLE=.\+,CINDER_ENABLE=false," -i /etc/default/cinder
fi
-
fi
+chmod 0640 /etc/cinder/cinder.conf
+
#DEBHELPER#
--- /dev/null
+#!/bin/sh
+
+set -e
+
+if [ -f /usr/share/debconf/confmodule ]; then
+ . /usr/share/debconf/confmodule
+fi
+
+db_get cinder-common/configure_db
+if [ "$RET" = "true" ]; then
+
+ if [ -f /usr/share/dbconfig-common/dpkg/postrm ]; then
+ . /usr/share/dbconfig-common/dpkg/postrm
+ dbc_go cinder-common $@
+ else
+ rm -f /etc/dbconfig-common/cinder-common.conf
+ if which ucf >/dev/null 2>&1; then
+ ucf --purge /etc/dbconfig-common/cinder-common.conf
+ ucfr --purge cinder-common /etc/dbconfig-common/cinder-common.conf
+ fi
+ fi
+fi
+
+if [ "$1" = "purge" ] ; then
+ rm -f /etc/cinder/cinder.conf
+ rm -f /etc/default/cinder-common
+fi
+
+#DEBHELPER#
--- /dev/null
+#!/bin/sh
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+db_get cinder-common/configure_db
+if [ "$RET" = "true" ]; then
+ . /usr/share/dbconfig-common/dpkg/prerm
+ dbc_go cinder-common $@
+fi
+
+#DEBHELPER#
--- /dev/null
+Template: cinder-common/start_services
+Type: boolean
+Default: true
+_Description: Start cinder services at boot?
+ Please choose whether you want to start Cinder services when the
+ machine is booted up.
+
+Template: cinder-common/configure_db
+Type: boolean
+Default: false
+_Description: Set up a database for Cinder?
+ No database has been set up for Cinder to use. If you want
+ to set one up now, please make sure you have all needed
+ information:
+ .
+ * the host name of the database server (which must allow TCP
+ connections from this machine);
+ * a username and password to access the database;
+ * the type of database management software you want to use.
+ .
+ If you don't choose this option, no database will be set up and Cinder
+ will use regular SQLite support.
+ .
+ You can change this setting later on by running "dpkg-reconfigure
+ -plow cinder-common".
#!/bin/sh -e
-if [ "$1" = "configure" ]; then
- # only migrate the database if configured to use a local sqlite db (default)
- if grep -q 'sql_connection=sqlite' /etc/cinder/cinder.conf ; then
- su -s /bin/sh -c 'cinder-manage db sync' cinder
- fi
- if [ -e /var/lib/cinder/cinder.sql ] ; then
- chown cinder:cinder /var/lib/cinder/cinder.sqlite
- chmod 0640 /var/lib/cinder/cinder.sqlite
- fi
-fi
#DEBHELPER#
Package: cinder-common
Architecture: all
-Depends: python-cinder (= ${binary:Version}), ${python:Depends}, ${misc:Depends}, adduser
+Depends: python-cinder (= ${binary:Version}), ${python:Depends}, ${misc:Depends}, adduser, debconf, dbconfig-common
Provides: ${python:Provides}
Description: Cinder starage service - common files
Cinder is a storage service for the Openstack project