#!/bin/sh

PASSWORD=$(grep RUDDER_OPENLDAP_BIND_PASSWORD /opt/rudder/etc/rudder-passwords.conf|sed "s/RUDDER_OPENLDAP_BIND_PASSWORD:\(.*\)/\1/")

/opt/rudder/bin/ldapmodify -x -D "cn=Manager,cn=rudder-configuration" -w ${PASSWORD} << EOF
dn: nodeGroupId=hasPolicyServer-root,groupCategoryId=SystemGroups,groupCategoryId=GroupRoot,ou=Rudder,cn=rudder-configuration
changetype: modify
delete: nodeId
nodeId: # The content of this file should be replaced with a valid U
EOF

/opt/rudder/bin/ldapdelete -r -x -D "cn=Manager,cn=rudder-configuration" -w ${PASSWORD} "nodeId=\23 The content of this file should be replaced with a valid U,ou=Nodes,ou=Accepted Inventories,ou=Inventories,cn=rudder-configuration"

/opt/rudder/bin/ldapdelete -r -x -D "cn=Manager,cn=rudder-configuration" -w ${PASSWORD} "nodeId=\23 The content of this file should be replaced with a valid U,ou=Nodes,cn=rudder-configuration"
