Open penglongli opened 7 years ago
#!/bin/bash DIR_NAME=$1 ETCD_DIR_ARR=() del_key() { CURRENT_DIR_NAME=$1 CURRENT_RESULT=$(etcdctl ls ${CURRENT_DIR_NAME}) if [ "$CURRENT_RESULT" = $CURRENT_DIR_NAME ]; then etcdctl rm $CURRENT_DIR_NAME else ETCD_DIR_ARR+=(${CURRENT_DIR_NAME}) ITEMS=($CURRENT_RESULT) for ITEM in ${ITEMS[@]} do del_key $ITEM done fi } del_dir() { ARR_LENGTH=${#ETCD_DIR_ARR[@]} for ((i=($ARR_LENGTH-1); i>=0; i--)) do etcdctl rmdir ${ETCD_DIR_ARR[$i]} done } del_key $DIR_NAME del_dir
Usage:
./etcd_rm.sh DIR
wait add
Etcd v2
Usage:
Etcd v3
wait add