Automata on ordinals and automaticity of linear orders