Issue 197: smarter forget.sh

This commit is contained in:
Adrian Cole 2011-10-16 03:07:58 -07:00
parent 9b5e41207b
commit 5144f0ad4b
8 changed files with 51 additions and 35 deletions

View File

@ -44,13 +44,15 @@ function forget {
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID]
return 1;
} || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &
sleep 1
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start"
RETURN=$?
# this is generally followed by findPid, so we shouldn't exit
# immediately as the proc may not have registered in ps, yet
test $RETURN && sleep 1
return $RETURN;
}
return 0
}
export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin
case $1 in
@ -101,7 +103,7 @@ grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
apt-get update -qq
which curl || apt-get install -f -y -qq --force-yes curl
apt-get install -f -y -qq --force-yes openjdk-7-jdk||apt-get install -f -y -qq --force-yes openjdk-6-jdk
apt-get install -f -y -qq --force-yes openjdk-6-jdk
echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> $HOME/.bashrc
END_OF_SCRIPT

View File

@ -44,13 +44,15 @@ function forget {
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID]
return 1;
} || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &
sleep 1
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start"
RETURN=$?
# this is generally followed by findPid, so we shouldn't exit
# immediately as the proc may not have registered in ps, yet
test $RETURN && sleep 1
return $RETURN;
}
return 0
}
export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin
case $1 in
@ -101,7 +103,7 @@ grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
apt-get update -qq
which curl || apt-get install -f -y -qq --force-yes curl
apt-get install -f -y -qq --force-yes openjdk-7-jdk||apt-get install -f -y -qq --force-yes openjdk-6-jdk
apt-get install -f -y -qq --force-yes openjdk-6-jdk
echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> $HOME/.bashrc
iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT
iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT

View File

@ -44,13 +44,15 @@ function forget {
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID]
return 1;
} || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &
sleep 1
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start"
RETURN=$?
# this is generally followed by findPid, so we shouldn't exit
# immediately as the proc may not have registered in ps, yet
test $RETURN && sleep 1
return $RETURN;
}
return 0
}
export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin
case $1 in
@ -80,7 +82,7 @@ grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
apt-get update -qq
which curl || apt-get install -f -y -qq --force-yes curl
apt-get install -f -y -qq --force-yes openjdk-7-jdk||apt-get install -f -y -qq --force-yes openjdk-6-jdk
apt-get install -f -y -qq --force-yes openjdk-6-jdk
echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> $HOME/.bashrc
END_OF_SCRIPT

View File

@ -44,13 +44,15 @@ function forget {
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID]
return 1;
} || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &
sleep 1
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start"
RETURN=$?
# this is generally followed by findPid, so we shouldn't exit
# immediately as the proc may not have registered in ps, yet
test $RETURN && sleep 1
return $RETURN;
}
return 0
}
export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin
case $1 in

View File

@ -45,13 +45,15 @@ function forget {
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID]
return 1;
} || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &
sleep 1
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start"
RETURN=$?
# this is generally followed by findPid, so we shouldn't exit
# immediately as the proc may not have registered in ps, yet
test $RETURN && sleep 1
return $RETURN;
}
return 0
}
export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin
case $1 in

View File

@ -11,11 +11,13 @@ function forget {
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID]
return 1;
} || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &
sleep 1
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start"
RETURN=$?
# this is generally followed by findPid, so we shouldn't exit
# immediately as the proc may not have registered in ps, yet
test $RETURN && sleep 1
return $RETURN;
}
return 0
}

View File

@ -47,13 +47,15 @@ function forget {
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID]
return 1;
} || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &
sleep 1
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start"
RETURN=$?
# this is generally followed by findPid, so we shouldn't exit
# immediately as the proc may not have registered in ps, yet
test $RETURN && sleep 1
return $RETURN;
}
return 0
}
export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin
case $1 in

View File

@ -45,13 +45,15 @@ function forget {
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID]
return 1;
} || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &
sleep 1
findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start"
RETURN=$?
# this is generally followed by findPid, so we shouldn't exit
# immediately as the proc may not have registered in ps, yet
test $RETURN && sleep 1
return $RETURN;
}
return 0
}
export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin
case $1 in