To enable I2C and SPI interfaces and deactivate the serial console, you can use the
raspi-config tool which works as expected.
As far as I am informed, for SPI and I2C activation, the tool is just adding the required lines to the
/etc/modules file. This could be achieved by a very simple script in order to do this programatically. Is there anything else the config tool does when activating SPI or I2C which needs to be taken into account when writing an own activation script?
What does the tool do when deactivating the console on the serial port?