That's the only way only way I'm aware of; detailed below for others who might stumble on this trying to figure out how to do it.
Add scripfile to the manifest (XML), below the </description>
tag:
<scriptfile>my_script.php</scriptfile>
my_script.php:
class PlgSystemPluginnameInstallerScript
{
public function install($parent)
{
// Enable plugin
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->update('#__extensions');
$query->set($db->quoteName('enabled') . ' = 1');
$query->where($db->quoteName('element') . ' = ' . $db->quote('PLUGIN_NAME_GOES_HERE'));
$query->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$db->setQuery($query);
$db->execute();
}
}
Tip: If it's a content plugin, replace PlgSystemPluginnameInstallerScript
with PlgContentPluginnameInstallerScript
.