(command.CommandList
  children: [
    (command.ShFunction
      name: checkdocker
      body: 
        (BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.Simple
                              words: [{<which>} {<docker.io>}]
                              redirects: [
                                (redir
                                  op: <Id.Redir_DGreat '>>'>
                                  loc: (redir_loc.Fd fd:1)
                                  arg: {<'/dev/null'>}
                                )
                                (redir
                                  op: <Id.Redir_GreatAnd '2>&'>
                                  loc: (redir_loc.Fd fd:2)
                                  arg: {<1>}
                                )
                              ]
                              do_fork: T
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:DOCKER)
                          op: assign_op.Equal
                          rhs: {<docker.io>}
                          spids: [40]
                        )
                      ]
                    )
                  ]
                  spids: [22 37]
                )
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.Simple
                              words: [{<which>} {<docker>}]
                              redirects: [
                                (redir
                                  op: <Id.Redir_DGreat '>>'>
                                  loc: (redir_loc.Fd fd:1)
                                  arg: {<'/dev/null'>}
                                )
                                (redir
                                  op: <Id.Redir_GreatAnd '2>&'>
                                  loc: (redir_loc.Fd fd:2)
                                  arg: {<1>}
                                )
                              ]
                              do_fork: T
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:DOCKER)
                          op: assign_op.Equal
                          rhs: {<docker>}
                          spids: [62]
                        )
                      ]
                    )
                  ]
                  spids: [44 59]
                )
              ]
              else_action: [
                (C {<echo>} {(DQ <'Error: docker must be installed'>)})
                (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.Pipeline
                  children: [
                    (command.Simple
                      words: [{($ Id.VSub_DollarName '$DOCKER')} {<-h>}]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '2>'>
                          loc: (redir_loc.Fd fd:2)
                          arg: {<'/dev/null'>}
                        )
                      ]
                      do_fork: T
                    )
                    (C {<grep>} {<-q>} {<Jansens>})
                  ]
                  negated: F
                )
                (BraceGroup
                  children: [
                    (command.Sentence
                      child: 
                        (C {<echo>} 
                          {
                            (DQ <'Error: '> ($ Id.VSub_DollarName '$DOCKER') 
                              <' is the Docking System Tray - install docker.io instead'>
                            )
                          }
                        )
                      terminator: <Id.Op_Semi _>
                    )
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (command.Pipeline
                  children: [
                    (C {($ Id.VSub_DollarName '$DOCKER')} {<version>})
                    (C {<grep>} {<-q>} {(DQ <'^Client version:'>)})
                  ]
                  negated: F
                )
                (BraceGroup
                  children: [
                    (command.Sentence
                      child: 
                        (C {<echo>} 
                          {
                            (DQ <'Error: unexpected output from '> 
                              (word_part.EscapedLiteral
                                token: <Id.Lit_EscapedChar '\\"'>
                              ) ($ Id.VSub_DollarName '$DOCKER') <' version'> 
                              (word_part.EscapedLiteral
                                token: <Id.Lit_EscapedChar '\\"'>
                              )
                            )
                          }
                        )
                      terminator: <Id.Op_Semi _>
                    )
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (command.Pipeline
                  children: [
                    (C {($ Id.VSub_DollarName '$DOCKER')} {<version>})
                    (C {<grep>} {<-q>} {(DQ <'^Server version:'>)})
                  ]
                  negated: F
                )
                (BraceGroup
                  children: [
                    (command.Sentence
                      child: 
                        (C {<echo>} 
                          {
                            (DQ 
                              <
'Error: could not get docker server version - check it is running and your permissions'
                              >
                            )
                          }
                        )
                      terminator: <Id.Op_Semi _>
                    )
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: initcontainer
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_Number '$1'))} {<Id.Lit_RBracket ']'>})
                (BraceGroup
                  children: [
                    (command.Sentence
                      child: (C {<echo>} {(DQ <'Error: platform name must be specified'>)})
                      terminator: <Id.Op_Semi _>
                    )
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:DFILE)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ ($ Id.VSub_DollarName '$ROOTDIR') <'/contrib/docker/'> 
                        ($ Id.VSub_Number '$1')
                      )
                    }
                  spids: [234]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (C {<Id.Lit_LBracket '['>} {<-f>} {(DQ ($ Id.VSub_DollarName '$DFILE'))} 
                  {<Id.Lit_RBracket ']'>}
                )
                (BraceGroup
                  children: [
                    (command.Sentence
                      child: 
                        (C {<echo>} 
                          {
                            (DQ <'Error: docker file '> ($ Id.VSub_DollarName '$DFILE') <' not found'>)
                          }
                        )
                      terminator: <Id.Op_Semi _>
                    )
                    (command.Sentence
                      child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:CONTAINER)
                  op: assign_op.Equal
                  rhs: {(DQ <hg-dockerrpm-> ($ Id.VSub_Number '$1'))}
                  spids: [274]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:DBUILDUSER)
                  op: assign_op.Equal
                  rhs: {<build>}
                  spids: [281]
                )
              ]
            )
            (command.Pipeline
              children: [
                (command.Subshell
                  child: 
                    (command.CommandList
                      children: [
                        (C {<cat>} {($ Id.VSub_DollarName '$DFILE')})
                        (command.If
                          arms: [
                            (if_arm
                              cond: 
                                (condition.Shell
                                  commands: [
                                    (command.Sentence
                                      child: 
                                        (C {<Id.Lit_LBracket '['>} 
                                          {
                                            (command_sub
                                              left_token: <Id.Left_DollarParen '$('>
                                              child: (C {<uname>})
                                            )
                                          } {<Id.Lit_Equals '='>} {(DQ <Darwin>)} {<Id.Lit_RBracket ']'>}
                                        )
                                      terminator: <Id.Op_Semi _>
                                    )
                                  ]
                                )
                              action: [
                                (C {<echo>} {<RUN>} {<useradd>} {($ Id.VSub_DollarName '$DBUILDUSER')} 
                                  {<-u>} {<1000>}
                                )
                              ]
                              spids: [293 311]
                            )
                          ]
                          else_action: [
                            (C {<echo>} {<RUN>} {<groupadd>} {($ Id.VSub_DollarName '$DBUILDUSER')} {<-g>} 
                              {(command_sub left_token:<Id.Left_Backtick '`'> child:(C {<id>} {<-g>}))}
                            )
                            (C {<echo>} {<RUN>} {<useradd>} {($ Id.VSub_DollarName '$DBUILDUSER')} {<-u>} 
                              {(command_sub left_token:<Id.Left_Backtick '`'> child:(C {<id>} {<-u>}))} {<-g>} {($ Id.VSub_DollarName '$DBUILDUSER')}
                            )
                          ]
                        )
                      ]
                    )
                )
                (C {($ Id.VSub_DollarName '$DOCKER')} {<build>} {<--tag>} 
                  {($ Id.VSub_DollarName '$CONTAINER')} {<->}
                )
              ]
              negated: F
            )
          ]
        )
    )
  ]
)