update firmware and software


I need to upgrade the whole firmware of atmega and whole linux for ar9331 from remote repository (through wifi) when I put in my repository new files.

I cannot use arduino sketch and I m not in the same room of my arduino yun .

Do you know I can that ?
It is possibile ?
Can I write a code about that ? for linux o for atmega ?