There's no comparison.
There's no military solution in Afghanistan because the Taliban still enjoy the support of large swathes of the population and hence are impossible to root out, while the Shabaab are hated by the people. Most COIN campaigns involve at least some sort of hearts and minds push where you try to convince the people that it isn't in their interest to support an insurgency. In the case of Somalia, there's no need because the insurgents have already lost any support they might have originally had.
I think it is safe to say that the vast majority of Somalis supported the resistance against Ethiopia and once viewed Shabaab as liberators who would finally unite Somalia, but with the continuous heinous and barbaric actions of Shabaab, they went from liberators to oppressors in the eyes of most. With Shabaab being pushed into a corner and reports of growing infighting within their ranks, I think it is safe to say that they'll go the way of every other armed group in Somali history.
There's the equivalent of the TFG in Afghanistan. There's also equivalent propaganda demonizing the Taliban, labeling them Khawaarij, Wahhabis, radicals, cowards, barbarians, etc. Karzai's regime and Western media also claim most Afghans do not support the Taliban. It's the same story; not much difference. Over the course of the years, ISAF has been claiming the Taliban are finished and on their last throes. I'm sure you've heard or read about those. So, don't be surprised in the near future if the West and their vassals (Ethiopia, Kenya, Uganda, Burundi, Djibouti, etc) want to make peace with al-Shabaab.