I am trying to write a script to assist me with maven builds and deployment.
Right now what I would like is a way to determine whether I am connected to a specific wireless network. What I would like is if I am connected to the network at my workplace, then I would like to export a variable like $CONNECTED.
Then when I invoke maven, I know that I should not specify the --offline argument.
I am a new linux user, what is a fairly easy way to accomplish this ?
Actually, I do most of my Maven builds offline and only do a connected build about once a day (manually), since that's enough to keep up with the public repositories. Of course, Your Mileage May Vary if you're pulling in modules from internal projects. And if those projects publish a nightly snapshot or change during the day.
TCP/IP is designed to be able to have network-dependent apps totally independent of what network(s) the machine is plugged into and of which network interface(s) are being used. But if your intent is simply to see if you have access to a private repo, you can "ping" it. Probably the best way to do that is to attempt to "wget" one of the repo's files. If that operation fails, you're offline as far as the Maven build is concerned.
Or, if it's really critical, just forget about the offline option, since Maven will attempt to operate without the remote repositories if it cannot talk to them. It's slower, since Maven is going to keep hoping for a connection, but that way Maven handles network issues with a minimum of fuss.
Customer surveys are for companies who didn't pay proper attention to begin with.
I think I will just leave it in offline mode as you say.... and thanks for shedding some light on maven's behaviour when it can't connect to repositories... I was wondering why it didn't fail when it couldn't find a repository and --offline was not specified.
I would love to hear the motive behind writing the scripts to build and deploy using a shell script when you can use a continuos integration tools like hudson/Jenkins . Its so easy for building and managing the complete project build and deployment infrastructure.