[Ovirt-devel] [PATCH] Add trivial error() function and change code to use it
Jeff Schroeder
jeffschroed at gmail.com
Fri Oct 3 05:35:31 UTC 2008
Remove the multiple echo ... && exit 1 references and replace
them with a simple function. This makes the code a bit cleaner.
Signed-off-by: Jeff Schroeder <jeffschroeder at computer.org>
---
wui/scripts/ovirt-wui-install | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/wui/scripts/ovirt-wui-install b/wui/scripts/ovirt-wui-install
index 44798fc..1f5e1eb 100755
--- a/wui/scripts/ovirt-wui-install
+++ b/wui/scripts/ovirt-wui-install
@@ -31,6 +31,11 @@ usage() {
exit 1
} >&2
+error() {
+ echo $* >&2
+ exit 1
+}
+
find_srv() {
local dnsreply
@@ -112,7 +117,7 @@ find_srv ldap tcp
if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
SRV_HOST=${SRV_HOST%.}
srv_base=$(find_ldap_base)
- [ $? != 0 ] && echo "Failed to determine base for ldap" && exit 1
+ [ $? != 0 ] && error "Failed to determine base for ldap"
sed -i -e "s/host: .*/host: $SRV_HOST/g" \
-e "s/port: .*/port: $SRV_PORT/g" \
@@ -121,7 +126,7 @@ if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
else
# FIXME: Eventually this script should prompt for things that can't
# be found in DNS SRV records.
- echo "Failed to get ldap host/port" && exit 1
+ error "Failed to get ldap host/port"
fi
# setup an NTP step-ticker
@@ -153,7 +158,7 @@ echo "local all all trust" > /var/lib/pgsql/data/pg_hba.conf
echo "host all all 127.0.0.1 255.255.255.0 trust" >> /var/lib/pgsql/data/pg_hba.conf
service postgresql stop > /dev/null 2>&1
service postgresql start
-[ $? != 0 ] && echo "Failed to start database" && exit 1
+[ $? != 0 ] && error "Failed to start database"
wait_for_service 'psql -l -U postgres' 10 2 || exit 1
if [ -z $PASSWD ]; then
@@ -168,7 +173,7 @@ su - postgres -c "/usr/bin/dropdb $DATABASE > /dev/null 2>&1"
# create new DB
su - postgres -c "/usr/bin/createdb $DATABASE"
-[ $? != 0 ] && echo "Failed to create database $DATABASE" && exit 1
+[ $? != 0 ] && error "Failed to create database $DATABASE"
su - postgres -c "psql --dbname $DATABASE <<EOF
DROP ROLE $USERNAME;
@@ -180,7 +185,7 @@ su - postgres -c "psql --dbname $DATABASE <<EOF
VALID UNTIL 'infinity';
GRANT ALL ON DATABASE $DATABASE TO $USERNAME;
EOF"
-[ $? != 0 ] && echo "Failed to run database setup" && exit 1
+[ $? != 0 ] && error "Failed to run database setup"
touch $EXISTS_FILE
@@ -190,7 +195,7 @@ rake db:migrate
cd -
${OVIRT_DIR}/script/grant_admin_privileges ovirtadmin
-[ $? != 0 ] && echo "Failed to grant ovirtadmin privileges" && exit 1
+[ $? != 0 ] && error "Failed to grant ovirtadmin privileges"
ovirt-add-host $(hostname) ${OVIRT_DIR}/ovirt.keytab
--
1.5.6.3
More information about the ovirt-devel
mailing list