#!/bin/bash
# shutdown service
clusvcadm -d service:web-service
# remove the filesystems
umount /var/www/html
lvremove -f /dev/vg_cluster/lv_apache
vgremove -f vg_cluster
pvremove -f /dev/mapper/mpathap1
# remove the subservices
#ccs -h armitage --rmsubservice web-service clusterfs ref=web-gfs
#ccs -h armitage --rmsubservice web-service script ref=web-script
#ccs -h armitage --rmsubservice web-service ip ref=172.31.100.50
# remove the service
ccs -h armitage --rmservice web-service domain=prefer_armitage max_restarts=3 name=web-service recovery=restart restart_expire_time=600
# remove resources
ccs -h armitage --rmresource script name=web-script file=/etc/rc.d/init.d/httpd
ccs -h armitage --rmresource ip address=172.31.100.50 monitor_link=on sleeptime=1
ccs -h armitage --rmresource clusterfs device=/dev/mapper/vg_cluster-lv_apache force_unmount=on fstype=gfs2 mountpoint=/var/www/html name=web-gfs options=noatime self_fence=on
# remove failover domains
#ccs -h armitage --rmfailoverdomainnode prefer_neuromancer finn.tc.redhat.com 20
#ccs -h armitage --rmfailoverdomainnode prefer_neuromancer armitage.tc.redhat.com 10
#ccs -h armitage --rmfailoverdomainnode prefer_neuromancer neuromancer.tc.redhat.com 1
#ccs -h armitage --rmfailoverdomainnode prefer_finn armitage.tc.redhat.com 20
#ccs -h armitage --rmfailoverdomainnode prefer_finn neuromancer.tc.redhat.com 10
#ccs -h armitage --rmfailoverdomainnode prefer_finn finn.tc.redhat.com 1
#ccs -h armitage --rmfailoverdomainnode prefer_armitage neuromancer.tc.redhat.com 20
#ccs -h armitage --rmfailoverdomainnode prefer_armitage finn.tc.redhat.com 10
#ccs -h armitage --rmfailoverdomainnode prefer_armitage armitage.tc.redhat.com 1
ccs -h armitage --rmfailoverdomain prefer_neuromancer restricted ordered
ccs -h armitage --rmfailoverdomain prefer_finn restricted ordered
ccs -h armitage --rmfailoverdomain prefer_armitage restricted ordered
# remove fencing
ccs -h armitage --rmfenceinst wti neuromancer.tc.redhat.com power port=1
ccs -h armitage --rmfenceinst wti finn.tc.redhat.com power port=2
ccs -h armitage --rmfenceinst wti armitage.tc.redhat.com power port=4
ccs -h armitage --rmfencedev wti agent=fence_wti ipaddr=wti.tc.redhat.com login=root passwd=red22hat power_wait=5
ccs -h armitage --rmmethod power neuromancer.tc.redhat.com
ccs -h armitage --rmmethod power finn.tc.redhat.com
ccs -h armitage --rmmethod power armitage.tc.redhat.com
# remove nodes
ccs -h armitage --rmnode neuromancer.tc.redhat.com
ccs -h armitage --rmnode finn.tc.redhat.com
ccs -h armitage --rmnode armitage.tc.redhat.com
ccs -h armitage --sync --activate
#ccs -h armitage --stopall
for i in armitage finn neuromancer; do ssh $i "rm -f /etc/cluster/cluster.conf"; done