(command.CommandList
  children: [
    (command.Assignment
      pairs: [(assign_pair lhs:(lhs_expr.LhsName name:PIDDIR) op:Equal rhs:{(/var/run/samba)})]
    )
    (command.Assignment
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:SAMBAPID)
          op: Equal
          rhs: {($ VSub_DollarName '$PIDDIR') (/samba.pid)}
        )
      ]
    )
    (C {(unset)} {(TMPDIR)})
    (command.AndOr
      ops: [Op_DPipe]
      children: [
        (C {(test)} {(-x)} {(/usr/sbin/samba)} {(-a)} {(-r)} {(/etc/samba/smb.conf)})
        (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(0)})
      ]
    )
    (C {(.)} {(/lib/lsb/init-functions)})
    (command.Case
      to_match: {(DQ ($ VSub_Number '$1'))}
      arms: [
        (case_arm
          pat_list: [{(start)}]
          action: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:SERVER_ROLE)
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSub
                        left_token: <Left_Backtick '`'>
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.Pipeline
                                children: [
                                  (command.Simple
                                    words: [
                                      {(samba-tool)}
                                      {(testparm)}
                                      {(--parameter-name) (Lit_Other '=') (DQ ('server role'))}
                                    ]
                                    redirects: [
                                      (redir.Redir
                                        op: <Redir_Great '2>'>
                                        fd: 2
                                        arg_word: {(/dev/null)}
                                      )
                                    ]
                                  )
                                  (C {(tail)} {(-1)})
                                ]
                                negated: F
                              )
                            ]
                          )
                      )
                    }
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Lit_LBracket '[')} {(DQ ($ VSub_DollarName '$SERVER_ROLE'))} 
                          {(KW_Bang '!') (Lit_Other '=')} {(DQ ('active directory domain controller'))} {(Lit_RBracket ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [(command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(0)})]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(command.Sentence child:(C {(init_is_upstart)}) terminator:<Op_Semi ';'>)]
                  action: [(command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})]
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:KEYFILE)
                  op: Equal
                  rhs: {(/var/lib/samba/private/tls/key.pem)}
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (C {(Lit_LBracket '[')} {(-e)} {($ VSub_DollarName '$KEYFILE')} {(Lit_RBracket ']')})
                  ]
                  action: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:KEYPERMS)
                          op: Equal
                          rhs: 
                            {
                              (word_part.CommandSub
                                left_token: <Left_Backtick '`'>
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (C {(stat)} {(-c)} {(Lit_Other '%') (a)} 
                                        {($ VSub_DollarName '$KEYFILE')}
                                      )
                                    ]
                                  )
                              )
                            }
                        )
                      ]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (C {(Lit_LBracket '[')} {(DQ ($ VSub_DollarName '$KEYPERMS'))} 
                              {(KW_Bang '!') (Lit_Other '=')} {(DQ (600))} {(Lit_RBracket ']')}
                            )
                          ]
                          action: [
                            (C {(echo)} 
                              {
                                (DQ ('wrong permission on ') ($ VSub_DollarName '$KEYFILE') 
                                  (', must be 600')
                                )
                              }
                            )
                            (C {(echo)} {(DQ ('samba will not start (CVE-2013-4475)'))})
                            (C {(echo)} 
                              {
                                (DQ 
                                  (
'Removing all tls .pem files will cause an auto-regeneration with the correct permissions.'
                                  )
                                )
                              }
                            )
                            (command.ControlFlow
                              token: <ControlFlow_Exit exit>
                              arg_word: {(1)}
                            )
                          ]
                        )
                      ]
                    )
                  ]
                )
              ]
            )
            (C {(log_daemon_msg)} {(DQ ('Starting Samba AD DC daemon'))} {(DQ (samba))})
            (C {(install)} {(-o)} {(root)} {(-g)} {(root)} {(-m)} {(755)} {(-d)} 
              {($ VSub_DollarName '$PIDDIR')}
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.Pipeline
                          children: [
                            (C {(start-stop-daemon)} {(--start)} {(--quiet)} {(--oknodo)} {(--exec)} 
                              {(/usr/sbin/samba)} {(--)} {(-D)}
                            )
                          ]
                          negated: T
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(log_end_msg)} {(1)})
                    (command.ControlFlow
                      token: <ControlFlow_Exit exit>
                      arg_word: {(1)}
                    )
                  ]
                )
              ]
            )
            (C {(log_end_msg)} {(0)})
          ]
        )
        (case_arm
          pat_list: [{(stop)}]
          action: [
            (command.If
              arms: [
                (if_arm
                  cond: [(command.Sentence child:(C {(init_is_upstart)}) terminator:<Op_Semi ';'>)]
                  action: [(command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(0)})]
                )
              ]
            )
            (C {(log_daemon_msg)} {(DQ ('Stopping Samba AD DC daemon'))} {(DQ (samba))})
            (C {(start-stop-daemon)} {(--stop)} {(--quiet)} {(--pidfile)} 
              {($ VSub_DollarName '$SAMBAPID')}
            )
            (C {(sleep)} {(1)})
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(Lit_LBracket '[')} {(-f)} {($ VSub_DollarName '$SAMBAPID')} 
                          {(Lit_RBracket ']')}
                        )
                        (command.Pipeline
                          children: [
                            (command.Simple
                              words: [
                                {(ps)}
                                {(h)}
                                {
                                  (word_part.CommandSub
                                    left_token: <Left_Backtick '`'>
                                    command_list: 
                                      (command.CommandList
                                        children: [(C {(cat)} {($ VSub_DollarName '$SAMBAPID')})]
                                      )
                                  )
                                }
                              ]
                              redirects: [
                                (redir.Redir
                                  op: <Redir_Great '>'>
                                  fd: 16777215
                                  arg_word: {(/dev/null)}
                                )
                              ]
                            )
                          ]
                          negated: T
                        )
                      ]
                    )
                  ]
                  action: [(C {(rm)} {(-f)} {($ VSub_DollarName '$SAMBAPID')})]
                )
              ]
            )
            (C {(log_end_msg)} {(0)})
          ]
        )
        (case_arm
          pat_list: [{(restart)} {(force-reload)}]
          action: [
            (command.If
              arms: [
                (if_arm
                  cond: [(command.Sentence child:(C {(init_is_upstart)}) terminator:<Op_Semi ';'>)]
                  action: [(command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})]
                )
              ]
            )
            (C {($ VSub_Number '$0')} {(stop)})
            (C {(sleep)} {(1)})
            (C {($ VSub_Number '$0')} {(start)})
          ]
        )
        (case_arm
          pat_list: [{(status)}]
          action: [
            (C {(status_of_proc)} {(-p)} {($ VSub_DollarName '$SAMBAPID')} {(/usr/sbin/samba)} {(samba)})
            (command.ControlFlow
              token: <ControlFlow_Exit exit>
              arg_word: {($ VSub_QMark '$?')}
            )
          ]
        )
        (case_arm
          pat_list: [{(Lit_Star '*')}]
          action: [
            (C {(echo)} 
              {(DQ ('Usage: /etc/init.d/samba-ad-dc {start|stop|restart|force-reload|status}'))}
            )
            (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
          ]
        )
      ]
    )
    (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(0)})
  ]
)