(CommandList
  children: [
    (C {(set)} {(-o)} {(errexit)})
    (C {(set)} {(-o)} {(nounset)})
    (C {(set)} {(-o)} {(pipefail)})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:MOUNTER_IMAGE)
          op: Equal
          rhs: 
            {
              (BracedVarSub
                token: <VSub_Number 1>
                suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{})
                spids: [98 101]
              )
            }
          spids: [97]
        )
      ]
      spids: [97]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:MOUNTER_PATH)
          op: Equal
          rhs: {(/home/kubernetes/flexvolume_mounter)}
          spids: [103]
        )
      ]
      spids: [103]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:VOLUME_PLUGIN_DIR)
          op: Equal
          rhs: {(/etc/srv/kubernetes/kubelet-plugins/volume/exec)}
          spids: [106]
        )
      ]
      spids: [106]
    )
    (FuncDef
      name: usage
      body: 
        (BraceGroup
          children: [
            (C {(echo)} {(DQ ("usage: ") ($ VSub_Number "$0") (" imagename[:tag]"))})
            (C {(echo)} 
              {
                (DQ 
                  (
"    imagename  Name of a Container Registry image. By default the latest image is used."
                  )
                )
              }
            )
            (C {(echo)} {(DQ ("    :tag       Container Registry image tag."))})
            (C {(exit)} {(1)})
          ]
          spids: [114]
        )
      spids: [110 113]
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (C {(Lit_Other "[")} {(-z)} {(${ VSub_Name MOUNTER_IMAGE)} {(Lit_Other "]")})
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (C {(echo)} {(DQ ("ERROR: No Container Registry mounter image is specified."))})
            (C {(echo)})
            (C {(usage)})
          ]
          spids: [-1 160]
        )
      ]
      spids: [-1 175]
    )
    (FuncDef
      name: umount_silent
      body: 
        (BraceGroup
          children: [
            (Sentence
              child: (C {(umount)} {(-l)} {($ VSub_Number "$1")})
              terminator: <Op_Amp "&">
            )
            (AndOr
              children: [
                (SimpleCommand
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[198])]
                )
                (C {(/bin/true)})
              ]
              op_id: Op_DPipe
            )
          ]
          spids: [188]
        )
      spids: [184 187]
    )
    (FuncDef
      name: kubelet_wait
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(LhsName name:timeout) op:Equal rhs:{(60)} spids:[219])]
              spids: [219]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:kubelet_readonly_port)
                  op: Equal
                  rhs: {(10255)}
                  spids: [223]
                )
              ]
              spids: [223]
            )
            (Until
              cond: [
                (Sentence
                  child: 
                    (DBracket
                      expr: 
                        (BoolBinary
                          op_id: BoolBinary_eq
                          left: {($ VSub_Name "$timeout")}
                          right: {(0)}
                        )
                    )
                  terminator: <Op_Semi ";">
                )
              ]
              body: 
                (DoGroup
                  children: [
                    (C {(printf)} {(DQ (.))})
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (DBracket
                                  expr: 
                                    (BoolBinary
                                      op_id: BoolBinary_GlobDEqual
                                      left: 
                                        {
                                          (CommandSubPart
                                            command_list: 
                                              (CommandList
                                                children: [
                                                  (C {(curl)} {(-s)} 
                                                    {(http) (Lit_Other ":") (//localhost) 
                                                      (Lit_Other ":") (${ VSub_Name kubelet_readonly_port) (/healthz)
                                                    }
                                                  )
                                                ]
                                              )
                                            left_token: <Left_CommandSub "$(">
                                            spids: [254 269]
                                          )
                                        }
                                      right: {(DQ (ok))}
                                    )
                                )
                              terminator: <Op_Semi ";">
                            )
                          ]
                          action: [(ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})]
                          spids: [-1 280]
                        )
                      ]
                      spids: [-1 288]
                    )
                    (C {(sleep)} {(1)})
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:timeout)
                          op: Equal
                          rhs: 
                            {
                              (ArithSubPart
                                anode: 
                                  (ArithBinary
                                    op_id: Arith_Minus
                                    left: (ArithVarRef name:timeout)
                                    right: (ArithWord w:{(Lit_Digits 1)})
                                  )
                                spids: [297 304]
                              )
                            }
                          spids: [296]
                        )
                      ]
                      spids: [296]
                    )
                  ]
                  spids: [240 307]
                )
            )
            (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)})
          ]
          spids: [216]
        )
      spids: [212 215]
    )
    (FuncDef
      name: flex_clean
      body: 
        (BraceGroup
          children: [
            (C {(echo)})
            (C {(echo)} {(DQ ("An error has occurred. Cleaning up..."))})
            (C {(echo)})
            (C {(umount_silent)} {(${ VSub_Name VOLUME_PLUGIN_DIR)})
            (C {(rm)} {(-rf)} {(${ VSub_Name VOLUME_PLUGIN_DIR)})
            (C {(umount_silent)} {(${ VSub_Name MOUNTER_PATH) (/var/lib/kubelet)})
            (C {(umount_silent)} {(${ VSub_Name MOUNTER_PATH)})
            (C {(rm)} {(-rf)} {(${ VSub_Name MOUNTER_PATH)})
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} {(-n)} 
                          {
                            (BracedVarSub
                              token: <VSub_Name IMAGE_URL>
                              suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{})
                              spids: [391 394]
                            )
                          } {(Lit_Other "]")}
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (Sentence
                      child: (C {(docker)} {(rmi)} {(-f)} {(${ VSub_Name IMAGE_URL)})
                      terminator: <Op_Amp "&">
                    )
                    (AndOr
                      children: [
                        (SimpleCommand
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: -1
                              arg_word: {(/dev/null)}
                              spids: [413]
                            )
                          ]
                        )
                        (C {(/bin/true)})
                      ]
                      op_id: Op_DPipe
                    )
                  ]
                  spids: [-1 399]
                )
              ]
              spids: [-1 422]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} {(-n)} 
                          {
                            (BracedVarSub
                              token: <VSub_Name MOUNTER_DEFAULT_NAME>
                              suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{})
                              spids: [431 434]
                            )
                          } {(Lit_Other "]")}
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (Sentence
                      child: (C {(docker)} {(rm)} {(-f)} {(${ VSub_Name MOUNTER_DEFAULT_NAME)})
                      terminator: <Op_Amp "&">
                    )
                    (AndOr
                      children: [
                        (SimpleCommand
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: -1
                              arg_word: {(/dev/null)}
                              spids: [453]
                            )
                          ]
                        )
                        (C {(/bin/true)})
                      ]
                      op_id: Op_DPipe
                    )
                  ]
                  spids: [-1 439]
                )
              ]
              spids: [-1 462]
            )
          ]
          spids: [326]
        )
      spids: [322 325]
    )
    (C {(trap)} {(flex_clean)} {(ERR)})
    (FuncDef
      name: generate_chroot_wrapper
      body: 
        (BraceGroup
          children: [
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} {(KW_Bang "!")} {(-d)} 
                          {(${ VSub_Name MOUNTER_PATH) (/flexvolume)} {(Lit_Other "]")}
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
"Failed to set up FlexVolume driver: cannot find directory '/flexvolume' in the mount utility image."
                          )
                        )
                      }
                    )
                    (C {(exit)} {(1)})
                  ]
                  spids: [-1 503]
                )
              ]
              spids: [-1 518]
            )
            (ForEach
              iter_name: driver_dir
              iter_words: [{(${ VSub_Name MOUNTER_PATH) (/flexvolume/) (Lit_Other "*")}]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other "[")} {(-d)} {(DQ ($ VSub_Name "$driver_dir"))} 
                                  {(Lit_Other "]")}
                                )
                              terminator: <Op_Semi ";">
                            )
                          ]
                          action: [
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:filecount)
                                  op: Equal
                                  rhs: 
                                    {
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [
                                              (Pipeline
                                                children: [
                                                  (C {(ls)} {(-1)} {($ VSub_Name "$driver_dir")})
                                                  (C {(wc)} {(-l)})
                                                ]
                                                negated: False
                                              )
                                            ]
                                          )
                                        left_token: <Left_CommandSub "$(">
                                        spids: [557 569]
                                      )
                                    }
                                  spids: [556]
                                )
                              ]
                              spids: [556]
                            )
                            (If
                              arms: [
                                (if_arm
                                  cond: [
                                    (Sentence
                                      child: 
                                        (C {(Lit_Other "[")} {($ VSub_Name "$filecount")} {(-gt)} {(1)} 
                                          {(Lit_Other "]")}
                                        )
                                      terminator: <Op_Semi ";">
                                    )
                                  ]
                                  action: [
                                    (C {(echo)} 
                                      {
                                        (DQ 
                                          (
"ERROR: Expected 1 file in the FlexVolume directory but found "
                                          ) ($ VSub_Name "$filecount") (.)
                                        )
                                      }
                                    )
                                    (C {(exit)} {(1)})
                                  ]
                                  spids: [-1 585]
                                )
                              ]
                              spids: [-1 602]
                            )
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:driver_file)
                                  op: Equal
                                  rhs: 
                                    {
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [
                                              (Pipeline
                                                children: [
                                                  (C {(ls)} {($ VSub_Name "$driver_dir")})
                                                  (C {(head)} {(-n)} {(1)})
                                                ]
                                                negated: False
                                              )
                                            ]
                                          )
                                        left_token: <Left_CommandSub "$(">
                                        spids: [608 622]
                                      )
                                    }
                                  spids: [607]
                                )
                              ]
                              spids: [607]
                            )
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:driver_path)
                                  op: Equal
                                  rhs: 
                                    {(flexvolume/) 
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [(C {(basename)} {($ VSub_Name "$driver_dir")})]
                                          )
                                        left_token: <Left_CommandSub "$(">
                                        spids: [640 646]
                                      ) (/) (${ VSub_Name driver_file)
                                    }
                                  spids: [638]
                                )
                              ]
                              spids: [638]
                            )
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:wrapper_dir)
                                  op: Equal
                                  rhs: 
                                    {(${ VSub_Name VOLUME_PLUGIN_DIR) (/) 
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [(C {(basename)} {($ VSub_Name "$driver_dir")})]
                                          )
                                        left_token: <Left_CommandSub "$(">
                                        spids: [658 664]
                                      )
                                    }
                                  spids: [653]
                                )
                              ]
                              spids: [653]
                            )
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:wrapper_path)
                                  op: Equal
                                  rhs: {(${ VSub_Name wrapper_dir) (/) (${ VSub_Name driver_file)}
                                  spids: [667]
                                )
                              ]
                              spids: [667]
                            )
                            (C {(mkdir)} {(-p)} {($ VSub_Name "$wrapper_dir")})
                            (SimpleCommand
                              words: [{(cat)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Great
                                  fd: -1
                                  arg_word: {($ VSub_Name "$wrapper_path")}
                                  spids: [687]
                                )
                                (HereDoc
                                  op_id: Redir_DLess
                                  fd: -1
                                  body: 
                                    {
                                      (DQ ("#!/bin/bash\n") ("chroot ") (${ VSub_Name MOUNTER_PATH) 
                                        (" ") (${ VSub_Name driver_path) (" ") (Right_DoubleQuote "\"") 
                                        (EscapedLiteralPart
                                          token: <Lit_EscapedChar "\\$">
                                        ) ("@") (Right_DoubleQuote "\"") ("\n")
                                      )
                                    }
                                  do_expansion: True
                                  here_end: EOF
                                  was_filled: True
                                  spids: [690]
                                )
                              ]
                            )
                            (C {(chmod)} {(755)} {($ VSub_Name "$wrapper_path")})
                            (C {(echo)} 
                              {(DQ ("FlexVolume driver installed at ") (${ VSub_Name wrapper_path))}
                            )
                          ]
                          spids: [-1 552]
                        )
                      ]
                      spids: [-1 727]
                    )
                  ]
                  spids: [536 730]
                )
              spids: [528 534]
            )
          ]
          spids: [484]
        )
      spids: [480 483]
    )
    (C {(echo)})
    (C {(echo)} {(DQ ("Importing mount utility image from Container Registry..."))})
    (C {(echo)})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:METADATA)
          op: Equal
          rhs: {(http) (Lit_Other ":") (//metadata.google.internal/computeMetadata/v1)}
          spids: [746]
        )
      ]
      spids: [746]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:SVC_ACCT_ENDPOINT)
          op: Equal
          rhs: {($ VSub_Name "$METADATA") (/instance/service-accounts/default)}
          spids: [751]
        )
      ]
      spids: [751]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:ACCESS_TOKEN)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (CommandList
                    children: [
                      (Pipeline
                        children: [
                          (C {(curl)} {(-s)} {(-H)} {(SQ <"Metadata-Flavor: Google">)} 
                            {($ VSub_Name "$SVC_ACCT_ENDPOINT") (/token)}
                          )
                          (C {(cut)} {(-d) (SQ <"\"">)} {(-f)} {(4)})
                        ]
                        negated: False
                      )
                    ]
                  )
                left_token: <Left_CommandSub "$(">
                spids: [756 782]
              )
            }
          spids: [755]
        )
      ]
      spids: [755]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:PROJECT_ID)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (CommandList
                    children: [
                      (C {(curl)} {(-s)} {(-H)} {(SQ <"Metadata-Flavor: Google">)} 
                        {($ VSub_Name "$METADATA") (/project/project-id)}
                      )
                    ]
                  )
                left_token: <Left_CommandSub "$(">
                spids: [785 798]
              )
            }
          spids: [784]
        )
      ]
      spids: [784]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:IMAGE_URL)
          op: Equal
          rhs: {(gcr.io/) (${ VSub_Name PROJECT_ID) (/) (${ VSub_Name MOUNTER_IMAGE)}
          spids: [800]
        )
      ]
      spids: [800]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:MOUNTER_DEFAULT_NAME)
          op: Equal
          rhs: {(flexvolume_mounter)}
          spids: [810]
        )
      ]
      spids: [810]
    )
    (SimpleCommand
      words: [
        {(sudo)}
        {(-u)}
        {(${ VSub_Name SUDO_USER)}
        {(docker)}
        {(login)}
        {(-u)}
        {(_token)}
        {(-p)}
        {($ VSub_Name "$ACCESS_TOKEN")}
        {(https) (Lit_Other ":") (//gcr.io)}
      ]
      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[837])]
    )
    (C {(sudo)} {(-u)} {(${ VSub_Name SUDO_USER)} {(docker)} {(run)} 
      {(--name) (Lit_Other "=") (${ VSub_Name MOUNTER_DEFAULT_NAME)} {(${ VSub_Name IMAGE_URL)}
    )
    (SimpleCommand
      words: [{(docker)} {(export)} {(${ VSub_Name MOUNTER_DEFAULT_NAME)}]
      redirects: [
        (Redir
          op_id: Redir_Great
          fd: -1
          arg_word: {(/tmp/) (${ VSub_Name MOUNTER_DEFAULT_NAME) (.tar)}
          spids: [871]
        )
      ]
    )
    (SimpleCommand
      words: [{(docker)} {(rm)} {(${ VSub_Name MOUNTER_DEFAULT_NAME)}]
      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[887])]
    )
    (SimpleCommand
      words: [{(docker)} {(rmi)} {(${ VSub_Name IMAGE_URL)}]
      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[899])]
    )
    (C {(echo)})
    (C {(echo)} {(DQ ("Loading mount utilities onto this instance..."))})
    (C {(echo)})
    (C {(mkdir)} {(-p)} {(${ VSub_Name MOUNTER_PATH)})
    (C {(tar)} {(xf)} {(/tmp/) (${ VSub_Name MOUNTER_DEFAULT_NAME) (.tar)} {(-C)} 
      {(${ VSub_Name MOUNTER_PATH)}
    )
    (C {(mkdir)} {(-p)} {(${ VSub_Name MOUNTER_PATH) (/var/lib/kubelet)})
    (C {(mount)} {(--rbind)} {(/var/lib/kubelet/)} {(${ VSub_Name MOUNTER_PATH) (/var/lib/kubelet)})
    (C {(mount)} {(--make-rshared)} {(${ VSub_Name MOUNTER_PATH) (/var/lib/kubelet)})
    (C {(mount)} {(--bind)} {(${ VSub_Name MOUNTER_PATH)} {(${ VSub_Name MOUNTER_PATH)})
    (C {(mount)} {(-o)} {(remount) (Lit_Comma ",") (dev) (Lit_Comma ",") (exec)} 
      {(${ VSub_Name MOUNTER_PATH)}
    )
    (C {(echo)})
    (C {(echo)} {(DQ ("Setting up FlexVolume driver..."))})
    (C {(echo)})
    (C {(mkdir)} {(-p)} {(${ VSub_Name VOLUME_PLUGIN_DIR)})
    (C {(mount)} {(--bind)} {(${ VSub_Name VOLUME_PLUGIN_DIR)} {(${ VSub_Name VOLUME_PLUGIN_DIR)})
    (C {(mount)} {(-o)} {(remount) (Lit_Comma ",") (exec)} {(${ VSub_Name VOLUME_PLUGIN_DIR)})
    (C {(generate_chroot_wrapper)})
    (C {(echo)})
    (C {(echo)} {(DQ ("Restarting Kubelet..."))})
    (C {(echo)})
    (C {(systemctl)} {(restart)} {(kubelet.service)})
    (C {(kubelet_wait)})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (C {(Lit_Other "[")} {($ VSub_QMark "$?")} {(-eq)} {(0)} {(Lit_Other "]")})
              terminator: <Op_Semi ";">
            )
          ]
          action: [(C {(echo)}) (C {(echo)} {(DQ ("FlexVolume is ready."))})]
          spids: [-1 1081]
        )
      ]
      else_action: [(C {(echo)} {(DQ ("ERROR: Timed out after 1 minute waiting for kubelet restart."))})]
      spids: [1093 1102]
    )
  ]
)