Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wonder if it is possible to create such .sh script that a normal user would be capable to start with something like nohup ./superScript.sh >& /dev/null & and which would once a minute look into some SVN, find out current version and if there was an update run commands like:

kill `ps aux | grep -F 'ServerAPP' | grep -v -F 'grep' | awk '{ print $2 }'` 
./server_automated_net_setup.sh
cd server/install-dir/
export LD_LIBRARY_PATH=./:~/server/install-dir/lib_boost:~/server/install-dir/lib_openSSL
nohup ./ServerAPP >& /dev/null &

that would kill currently running app, run some auto update script we already have in users home ~ and run it again.

Is it possible to create such script and how to do it?

share|improve this question
1  
Please don't cross post the same question on multiple stackexchange sites. unix.stackexchange.com/q/29478/7285 is the original. –  psusi Jan 19 '12 at 23:43

2 Answers 2

If you have access to svn server, the the better approach is to define svn postcommit hook. This way you avoid pooling.

Are we there yet? Are we there yet? Are we there yet? - see how annoying is that?

Advantages of listener over pooling:

  • you will know immediately (not with 1 minute delay) because you tell svn to tell you when anything gets changed.
  • you don't waste your resources for asking and server resources for answering
share|improve this answer

The script would look something like this:

#! /bin/bash

REMOTE_REPO="svn://path/to/remote/repo"
LOCAL_REPO="/path/to/local/repo"

REMOTE_REV=`svn info $REMOTE_REPO | grep '^Revision:' | awk '{print $2}'`
LOCAL_REV=`svn info $LOCAL_REPO | grep '^Revision:' | awk '{print $2}'`

if [ $REMOTE_REV -eq $LOCAL_REV ]; then
    exit 0;
else
    # Run your commands here.
    cd $LOCAL_REPO
    svn up
fi

This script just compares the current revision number of both the local and remote svn repositories. If the differ than it runs some commands. If they are the same, it just exists.

Then you'd just have to set up a cron job to run how often you want.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.