Add is_fedora and exit_distro_not_supported functions

Between is_fedora, is_ubuntu and is_suse, we can make the code a bit
simpler to read. We also use exit_distro_not_supported to identify
places where we need implementation details for new distros.

As "/sbin/service --skip-redirect" is Fedora-specific, guard this with a
is_fedora test too.

Change-Id: Ic77c0697ed9be0dbb5df8e73da93463e76025f0c
This commit is contained in:
Vincent Untz
2012-12-06 09:56:32 +01:00
parent e5f8d1228a
commit 00011c0847
9 changed files with 128 additions and 64 deletions
+19 -11
View File
@@ -23,22 +23,28 @@ function configure_database_mysql {
if is_ubuntu; then
MY_CONF=/etc/mysql/my.cnf
MYSQL=mysql
else
elif is_fedora; then
MY_CONF=/etc/my.cnf
if is_suse; then
MYSQL=mysql
else
MYSQL=mysqld
fi
MYSQL=mysqld
elif is_suse; then
MY_CONF=/etc/my.cnf
MYSQL=mysql
else
exit_distro_not_supported "mysql configuration"
fi
# Start mysql-server
if [[ "$os_PACKAGE" = "rpm" ]]; then
# RPM doesn't start the service
if is_fedora || is_suse; then
# service is not started by default
start_service $MYSQL
# Set the root password - only works the first time
fi
# Set the root password - only works the first time. For Ubuntu, we already
# did that with debconf before installing the package.
if ! is_ubuntu; then
sudo mysqladmin -u root password $DATABASE_PASSWORD || true
fi
# Update the DB to give user $DATABASE_USER@% full control of the all databases:
sudo mysql -uroot -p$DATABASE_PASSWORD -h127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO '$DATABASE_USER'@'%' identified by '$DATABASE_PASSWORD';"
@@ -84,10 +90,12 @@ EOF
chmod 0600 $HOME/.my.cnf
fi
# Install mysql-server
if is_suse; then
if is_ubuntu || is_fedora; then
install_package mysql-server
elif is_suse; then
install_package mysql-community-server
else
install_package mysql-server
exit_distro_not_supported "mysql installation"
fi
}
+5 -3
View File
@@ -20,7 +20,7 @@ function recreate_database_postgresql {
function configure_database_postgresql {
echo_summary "Configuring and starting PostgreSQL"
if [[ "$os_PACKAGE" = "rpm" ]]; then
if is_fedora || is_suse; then
PG_HBA=/var/lib/pgsql/data/pg_hba.conf
PG_CONF=/var/lib/pgsql/data/postgresql.conf
sudo [ -e $PG_HBA ] || sudo postgresql-setup initdb
@@ -53,10 +53,12 @@ EOF
else
sed -i "s/:root:\w\+/:root:$DATABASE_PASSWORD/" $PGPASS
fi
if [[ "$os_PACKAGE" = "rpm" ]]; then
if is_ubuntu; then
install_package postgresql
elif is_fedora || is_suse; then
install_package postgresql-server
else
install_package postgresql
exit_distro_not_supported "postgresql installation"
fi
}