Automatic control of pipeline valves