Originally i was looking for a plain AS solution because i'm not familiar with the shell script thingies at all.
So here we go: