The republic was run by Barbary pirates who used the two cities as base ports for starting attacks on shipping . The republic was run by Barbary pirates who used the two cities as base ports for launching attacks on shipping .