(List (FunctionDef main [] (List (If (Pipeline! (Com {[LIT_CHARS healthy]} {[LIT_CHARS 60]} ) ) (List (Com {[LIT_CHARS stop_docker]} ) (Com {[LIT_CHARS start_docker]} ) (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "waiting 30s for startup"]]} ) (Com {[LIT_CHARS sleep]} {[LIT_CHARS 30]} ) (Com {[LIT_CHARS healthy]} {[LIT_CHARS 60]} ) ) ) (While (Com {[LIT_CHARS healthy]} ) (Com {[LIT_CHARS sleep]} {[LIT_CHARS 10]} ) ) (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Docker failed!"]]} ) (Com {[LIT_CHARS exit]} {[LIT_CHARS 2]} ) ) ) (FunctionDef healthy [] (List (= scope= flags=0 words=[] bindings=[('max_retry_sec', {[DQ [VarSub 1]]})]) (Com {[LIT_CHARS shift]} ) (= scope= flags=0 words=[] bindings=[('starttime', {[ComSub (Com {[LIT_CHARS date]} {[LIT_OTHER "+"] [LIT_OTHER "%"] [LIT_CHARS s]})]})]) (While (Pipeline! (Com {[LIT_CHARS timeout]} {[LIT_CHARS 60]} {[LIT_CHARS docker]} {[LIT_CHARS ps]} < (FilenameRedirectNode filename={[LIT_CHARS /dev/null]} "> 1), > ) ) (If (DBracket {B? LOGICAL_BINARY_OR {B1 UNARY_STRING_z {[DQ [VarSub max_retry_sec]]}} {B2 BINARY_INT_GT {[ArithSub {A2 AS_OP_MINUS {A Atom NODE_ARITH_WORD {[ComSub (Com {[LIT_CHARS date]} {[LIT_OTHER "+"] [LIT_OTHER "%"] [LIT_CHARS s]})]}} {A Atom NODE_ARITH_WORD {[VarSub starttime]}}}]} {[DQ [VarSub max_retry_sec]]}}}) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "docker ps did not succeed"]]} ) (Com {[LIT_CHARS return]} {[LIT_CHARS 2]} ) ) (ElseTrue) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "waiting 5s before retry"]]} ) (Com {[LIT_CHARS sleep]} {[LIT_CHARS 5]} ) ) ) ) (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "docker is healthy"]]} ) (Com {[LIT_CHARS return]} {[LIT_CHARS 0]} ) ) ) (FunctionDef stop_docker [] (List (Com {[LIT_CHARS /etc/init.d/docker]} {[LIT_CHARS stop]} ) (= scope= flags=0 words=[] bindings=[('starttime', {[ComSub (Com {[LIT_CHARS date]} {[LIT_OTHER "+"] [LIT_OTHER "%"] [LIT_CHARS s]})]})]) (While (Com {[LIT_CHARS pidof]} {[LIT_CHARS docker]} < (FilenameRedirectNode filename={[LIT_CHARS /dev/null]} "> 1), > ) (List (= scope= flags=0 words=[] bindings=[('currenttime', {[ComSub (Com {[LIT_CHARS date]} {[LIT_OTHER "+"] [LIT_OTHER "%"] [LIT_CHARS s]})]})]) (DParen {A2 AS_OP_EQUAL {A Atom NODE_ARITH_WORD {[VarSub elapsedtime]}} {A2 AS_OP_MINUS {A Atom NODE_ARITH_WORD {[VarSub currenttime]}} {A Atom NODE_ARITH_WORD {[VarSub starttime]}}}}) (If (Com {[LIT_CHARS test]} {[VarSub elapsedtime]} {[LIT_CHARS -gt]} {[LIT_CHARS 60]} ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "attempting to kill docker process with sigkill signal"]]} ) (AndOr OP_OR_IF (Com {[LIT_CHARS kill]} {[LIT_CHARS -9]} {[ComSub (Com {[LIT_CHARS pidof]} {[LIT_CHARS docker]})]} ) (Com {[LIT_CHARS sleep]} {[LIT_CHARS 10]} ) ) ) (ElseTrue) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "waiting clean shutdown"]]} ) (Com {[LIT_CHARS sleep]} {[LIT_CHARS 10]} ) ) ) ) ) ) ) (FunctionDef start_docker [] (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "docker is not running. starting docker"]]} ) (Com {[LIT_CHARS rm]} {[LIT_CHARS -rf]} {[LIT_CHARS /var/lib/docker/network]} ) (Com {[LIT_CHARS /etc/init.d/docker]} {[LIT_CHARS start]} ) ) ) (Com {[LIT_CHARS main]} ) )