Another way is to just use a reversing relay and 2 limit switches, and use a constant current limit on the PSU to the DC motor.
That CC will limit starting and reversing currents, ie; will give the gentle acceleration/decelerations needed on the polarity changes. You can dial in the reversing properties by adjusting the CC limit.
The limit switches will need to be the type that can be travelled past, as there will be a natural distance needed AFTER the switch, for the reversing operation.