#!/bin/bash if [[ -z "$1" ]] { global HOST := $[hostname -f] } else { global HOST := $1 } knife client show $HOST > /dev/null global RES := $Status if [[ "$RES" -ne 0 ]] { echo "Can't find knife client $HOST" exit $RES } global admin_val := $[knife client show $(HOST) | grep ^admin: | sed "s/admin:[^a-z]*//] if [[ "$admin_val" != "true" ]] { echo -e "/\"admin\": false\ns/false/true\nw\nq\n" | env EDITOR=ed knife client edit $(HOST) } (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr:(BoolUnary op_id:BoolUnary_z child:{(DQ ($ VSub_Number "$1"))})) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HOST) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(hostname)} {(-f)})]) left_token: spids: [20 24] ) } spids: [19] ) ] spids: [19] ) ] spids: [-1 16] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HOST) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [29] ) ] spids: [29] ) ] spids: [26 34] ) (SimpleCommand words: [{(knife)} {(client)} {(show)} {($ VSub_Name "$HOST")}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[44])] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:RES) op:Equal rhs:{($ VSub_QMark "$?")} spids:[48])] spids: [48] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{(DQ ($ VSub_Name "$RES"))} right:{(0)}) ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Can't find knife client ") ($ VSub_Name "$HOST"))}) (C {(exit)} {($ VSub_Name "$RES")}) ] spids: [-1 66] ) ] spids: [-1 81] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:admin_val) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(knife)} {(client)} {(show)} {(${ VSub_Name HOST)}) (C {(grep)} {(Lit_Other "^") (admin) (Lit_Other ":")}) (C {(sed)} {(DQ ("s/admin:[^a-z]*//"))}) ] negated: False ) ] ) left_token: spids: [85 111] ) } spids: [84] ) ] spids: [84] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {(DQ ($ VSub_Name "$admin_val"))} right: {(DQ (true))} ) ) terminator: ) ] action: [ (Pipeline children: [ (C {(echo)} {(-e)} { (DQ (/) (EscapedLiteralPart token:) (admin) (EscapedLiteralPart token:) (": false") (EscapedLiteralPart token:) (s/false/true) (EscapedLiteralPart token:) (w) (EscapedLiteralPart token:) (q) (EscapedLiteralPart token:) ) } ) (SimpleCommand words: [{(knife)} {(client)} {(edit)} {(${ VSub_Name HOST)}] more_env: [(env_pair name:EDITOR val:{(ed)} spids:[154])] ) ] negated: False ) ] spids: [-1 130] ) ] spids: [-1 167] ) ] )