Agreement reinstates rebel leader Riek Machar as vice president, formally ending five years of bloody civil war.