There are many Arduino scripts to drive rotary tables but not many that do linear movement. I have written one that does both and supports multiple devices (where a device can be defined as linear or rotary). Some people have used it to index on a mill that does not support a 4th axis by running a tool past a proximity sensor in the Gcode to trigger a switch. This week, a chap who wants to use it to drive his camera up and down a rail. His requirements were simpler. He just wanted to have continuous movement when he held a button down and move a defined distance whenever he pressed a button. It supports that without any modification. This is a high performance interrupt driven solution which included trapezoidal acceleration profiles
You can grab the code here
Interrupt Driven Rotary Table controller - Home Model Engine Machinist
There are some hardware dependencies so read the thread carefully.
This will need some modification to meet your requirements. Have a play with it, If you would like me to customise it for you for a fee, I am open to that too, Just send me a PM.