diff options
author | mharmsen <mharmsen@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2008-11-28 21:10:42 +0000 |
---|---|---|
committer | mharmsen <mharmsen@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2008-11-28 21:10:42 +0000 |
commit | fe389a989ca983779e0abd34018c61f805deeea4 (patch) | |
tree | fa47907f4c6a544bd4e0e0df982542ea742a12fc /pki/dogtag/scripts/remove_ds_instance | |
parent | d13a26663e2c1986b3b596766db9f4b9cce3f2d6 (diff) | |
download | pki-fe389a989ca983779e0abd34018c61f805deeea4.tar.gz pki-fe389a989ca983779e0abd34018c61f805deeea4.tar.xz pki-fe389a989ca983779e0abd34018c61f805deeea4.zip |
Bugzilla Bug #445402: Rename 'linux' to 'dogtag'.
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@148 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/dogtag/scripts/remove_ds_instance')
-rwxr-xr-x | pki/dogtag/scripts/remove_ds_instance | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/pki/dogtag/scripts/remove_ds_instance b/pki/dogtag/scripts/remove_ds_instance new file mode 100755 index 000000000..d81326c63 --- /dev/null +++ b/pki/dogtag/scripts/remove_ds_instance @@ -0,0 +1,156 @@ +#!/bin/sh +# BEGIN COPYRIGHT BLOCK +# This Program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; version 2 of the License. +# +# This Program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA. +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# END COPYRIGHT BLOCK +# + +## Always switch into this base directory +## prior to script execution so that all +## of its output is written to this directory + +cd `dirname $0` + + +## +## This script MUST be run as root! +## + +ROOTUID=0 + +OS=`uname` +if [ "${OS}" = "Linux" ] ; then + MY_EUID=`/usr/bin/id -u` + MY_UID=`/usr/bin/id -ur` + USERNAME=`/usr/bin/id -un` +else + printf "ERROR: Unsupported operating system '${OS}'!\n" + exit 255 +fi + +if [ "${MY_UID}" != "${ROOTUID}" ] && + [ "${MY_EUID}" != "${ROOTUID}" ] ; then + printf "ERROR: The '$0' script must be run as root!\n" + exit 255 +fi + + +## First, check for the existence of a directory server on this machine. +if [ ! -e /etc/init.d/dirsrv ]; then + printf "The Directory Server package does NOT exist on this machine!\n" + exit 255 +fi + + +## Second, check for the existence of a directory server administration server +## on this machine. +if [ -e /usr/sbin/ds_removal ] && + [ -d /usr/lib/dirsrv/cgi-bin ] || + [ -d /usr/lib64/dirsrv/cgi-bin ]; then + printf "This machine contains a Directory Server Administration\n" + printf "Server which means that Directory Server instances may\n" + printf "have been registered with the Administration Server.\n\n" + while : + do + printf "Do you wish to use the '/usr/sbin/ds_removal' tool\n" + printf "instead of '$0'? [yn] " + read ANSWER + printf "\n" + if [ "${ANSWER}" = "Y" ] || + [ "${ANSWER}" = "y" ] ; then + printf "\n" + printf "Please RUN the '/usr/sbin/ds_removal' tool to remove\n" + printf "the desired DS instance instead of '$0'.\n\n" + exit 255 + elif [ "${ANSWER}" = "N" ] || + [ "${ANSWER}" = "n" ] ; then + printf "\n" + break + else + continue + fi + done +fi + + +Usage() +{ + printf "Usage: $0 -s server_id\n" + printf " server_id: Directory server identifier; slapd-<server_id>\n" +} + +error="" +server_id="" +ds_server="" +ds_remove_cgi="" + +while [ "$1" != "" ] +do + if [ "$1" = "-s" ]; then + shift + server_id=$1 + shift + elif [ "$1" = "-h" -o "$1" = "-H" -o "$1" = "--help" ]; then + Usage + exit 0 + else + printf "ERROR: Option '$1' is not supported!\n" + Usage + exit 1 + fi +done + +if [ "$server_id" = "" ]; then + error="Directory Server identifier is missing!" +else + if [ -d "/usr/lib/dirsrv/slapd-${server_id}" ]; then + ds_server="/usr/lib/dirsrv/slapd-${server_id}" + ds_remove_cgi="./ds_remove_cgi_32" + elif [ -d "/usr/lib64/dirsrv/slapd-${server_id}" ]; then + ds_server="/usr/lib64/dirsrv/slapd-${server_id}" + ds_remove_cgi="./ds_remove_cgi_64" + else + error="Directory server identifier 'slapd-${server_id}' does not exist!" + fi +fi + +if [ "$error" != "" ]; then + printf "ERROR: ${error}\n" + Usage + exit 1 +fi + +QUERY_STRING="InstanceName=slapd-${server_id}"; export QUERY_STRING +REQUEST_METHOD=GET; export REQUEST_METHOD + +if [ -c /dev/null ]; then + NULL=/dev/null +else + NULL=/tmp/ds_remove.out +fi + +${ds_remove_cgi} > $NULL << EOF +EOF + +if [ -d "${ds_server}" ]; then + printf "FAILED to remove '${ds_server}'!\n" +else + printf "Successfully removed '${ds_server}'!\n" + printf "NOTE: Copies of your security databases have been saved\n" + printf " in '/etc/dirsrv/slapd-${server_id}.removed'!\n" +fi + +exit $? + |