Others have mentioned good ways to keep yourself motivated. I like the idea of a spreadsheet, and also having a countdown calendar!
But as for reducing your exposure/stress to this boss for the next 6 months and making this time as pleasant for you as possible, I suggest hunkering down and being bland and boring. Attract as little attention as possible by blending in and cultivating an aura of bland boringness. Answer any questions with just the answer and nothing else for them to latch onto. No additional context (unless needed), no reasoning, no nothing. You basically want to give the boss what they want asap and send them away. Even better if you can slowly fade away and take on less responsibility and be less in the spotlight. Be invisible and don't draw attention by doing anything outstanding, but also not horrendously wrong either. Steady average blandness, and reduce your investment in work by pulling back your heart and your caring.
edit: This^ advice applies to interactions with your boss and anything within his sphere of influence, of course. In your classroom with your students, you can put in your normal effort and attention for them. But anything outside of that, as soon as you run into your boss, I'd suddenly change like a chameleon into a puddle of utter pleasant blandness.
Can you find a counselor/therapist to help you process things during this time? They can be really helpful to build your resilience and reverse any harmful messages that are sinking in and affecting you.