Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # This script checks if a disk|partition is allready an Ceph OSD and
- # checks also if the device entered is a block device
- #
- # Expects a device (/dev/sda) as an argument and NOT a partition
- # (/dev/sda1)
- #
- # Written by Richard Arends, mainly for puppet-ceph:
- # https://github.com/stackforge/puppet-ceph
- #
- # Exit codes:
- #
- # 0: An active 'ceph data' partition is found on $DEVICE
- # 1: An active 'ceph data' partition is NOT found on $DEVICE
- # 100: There was an error with the ceph-disk command
- # 101: Device ${DEVICE} is not a block device
- #
- DEVICE="$1"
- doExit() {
- E_CODE=$1
- echo $E_CODE
- exit $E_CODE
- }
- ###
- # Main
- ###
- if ! test -b "${DEVICE}"; then
- # Device ${DEVICE} is not a block device
- doExit 101
- fi
- CEPH_DISK_OUTPUT=$(ceph-disk list)
- CEPH_DISK_RETVAL=$(echo $?)
- if [ $CEPH_DISK_RETVAL -ne 0 ]; then
- # There was an error with the ceph-disk command
- doExit 100
- fi
- CEPH_DISK_LIST_RETVAL=$(echo "${CEPH_DISK_OUTPUT}"|grep -q " *${DEVICE}.*ceph data, active";echo $?)
- doExit "${CEPH_DISK_LIST_RETVAL}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement