You can use IP SLA, object tracking, and EEM for this. For example:
ip sla 1
icmp-echo 10.1.1.1
ip sla schedule 1 life forever start now
!
track 1 ip sla 1 reachability
!
event manager applet ping-watch
event track 1 state down
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "int range gi0/1 - 4"
action 4.0 cli command "shut"
action 5.0 cli command "end"