The discharge tells you the cause: pus for bacteria, water for viruses.
In primary care, conjunctivitis (inflammation of the conjunctiva) is the commonest eye condition. Bacterial conjunctivitis causes purulent discharge, with the lids stuck together on waking. Viral conjunctivitis causes watery discharge, a recent URTI and preauricular lymphadenopathy. It is self-limiting over 1–2 weeks. If needed, use chloramphenicol drops or ointment, or fusidic acid in pregnancy. Contact lens users should stop wearing lenses. Don't share towels; school exclusion is not needed.