French police detained a 14-year-old pupil after he opened fire at a middle school in Aubagne, wounding a principal and teacher with a shotgun.