(command.CommandList children: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.LogicalOr left: (bool_expr.Unary op_id:Id.BoolUnary_z child:{(DQ ($ Id.VSub_Number '$1'))}) right: (bool_expr.LogicalOr left: (bool_expr.Unary op_id: Id.BoolUnary_z child: {(DQ ($ Id.VSub_Number '$2'))} ) right: (bool_expr.Unary op_id: Id.BoolUnary_z child: {(DQ ($ Id.VSub_Number '$3'))} ) ) ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:66) ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:NAME) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:72) command_list: (command.CommandList children: [(C {(basename)} {(DQ ($ Id.VSub_Number '$0'))})] ) ) } spids: [71] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobEqual left: {(DQ ($ Id.VSub_DollarName '$NAME'))} right: {(nodescp)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:94) ) ] action: [ (C {(echo)} { (DQ ('Usage: ') ($ Id.VSub_Number '$0') (" 'environment' 'nodename|IP address' 'from' 'to'") ) } ) ] spids: [81 96] ) ] else_action: [ (C {(echo)} { (DQ ('Usage: ') ($ Id.VSub_Number '$0') (" 'environment' 'nodename|IP address' 'command' (sudo)") ) } ) ] ) (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:124) ) ] spids: [39 68] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: Id.BoolUnary_z child: { (command_sub left_token: (Token id:Id.Left_Backtick val:'`' span_id:135) command_list: (command.CommandList children:[(C {(which)} {(sshpass)})]) ) } ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:144) ) ] action: [ (C {(echo)} { (DQ ( "Error: sshpass required for this tool. You should be able to 'sudo apt-get install sshpass' to get it" ) ) } ) (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:156) ) ] spids: [129 146] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:ENVIRONMENT) op: assign_op.Equal rhs: {($ Id.VSub_Number '$1')} spids: [161] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:IP) op: assign_op.Equal rhs: {($ Id.VSub_Number '$2')} spids: [164] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:COMMAND) op: assign_op.Equal rhs: {($ Id.VSub_Number '$3')} spids: [167] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KNIFESTAT) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_Backtick val:'`' span_id:175) command_list: (command.CommandList children: [ (command.Pipeline children: [ (command.Simple words: [ {(knife)} {(data)} {(bag)} {(show)} {(configs)} {($ Id.VSub_DollarName '$ENVIRONMENT')} ] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'2>&' span_id:190) fd: 2 arg_word: {(1)} ) ] ) (C {(grep)} {(ERROR)}) ] negated: F ) ] ) ) } spids: [174] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.LogicalNot child: (bool_expr.Unary op_id: Id.BoolUnary_z child: {(DQ ($ Id.VSub_DollarName '$KNIFESTAT'))} ) ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:213) ) ] action: [ (C {(echo)} {(DQ ('knife error ') ($ Id.VSub_DollarName '$KNIFESTAT') (' when showing the config'))} ) (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:227) ) ] spids: [200 215] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:PASSWD) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_Backtick val:'`' span_id:236) command_list: (command.CommandList children: [ (command.Pipeline children: [ (C {(knife)} {(data)} {(bag)} {(show)} {(configs)} {($ Id.VSub_DollarName '$ENVIRONMENT')} ) (C {(grep)} {(DQ ('cobbler-root-password:'))}) (C {(awk)} {(SQ (Token id:Id.Lit_Chars val:' {print $2}' span_id:264))}) ] negated: F ) ] ) ) } spids: [235] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: Id.BoolUnary_z child: {(DQ ($ Id.VSub_DollarName '$PASSWD'))} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:279) ) ] action: [ (C {(echo)} {(DQ ("Failed to retrieve 'cobbler-root-password'"))}) (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:291) ) ] spids: [268 281] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:320) command_list: (command.CommandList children: [(C {(basename)} {(DQ ($ Id.VSub_Number '$0'))})] ) ) } right: {(nssh)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:333) ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:SSH1COMMON) op: assign_op.Equal rhs: {(DQ )} spids: [338] ) ] ) ] spids: [316 335] ) ] else_action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:SSHCOMMON) op: assign_op.Equal rhs: { (DQ ( '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o VerifyHostKeyDNS=no' ) ) } spids: [345] ) ] ) ] ) (command.ShFunction name: apply_command body: (command.BraceGroup children: [ (C {(DQ ($ Id.VSub_At '$@'))}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:RES) op: assign_op.Equal rhs: {($ Id.VSub_QMark '$?')} spids: [365] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {(DQ ($ Id.VSub_DollarName '$RES'))} right: {(0)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:382) ) ] action: [ (C {(echo)} {(DQ ("Executing '") ($ Id.VSub_At '$@') ("' failed"))}) (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:396) arg_word: {($ Id.VSub_DollarName '$RES')} ) ] spids: [369 384] ) ] ) ] ) ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:410) command_list: (command.CommandList children: [(C {(basename)} {(DQ ($ Id.VSub_Number '$0'))})] ) ) } right: {(nodescp)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:423) ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:SCPCMD) op: assign_op.Equal rhs: {(DQ ('scp ') ($ Id.VSub_DollarName '$SSHCOMMON'))} spids: [428] ) ] ) (C {(apply_command)} {(sshpass)} {(-p)} {($ Id.VSub_DollarName '$PASSWD')} {($ Id.VSub_DollarName '$SCPCMD')} {(-p)} {(DQ ($ Id.VSub_Number '$3'))} {(DQ ('ubuntu@') ($ Id.VSub_Number '$2') (':') ($ Id.VSub_Number '$4'))} ) ] spids: [406 425] ) ] else_action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:SSHCMD) op: assign_op.Equal rhs: {(DQ ('ssh ') ($ Id.VSub_DollarName '$SSHCOMMON'))} spids: [470] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {(DQ ($ Id.VSub_Number '$4'))} right: {(sudo)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:491) ) ] action: [ (C {(apply_command)} {(sshpass)} {(-p)} {($ Id.VSub_DollarName '$PASSWD')} {($ Id.VSub_DollarName '$SSHCMD')} {(-t)} {(ubuntu) (Id.Lit_Other '@') ($ Id.VSub_DollarName '$IP')} { (DQ ('echo ') ($ Id.VSub_DollarName '$PASSWD') (' | sudo -S ') ($ Id.VSub_DollarName '$COMMAND') ) } ) ] spids: [478 493] ) ] else_action: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {(DQ ($ Id.VSub_DollarName '$COMMAND'))} right: {(-)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:545) ) ] action: [ (C {(echo)} { (DQ ('You might need this : cobbler_root = ') ($ Id.VSub_DollarName '$PASSWD')) } ) (C {(apply_command)} {(sshpass)} {(-p)} {($ Id.VSub_DollarName '$PASSWD')} {($ Id.VSub_DollarName '$SSHCMD')} {(-t)} {(ubuntu) (Id.Lit_Other '@') ($ Id.VSub_DollarName '$IP')} ) ] spids: [532 547] ) ] else_action: [ (C {(apply_command)} {(sshpass)} {(-p)} {($ Id.VSub_DollarName '$PASSWD')} {($ Id.VSub_DollarName '$SSHCMD')} {(-t)} {(ubuntu) (Id.Lit_Other '@') ($ Id.VSub_DollarName '$IP')} {(DQ ($ Id.VSub_DollarName '$COMMAND'))} ) ] ) ] ) ] ) ] )