(List (Com {[LIT_CHARS set]} {[LIT_CHARS -o]} {[LIT_CHARS errexit]} ) (Com {[LIT_CHARS set]} {[LIT_CHARS -o]} {[LIT_CHARS nounset]} ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[LIT_CHARS -z]} {[DQ [VarSub TARGET_STORAGE test_op=VS_TEST_COLON_HYPHEN {}]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "TARGET_STORAGE variable unset - skipping migration"]]} ) (Com {[LIT_CHARS exit]} {[LIT_CHARS 0]} ) ) ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[LIT_CHARS -z]} {[DQ [VarSub TARGET_VERSION test_op=VS_TEST_COLON_HYPHEN {}]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "TARGET_VERSION variable unset - skipping migration"]]} ) (Com {[LIT_CHARS exit]} {[LIT_CHARS 0]} ) ) ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[LIT_CHARS -z]} {[DQ [VarSub DATA_DIRECTORY test_op=VS_TEST_COLON_HYPHEN {}]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "DATA_DIRECTORY variable unset - skipping migration"]]} ) (Com {[LIT_CHARS exit]} {[LIT_CHARS 0]} ) ) ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [VarSub TARGET_STORAGE]]} {[LIT_NEQUAL "!="]} {[DQ [LIT_CHARS etcd2]]} {[LIT_CHARS -a]} {[DQ [VarSub TARGET_STORAGE]]} {[LIT_NEQUAL "!="]} {[DQ [LIT_CHARS etcd3]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Not supported version of storage: "][VarSub TARGET_STORAGE]]} ) (Com {[LIT_CHARS exit]} {[LIT_CHARS 1]} ) ) ) (= scope= flags=0 words=[] bindings=[('SUPPORTED_VERSIONS_STRING', {[DQ [LIT_CHARS "2.2.1 2.3.7 3.0.13"]]})]) (= scope= flags=0 words=[] bindings=[('SUPPORTED_VERSIONS', {[ComSub (Pipeline (Com {[LIT_CHARS echo]} {[DQ [VarSub SUPPORTED_VERSIONS_STRING]]}) (Com {[LIT_CHARS tr]} {[DQ [LIT_CHARS " "]]} {[DQ [\ LIT_ESCAPED_CHAR "\\n"]]}) )]})]) (= scope= flags=0 words=[] bindings=[('VERSION_FILE', {[DQ [LIT_CHARS version.txt]]})]) (= scope= flags=0 words=[] bindings=[('CURRENT_STORAGE', {[DQ [LIT_CHARS etcd2]]})]) (= scope= flags=0 words=[] bindings=[('CURRENT_VERSION', {[DQ [LIT_CHARS 2.2.1]]})]) (If (Com {[LIT_DBRACKET_LIKE "["]} {[LIT_CHARS -e]} {[DQ [VarSub DATA_DIRECTORY][LIT_CHARS /][VarSub VERSION_FILE]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (= scope= flags=0 words=[] bindings=[('VERSION_CONTENTS', {[DQ [ComSub (Com {[LIT_CHARS cat]} {[VarSub DATA_DIRECTORY] [LIT_CHARS /] [VarSub VERSION_FILE]})]]})]) (= scope= flags=0 words=[] bindings=[('CURRENT_VERSION', {[DQ [ComSub (Pipeline (Com {[LIT_CHARS echo]} {[VarSub VERSION_CONTENTS]}) (Com {[LIT_CHARS cut]} {[LIT_CHARS -d]} {[SQ ]} {[LIT_CHARS -f]} {[LIT_CHARS 1]}) )]]})]) (= scope= flags=0 words=[] bindings=[('CURRENT_STORAGE', {[DQ [ComSub (Pipeline (Com {[LIT_CHARS echo]} {[VarSub VERSION_CONTENTS]}) (Com {[LIT_CHARS cut]} {[LIT_CHARS -d]} {[SQ ]} {[LIT_CHARS -f]} {[LIT_CHARS 2]}) )]]})]) ) ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[LIT_OTHER "!"]} {[LIT_CHARS -d]} {[DQ [VarSub DATA_DIRECTORY]]} {[LIT_DBRACKET_LIKE "]"]} ) (Com {[LIT_CHARS mkdir]} {[LIT_CHARS -p]} {[DQ [VarSub DATA_DIRECTORY]]} ) ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[LIT_CHARS -z]} {[DQ [ComSub (Com {[LIT_CHARS ls]} {[LIT_CHARS -A]} {[VarSub DATA_DIRECTORY]})]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (Com {[LIT_CHARS echo]} {[DQ [VarSub DATA_DIRECTORY][LIT_CHARS " is empty - skipping migration"]]} ) (Com {[LIT_CHARS echo]} {[DQ [VarSub TARGET_VERSION][LIT_CHARS /][VarSub TARGET_STORAGE]]} < (FilenameRedirectNode filename={[DQ [VarSub DATA_DIRECTORY][LIT_CHARS /][VarSub VERSION_FILE]]} "> 1), > ) (Com {[LIT_CHARS exit]} {[LIT_CHARS 0]} ) ) ) (FunctionDef start_etcd [] (List (= scope= flags=0 words=[] bindings=[('ETCD_PORT', {[LIT_CHARS 18629]})]) (= scope= flags=0 words=[] bindings=[('ETCD_PEER_PORT', {[LIT_CHARS 18630]})]) (= scope= flags=0 words=[] bindings=[('ETCD_CMD', {[DQ [VarSub ETCD test_op=VS_TEST_COLON_HYPHEN {[LIT_SLASH /] [LIT_CHARS usr] [LIT_SLASH /] [LIT_CHARS local] [LIT_SLASH /] [LIT_CHARS bin] [LIT_SLASH /] [LIT_CHARS etcd-] [VarSub START_VERSION]}]]})]) (= scope= flags=0 words=[] bindings=[('ETCDCTL_CMD', {[DQ [VarSub ETCDCTL test_op=VS_TEST_COLON_HYPHEN {[LIT_SLASH /] [LIT_CHARS usr] [LIT_SLASH /] [LIT_CHARS local] [LIT_SLASH /] [LIT_CHARS bin] [LIT_SLASH /] [LIT_CHARS etcdctl-] [VarSub START_VERSION]}]]})]) (= scope= flags=0 words=[] bindings=[('API_VERSION', {[DQ [ComSub (Pipeline (Com {[LIT_CHARS echo]} {[VarSub START_STORAGE]}) (Com {[LIT_CHARS cut]} {[LIT_CHARS -c5-5]}) )]]})]) (If (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [VarSub API_VERSION]]} {[LIT_DBRACKET_LIKE "="]} {[DQ [LIT_CHARS 2]]} {[LIT_DBRACKET_LIKE "]"]} ) (= scope= flags=0 words=[] bindings=[('ETCDCTL_CMD', {[DQ [VarSub ETCDCTL_CMD][LIT_CHARS " --endpoint=http://127.0.0.1:"][VarSub ETCD_PORT][LIT_CHARS " set"]]})]) (ElseTrue) (= scope= flags=0 words=[] bindings=[('ETCDCTL_CMD', {[DQ [VarSub ETCDCTL_CMD][LIT_CHARS " --endpoints=http://127.0.0.1:"][VarSub ETCD_PORT][LIT_CHARS " put"]]})]) ) (Fork (Com {[VarSub ETCD_CMD]} {[LIT_CHARS --data-dir] [LIT_DBRACKET_LIKE "="] [VarSub DATA_DIRECTORY]} {[LIT_CHARS --listen-client-urls]} {[LIT_CHARS http] [LIT_OTHER ":"] [LIT_CHARS //127.0.0.1] [LIT_OTHER ":"] [VarSub ETCD_PORT]} {[LIT_CHARS --advertise-client-urls]} {[LIT_CHARS http] [LIT_OTHER ":"] [LIT_CHARS //127.0.0.1] [LIT_OTHER ":"] [VarSub ETCD_PORT]} {[LIT_CHARS --listen-peer-urls]} {[LIT_CHARS http] [LIT_OTHER ":"] [LIT_CHARS //127.0.0.1] [LIT_OTHER ":"] [VarSub ETCD_PEER_PORT]} {[LIT_CHARS --initial-advertise-peer-urls]} {[LIT_CHARS http] [LIT_OTHER ":"] [LIT_CHARS //127.0.0.1] [LIT_OTHER ":"] [VarSub ETCD_PEER_PORT]} < (FilenameRedirectNode filename={[LIT_CHARS /dev/null]} >"> 1), (DescriptorRedirectNode target={[LIT_CHARS 1]} &"> 2), > ) ) (= scope= flags=0 words=[] bindings=[('ETCD_PID', {[VarSub !]})]) (For i [{[ComSub (Com {[LIT_CHARS seq]} {[LIT_CHARS 240]})]}]) (List (Com {[VarSub ETCDCTL_CMD]} {[SQ ]} {[VarSub START_VERSION]} more_env=[('ETCDCTL_API', {[DQ [VarSub API_VERSION]]})] ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [VarSub ?]]} {[LIT_CHARS -eq]} {[DQ [LIT_CHARS 0]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Etcd on port "][VarSub ETCD_PORT][LIT_CHARS " is up."]]} ) (Com {[LIT_CHARS return]} {[LIT_CHARS 0]} ) ) ) (Com {[LIT_CHARS sleep]} {[LIT_CHARS 0.5]} ) ) ) (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Timeout while waiting for etcd on port "][VarSub ETCD_PORT]]} ) (Com {[LIT_CHARS return]} {[LIT_CHARS 1]} ) ) ) (FunctionDef stop_etcd [] (List (AndOr OP_OR_IF (Com {[LIT_CHARS kill]} {[DQ [VarSub ETCD_PID test_op=VS_TEST_HYPHEN {}]]} < (FilenameRedirectNode filename={[LIT_CHARS /dev/null]} "> 1), (DescriptorRedirectNode target={[LIT_CHARS 1]} &"> 2), > ) (Com {[LIT_OTHER ":"]} ) ) (AndOr OP_OR_IF (Com {[LIT_CHARS wait]} {[DQ [VarSub ETCD_PID test_op=VS_TEST_HYPHEN {}]]} < (FilenameRedirectNode filename={[LIT_CHARS /dev/null]} "> 1), (DescriptorRedirectNode target={[LIT_CHARS 1]} &"> 2), > ) (Com {[LIT_OTHER ":"]} ) ) ) ) (= scope= flags=0 words=[] bindings=[('ATTACHLEASE', {[DQ [VarSub ATTACHLEASE test_op=VS_TEST_COLON_HYPHEN {[LIT_SLASH /] [LIT_CHARS usr] [LIT_SLASH /] [LIT_CHARS local] [LIT_SLASH /] [LIT_CHARS bin] [LIT_SLASH /] [LIT_CHARS attachlease]}]]})]) (= scope= flags=0 words=[] bindings=[('ROLLBACK', {[DQ [VarSub ROLLBACK test_op=VS_TEST_COLON_HYPHEN {[LIT_SLASH /] [LIT_CHARS usr] [LIT_SLASH /] [LIT_CHARS local] [LIT_SLASH /] [LIT_CHARS bin] [LIT_SLASH /] [LIT_CHARS rollback]}]]})]) (= scope= flags=0 words=[] bindings=[('SKIP_STEP', {[LIT_CHARS true]})]) (For step [{[VarSub SUPPORTED_VERSIONS]}]) (List (If (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [VarSub step]]} {[LIT_DBRACKET_LIKE "="]} {[DQ [VarSub CURRENT_VERSION]]} {[LIT_DBRACKET_LIKE "]"]} ) (= scope= flags=0 words=[] bindings=[('SKIP_STEP', {[LIT_CHARS false]})]) (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [VarSub SKIP_STEP]]} {[LIT_NEQUAL "!="]} {[DQ [LIT_CHARS true]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (= scope= flags=0 words=[] bindings=[('START_VERSION', {[DQ [VarSub step]]})]) (= scope= flags=0 words=[] bindings=[('START_STORAGE', {[DQ [VarSub CURRENT_STORAGE]]})]) (If (Pipeline! (Com {[LIT_CHARS start_etcd]} ) ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Starting etcd "][VarSub step][LIT_CHARS " failed"]]} ) (Com {[LIT_CHARS exit]} {[LIT_CHARS 1]} ) ) ) (Com {[LIT_CHARS stop_etcd]} ) ) ) (= scope= flags=0 words=[] bindings=[('CURRENT_VERSION', {[VarSub step]})]) (Com {[LIT_CHARS echo]} {[DQ [VarSub CURRENT_VERSION][LIT_CHARS /][VarSub CURRENT_STORAGE]]} < (FilenameRedirectNode filename={[DQ [VarSub DATA_DIRECTORY][LIT_CHARS /][VarSub VERSION_FILE]]} "> 1), > ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [ComSub (Pipeline (Com {[LIT_CHARS echo]} {[VarSub CURRENT_VERSION]}) (Com {[LIT_CHARS cut]} {[LIT_CHARS -c1-2]}) )]]} {[LIT_DBRACKET_LIKE "="]} {[DQ [LIT_CHARS 3.]]} {[LIT_CHARS -a]} {[DQ [VarSub CURRENT_STORAGE]]} {[LIT_DBRACKET_LIKE "="]} {[DQ [LIT_CHARS etcd2]]} {[LIT_CHARS -a]} {[DQ [VarSub TARGET_STORAGE]]} {[LIT_DBRACKET_LIKE "="]} {[DQ [LIT_CHARS etcd3]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Performing etcd2 -> etcd3 migration"]]} ) (= scope= flags=0 words=[] bindings=[('START_VERSION', {[DQ [VarSub step]]})]) (= scope= flags=0 words=[] bindings=[('START_STORAGE', {[DQ [LIT_CHARS etcd3]]})]) (= scope= flags=0 words=[] bindings=[('ETCDCTL_CMD', {[DQ [VarSub ETCDCTL test_op=VS_TEST_COLON_HYPHEN {[LIT_SLASH /] [LIT_CHARS usr] [LIT_SLASH /] [LIT_CHARS local] [LIT_SLASH /] [LIT_CHARS bin] [LIT_SLASH /] [LIT_CHARS etcdctl-] [VarSub START_VERSION]}]]})]) (Com {[VarSub ETCDCTL_CMD]} {[LIT_CHARS migrate]} {[LIT_CHARS --data-dir] [LIT_DBRACKET_LIKE "="] [VarSub DATA_DIRECTORY]} more_env=[('ETCDCTL_API', {[LIT_CHARS 3]})] ) (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Attaching leases to TTL entries"]]} ) (If (Pipeline! (Com {[LIT_CHARS start_etcd]} ) ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Starting etcd "][VarSub step][LIT_CHARS " in v3 mode failed"]]} ) (Com {[LIT_CHARS exit]} {[LIT_CHARS 1]} ) ) ) (Com {[VarSub ATTACHLEASE]} {[LIT_CHARS --etcd-address]} {[LIT_CHARS http] [LIT_OTHER ":"] [LIT_CHARS //127.0.0.1] [LIT_OTHER ":"] [VarSub ETCD_PORT]} {[LIT_CHARS --ttl-keys-prefix]} {[DQ [VarSub TTL_KEYS_DIRECTORY test_op=VS_TEST_COLON_HYPHEN {[LIT_SLASH /] [LIT_CHARS registry] [LIT_SLASH /] [LIT_CHARS events]}]]} {[LIT_CHARS --lease-duration]} {[LIT_CHARS 1h]} ) (Com {[LIT_CHARS stop_etcd]} ) (= scope= flags=0 words=[] bindings=[('CURRENT_STORAGE', {[DQ [LIT_CHARS etcd3]]})]) (Com {[LIT_CHARS echo]} {[DQ [VarSub CURRENT_VERSION][LIT_CHARS /][VarSub CURRENT_STORAGE]]} < (FilenameRedirectNode filename={[DQ [VarSub DATA_DIRECTORY][LIT_CHARS /][VarSub VERSION_FILE]]} "> 1), > ) ) ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [VarSub CURRENT_VERSION]]} {[LIT_DBRACKET_LIKE "="]} {[DQ [VarSub TARGET_VERSION]]} {[LIT_CHARS -a]} {[DQ [VarSub CURRENT_STORAGE]]} {[LIT_DBRACKET_LIKE "="]} {[DQ [VarSub TARGET_STORAGE]]} {[LIT_DBRACKET_LIKE "]"]} ) (Com {[LIT_CHARS break]} ) ) ) ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [VarSub CURRENT_STORAGE]]} {[LIT_DBRACKET_LIKE "="]} {[DQ [LIT_CHARS etcd3]]} {[LIT_CHARS -a]} {[DQ [VarSub TARGET_STORAGE]]} {[LIT_DBRACKET_LIKE "="]} {[DQ [LIT_CHARS etcd2]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (If (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [ComSub (Pipeline (Com {[LIT_CHARS echo]} {[VarSub CURRENT_VERSION]}) (Com {[LIT_CHARS cut]} {[LIT_CHARS -c1-4]}) )]]} {[LIT_NEQUAL "!="]} {[DQ [LIT_CHARS 3.0.]]} {[LIT_CHARS -o]} {[DQ [VarSub TARGET_VERSION]]} {[LIT_NEQUAL "!="]} {[DQ [LIT_CHARS 2.3.7]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "etcd3 -> etcd2 downgrade is supported only between 3.0.x and 2.3.7"]]} ) (Com {[LIT_CHARS return]} {[LIT_CHARS 0]} ) ) ) (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Performing etcd3 -> etcd2 rollback"]]} ) (Com {[VarSub ROLLBACK]} {[LIT_CHARS --data-dir]} {[DQ [VarSub DATA_DIRECTORY]]} ) (If (Com {[LIT_DBRACKET_LIKE "["]} {[DQ [VarSub ?]]} {[LIT_CHARS -ne]} {[DQ [LIT_CHARS 0]]} {[LIT_DBRACKET_LIKE "]"]} ) (List (Com {[LIT_CHARS echo]} {[DQ [LIT_CHARS "Rollback to etcd2 failed"]]} ) (Com {[LIT_CHARS exit]} {[LIT_CHARS 1]} ) ) ) (= scope= flags=0 words=[] bindings=[('CURRENT_STORAGE', {[DQ [LIT_CHARS etcd2]]})]) (= scope= flags=0 words=[] bindings=[('CURRENT_VERSION', {[DQ [LIT_CHARS 2.3.7]]})]) (Com {[LIT_CHARS echo]} {[DQ [VarSub CURRENT_VERSION][LIT_CHARS /][VarSub CURRENT_STORAGE]]} < (FilenameRedirectNode filename={[DQ [VarSub DATA_DIRECTORY][LIT_CHARS /][VarSub VERSION_FILE]]} "> 1), > ) ) ) )