Skip to content

Commit

Permalink
Fix sudo, and exit immediately if any failure
Browse files Browse the repository at this point in the history
Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com>
  • Loading branch information
qiluo-msft committed Nov 1, 2018
1 parent 2ed1ebe commit f6c7a64
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ function postStartAction()
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]]; do
sleep 1;
done
if [[ "$REBOOT_TYPE" == "warm" && -d /host/warmboot ]]; then
WARM_DIR=/host/warmboot
WARM_DIR=/host/warmboot
SUDO=sudo -n
if [[ "$REBOOT_TYPE" == "warm" && -d $WARM_DIR ]]; then
function redisLoadAndDelete()
{
FILENAME="$1"
test -e $FILENAME && redis-load -s /var/run/redis/redis.sock -e EMPTY $FILENAME && rm $FILENAME
DB="$1"
FILENAME="$2"
test -e $FILENAME || { echo "No file $FILENAME" >&2; exit 10; }
$SUDO redis-load -s /var/run/redis/redis.sock -d $DB -e EMPTY $FILENAME || { echo "Failed to redis-load $FILENAME" >&2; exit 11; }
$SUDO rm $FILENAME || exit 12
}
# Load applDB from /host/warm-reboot/appl_db.json
redisLoadAndDelete $WARM_DIR/appl_db.json
Expand Down

0 comments on commit f6c7a64

Please sign in to comment.