The line "To the shores of Tripoli" refers to the First Barbary War, and specifically the Battle of Derne in 1805.
And the first part due to drinking water in meh-eek-O? LOL! I am familiar with the MC “fight song”. :-)