Rival factions sign UN deal to end Libya's conflict