AG

Angelo Gladding
lahacker.net

dlv5vbq7lzlthol5 4b942a3185b37d00

Home CodecanopyFiles

gaea.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
# [`gaea`][1]: manage the machines that power the Canopy
# Copyright (c) 2018- @[Angelo Gladding][2]
#
# This program is free software: it is distributed in the hope that it
# will be useful, but *without any warranty*; without even the implied
# warranty of merchantability or fitness for a particular purpose. You
# can redistribute it and/or modify it under the terms of the @@[GNU's
# Not Unix][3] %[Affero General Public License][4] as published by the
# @@[Free Software Foundation][5], either version 3 of the License, or
# any later version.
#
# *[GNU]: GNU's Not Unix
#
# [1]: https://lahacker.net/code/canopy/files/gaea.py
# [2]: https://lahacker.net
# [3]: https://gnu.org
# [4]: https://gnu.org/licenses/agpl
# [5]: https://fsf.org

"""
manage the machines that power the Canopy

    $ python detritus.py --help

"""

import argparse
import base64
import os
import pathlib
import textwrap
import time

__all__ = ["spawn_gaea", "spawn_canopy", "spawn_canopy_tree"]


debian_requirements = ("build-essential",  # build tools
                       "psmisc",  # killall
                       "xz-utils",  # .xz support
                       "git", "fcgiwrap",  # Git w/ HTTP serving
                       "supervisor",  # service manager
                       "redis-server",  # Redis key-value database
                       "haveged",  # produces entropy for faster key generation
                       "sqlite3",  # SQLite flat-file relational database
                       "libicu-dev", "python3-icu",  # SQLite unicode collation
                       "libsqlite3-dev",  # SQLite Python extension loading
                       "libssl-dev",  # uWSGI SSL support
                       "libffi-dev",  # (?)
                       "zlib1g-dev", "python3-dev",  # python
                       "python3-crypto",  # pycrypto
                       "python3-libtorrent",  # libtorrent
                       "libsm-dev", "python-opencv",  # opencv
                       "libevent-dev",  # Tor
                       "graphviz",  # graphing
                       "libgtk-3-0", "libdbus-glib-1-2",  # Firefox
                       "xvfb",  # browser automation
                       "libenchant-dev",  # pyenchant => sopel => bridging IRC
                       )
detritus = pathlib.Path("/home/gaea/detritus")
src_dir = detritus / "src"
bin_dir = detritus / "bin"
py_version = "3.7.1"
py_pkgs = ("pkg", "term", "src", "kv", "sql", "mkup", "mkdn",
           "mf", "mm", "uri", "web", "solarized", "canopy")
firefox_version = "63.0"
geckodriver_version = "0.23.0"

dhparam_path = detritus / "nginx/conf/dhparam.pem"
dhparam_size = "2048"
pubkey_size = "1024"

start = time.time()


def spawn_gaea():
    """
    setup gaea user and bring system up-to-date (~3 minutes)

    should be run as root

    """
    apt = sh.apt.bake(_env=dict(os.environ, DEBIAN_FRONTEND="noninteractive"))
    log("updating"); apt("update")  # noqa
    log("upgrading"); apt("dist-upgrade", "-yq")  # noqa
    for pkg in debian_requirements:
        try:
            sh.dpkg("-s", pkg)
        except sh.ErrorReturnCode:
            log("  installing", pkg); apt("install", "-yq", pkg)  # noqa

    try:
        sh.adduser("gaea", "--disabled-login", "--gecos", "Gaea")
    except sh.ErrorReturnCode_1:
        pass
    else:
        log("creating sudoer gaea")
        sh.mkdir("/home/gaea/.ssh")
        sh.cp(".ssh/authorized_keys", "/home/gaea/.ssh")
        sh.chown("-R", "gaea:gaea", "/home/gaea/.ssh")
        sh.tee(sh.echo("gaea  ALL=NOPASSWD: ALL"),
               "-a", "/etc/sudoers.d/01_gaea")


def spawn_canopy(origin):
    """
    spawn the canopy infrastructure (~13 minutes)

    should be run as gaea

    """
    detritus.mkdir(exist_ok=True)

    try:
        get_python_sh()
    except sh.CommandNotFound:
        build("python.org/ftp/python/{0}/Python-{0}.tar.xz".format(py_version),
              "--enable-loadable-sqlite-extensions",
              "--prefix={}".format(detritus))

    # Nginx
    build("nginx.org/download/nginx-1.15.6.tar.gz", "--with-http_ssl_module",
          "--with-http_v2_module", "--prefix={}".format(detritus / "nginx"))
    sh.mkdir("-p", detritus / "nginx/conf/conf.d")
    if not dhparam_path.exists():
        generate_dhparam()

    # Tor
    build("torproject.org/dist/tor-0.3.4.9.tar.gz",
          "--prefix={}".format(detritus))
    sh.mkdir("-p", detritus / "var/tor")

    # Firefox
    firefox_dir = "firefox-{}".format(firefox_version)
    if not (src_dir / firefox_dir).exists():
        log("installing firefox-{}".format(firefox_version))
        sh.wget("https://archive.mozilla.org/pub/firefox/releases/{}/"
                "linux-x86_64/en-US/{}.tar.bz2".format(firefox_version,
                                                       firefox_dir),
                _cwd=str(src_dir))
        sh.tar("xf", "{}.tar.bz2".format(firefox_dir), _cwd=str(src_dir))
        sh.mv("firefox", firefox_dir, _cwd=str(src_dir))
        sh.ln("-s", src_dir / firefox_dir / "firefox", bin_dir)

    # Geckodriver
    geckodriver_dir = "geckodriver-v{}-linux64".format(geckodriver_version)
    if not (src_dir / geckodriver_dir).exists():
        log("installing geckodriver-{}".format(geckodriver_version))
        sh.wget("https://github.com/mozilla/geckodriver/releases/download/v{}"
                "/{}.tar.gz".format(geckodriver_version, geckodriver_dir),
                _cwd=str(src_dir))
        sh.tar("xf", "{}.tar.gz".format(geckodriver_dir), _cwd=str(src_dir))
        sh.mkdir("-p", geckodriver_dir, _cwd=str(src_dir))
        sh.mv("geckodriver", geckodriver_dir, _cwd=str(src_dir))
        sh.ln("-s", src_dir / geckodriver_dir / "geckodriver", bin_dir)

    if not pathlib.Path("understory").exists():
        log("creating virtual environment")
        get_python_sh()("-m", "venv", "understory")
        sh.echo(textwrap.dedent("""\
            #!/usr/bin/env bash
            VENV=$1
            if [ -z $VENV ] ; then
              echo "usage: runinenv [virtualenv_path] CMDS"
              exit 1
            fi
            . ${VENV}/bin/activate
            shift 1
            # echo "Executing $@ in ${VENV}"  # XXX disturbs standard out
            exec "$@"
            deactivate"""), _out="runinenv")
        sh.chmod("+x", "runinenv")
        sh.sh("runinenv", "understory", "pip", "install", "sh==1.11")
        # XXX sh.ssh_copy_id("-f", "-i", "key",
        # XXX                "-o", "IdentityFile=~/.ssh/understory",
        # XXX                "root@understory.live")

        log("installing python packages")
        for py_pkg in py_pkgs:
            log(" ", py_pkg)
            sh.sh("runinenv", "understory", "pip", "install", "-e",
                  "git+{0}/code/{1}.git#egg={1}".format(origin, py_pkg))

    if not pathlib.Path("canopy").exists():
        log("setting up the canopy servers")
        sh.sh("runinenv", "understory", "canopy", "setupservers", "canopy",
              _env={"WEBCFG": "canopy/etc/web.conf"})


def spawn_canopy_tree(name, passphrase, domain=None):
    """
    spawn a canopy tree (~? minutes)

    should be run as gaea

    """
    # log("setting up canopy tree")
    print(str(sh.sh("runinenv", "understory", "canopy", "setuphost", name,
                    passphrase, pubkey_size,
                    *(("--domain", domain) if domain else ()),
                    _env={"COLORS_OFF": "1", "WEBCFG": "canopy/etc/web.conf",
                          "KVDB": "canopy/run/redis.sock"})).strip())
    sh.sudo("supervisorctl", "reload")


def get_python_sh():
    return sh.Command(str(bin_dir /
                          "python{}".format(py_version.rpartition(".")[0])))


def log(*args, **kwargs):
    print("{: 4d}".format(int(time.time() - start)), *args, **kwargs)


def build(archive_url, *config_args):
    archive_filename = archive_url.rpartition("/")[2]
    archive_stem = archive_filename
    for ext in (".gz", ".xz", ".bz2", ".tar"):
        if archive_stem.endswith(ext):
            archive_stem = archive_stem[:-len(ext)]
    src_dir.mkdir(exist_ok=True)
    archive_file = src_dir / archive_filename
    archive_dir = src_dir / archive_stem
    if not (archive_file.exists() and archive_dir.exists()):
        log("installing {}".format(archive_stem.lower()))
    if not archive_file.exists():
        log("  downloading")
        sh.wget("https://{}".format(archive_url), _cwd=str(src_dir))
    if not archive_dir.exists():
        log("  extracting")
        sh.tar("xf", archive_filename, _cwd=str(src_dir))
        log("  configuring")
        sh.bash("./configure", *config_args, _cwd=str(archive_dir))
        log("  making")
        sh.make(_cwd=str(archive_dir))
        log("  installing")
        sh.make("install", _cwd=str(archive_dir))


def generate_dhparam():
    """
    generate a unique Diffie-Hellman prime for Nginx

    This functionality has been abstracted here in order to allow an
    administrator to regenerate a cloned system's dhparam.

    """
    log("generating a large prime for dhparam..")
    sh.sudo("openssl", "dhparam", "-out", dhparam_path, dhparam_size)


def main():
    parser = argparse.ArgumentParser()
    contexts = parser.add_subparsers()

    gaea = contexts.add_parser("gaea", help="spawn gaea")
    gaea.set_defaults(command="gaea")

    canopy = contexts.add_parser("canopy", help="spawn canopy")
    canopy.set_defaults(command="canopy")
    canopy.add_argument("--origin", default="https://lahacker.net")

    tree = contexts.add_parser("tree", help="spawn canopy tree")
    tree.set_defaults(command="tree")
    tree.add_argument("name")
    tree.add_argument("passphrase")
    tree.add_argument("--domain")

    args = parser.parse_args()
    try:
        context = args.command
    except AttributeError:
        parser.exit(1)

    if context == "gaea":
        spawn_gaea()
    elif context == "canopy":
        spawn_canopy(args.origin)
    elif context == "tree":
        spawn_canopy_tree(args.name, args.passphrase, args.domain)

    # log("finished")
    parser.exit(0)


# `python-sh v1.12.14` Copyright (c) 2011- Andrew Moffat
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

sh_binary = """\
IiIiCmh0dHA6Ly9hbW9mZmF0LmdpdGh1Yi5pby9zaC8KIiIiCiM9PT09PT09PT09PT09PT09PT09PT
09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
CiMgQ29weXJpZ2h0IChDKSAyMDExLTIwMTcgYnkgQW5kcmV3IE1vZmZhdAojCiMgUGVybWlzc2lvbi
BpcyBoZXJlYnk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CiAgICAgICAgICAgIGZvciBmZCwgZXZlbnRzIGluIGNoYW5nZXM6CiAgICAgICAgICAgICAg
ICBmID0gc2VsZi5fZ2V0X2ZpbGVfb2JqZWN0KGZkKQogICAgICAgICAgICAgICAgaWYgZXZlbnRzIC
YgKHNlbGVjdC5QT0xMSU4gfCBzZWxlY3QuUE9MTFBSSSk6CiAgICAgICAgICAgICAgICAgICAgcmVz
dWx0cy5hcHBlbmQoKGYsIFBPTExFUl9FVkVOVF9SRUFEKSkKICAgICAgICAgICAgICAgIGVsaWYgZX
ZlbnRzICYgKHNlbGVjdC5QT0xMT1VUKToKICAgICAgICAgICAgICAgICAgICByZXN1bHRzLmFwcGVu
ZCgoZiwgUE9MTEVSX0VWRU5UX1dSSVRFKSkKICAgICAgICAgICAgICAgIGVsaWYgZXZlbnRzICYgKH
NlbGVjdC5QT0xMSFVQKToKICAgICAgICAgICAgICAgICAgICByZXN1bHRzLmFwcGVuZCgoZiwgUE9M
TEVSX0VWRU5UX0hVUCkpCiAgICAgICAgICAgICAgICBlbGlmIGV2ZW50cyAmIChzZWxlY3QuUE9MTE
VSUiB8IHNlbGVjdC5QT0xMTlZBTCk6CiAgICAgICAgICAgICAgICAgICAgcmVzdWx0cy5hcHBlbmQo
KGYsIFBPTExFUl9FVkVOVF9FUlJPUikpCiAgICAgICAgICAgIHJldHVybiByZXN1bHRzCmVsc2U6Ci
AgICBjbGFzcyBQb2xsZXIob2JqZWN0KToKICAgICAgICBkZWYgX19pbml0X18oc2VsZik6CiAgICAg
ICAgICAgIHNlbGYucmxpc3QgPSBbXQogICAgICAgICAgICBzZWxmLndsaXN0ID0gW10KICAgICAgIC
AgICAgc2VsZi54bGlzdCA9IFtdCgogICAgICAgIGRlZiBfX25vbnplcm9fXyhzZWxmKToKICAgICAg
ICAgICAgcmV0dXJuIGxlbihzZWxmLnJsaXN0KSArIGxlbihzZWxmLndsaXN0KSArIGxlbihzZWxmLn
hsaXN0KSAhPSAwCgogICAgICAgIGRlZiBf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ICAgICAgICMgYXR0ZW1wdCB0byBjb252ZXJ0
IHRoZSB0aGluZyB0byB1bmljb2RlIGZyb20gdGhlIHN5c3RlbSdzIGVuY29kaW5nCiAgICAgICAgdH
J5OgogICAgICAgICAgICBzID0gdW5pY29kZShzLCBERUZBVUxUX0VOQ09ESU5HKQogICAgICAgICMg
aWYgdGhlIHRoaW5nIGlzIGFscmVhZHkgdW5pY29kZSwgb3IgaXQncyBhIG51bWJlciwgaXQgY2FuJ3
QgYmUKICAgICAgICAjIGNvZXJjZWQgdG8gdW5pY29kZSB3aXRoIGFuIGVuY29kaW5nIGFyZ3VtZW50
LCBidXQgaWYgd2UgbGVhdmUgb3V0CiAgICAgICAgIyB0aGUgZW5jb2RpbmcgYXJndW1lbnQsIGl0IH
dpbGwgY29udmVydCBpdCB0byBhIHN0cmluZywgdGhlbiB0byB1bmljb2RlCiAgICAgICAgZXhjZXB0
IFR5cGVFcnJvcjoKICAgICAgICAgICAgcyA9IHVuaWNvZGUocykKCiAgICAgICAgIyBub3cgdGhhdC
B3ZSBoYXZlIGd1YXJhbnRlZWQgdW5pY29kZSwgZW5jb2RlIHRvIG91ciBzeXN0ZW0gZW5jb2Rpbmcs
CiAgICAgICAgIyBidXQgYXR0ZW1wdCB0byBmYWxsIGJhY2sgdG8gc29tZXRoaW5nCiAgICAgICAgdH
J5OgogICAgICAgICAgICBzID0gcy5lbmNvZGUoREVGQVVMVF9FTkNPRElORykKICAgICAgICBleGNl
cHQ6CiAgICAgICAgICAgIHMgPSBzLmVuY29kZShmYWxsYmFja19lbmNvZGluZywgInJlcGxhY2UiKQ
ogICAgcmV0dXJuIHMKCgpkZWYgX2luZGVudF90ZXh0KHRleHQsIG51bT00KToKICAgIGxpbmVzID0g
W10KICAgIGZvciBsaW5lIGluIHRleHQuc3BsaXQoIlxuIik6CiAgICAgICAgbGluZSA9ICgiICIgKi
BudW0pICsgbGluZQogICAgICAgIGxpbmVzLmFwcGVuZChsaW5lKQogICAgcmV0dXJuICJcb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GhhdCB3ZSBhbGxvdyB0byBwYXNzdGhyb3VnaCB0
byBPUHJvYyBmb3IKICAgIF9PUHJvY19hdHRyX3doaXRlbGlzdCA9IHNldCgoCiAgICAgICAgInNpZ2
5hbCIsCiAgICAgICAgInRlcm1pbmF0ZSIsCiAgICAgICAgImtpbGwiLAogICAgICAgICJraWxsX2dy
b3VwIiwKICAgICAgICAic2lnbmFsX2dyb3VwIiwKICAgICAgICAicGlkIiwKICAgICAgICAic2lkIi
wKICAgICAgICAicGdpZCIsCiAgICAgICAgImN0dHkiLAoKICAgICAgICAiaW5wdXRfdGhyZWFkX2V4
YyIsCiAgICAgICAgIm91dHB1dF90aHJlYWRfZXhjIiwKICAgICAgICAiYmdfdGhyZWFkX2V4YyIsCi
AgICApKQoKICAgIGRlZiBfX2luaXRfXyhzZWxmLCBjbWQsIGNhbGxfYXJncywgc3RkaW4sIHN0ZG91
dCwgc3RkZXJyKToKICAgICAgICAiIiIKICAgICAgICAgICAgY21kIGlzIGFuIGFycmF5LCB3aGVyZS
BlYWNoIGVsZW1lbnQgaXMgZW5jb2RlZCBhcyBieXRlcyAoUFkzKSBvciBzdHIKICAgICAgICAgICAg
KFBZMikKICAgICAgICAiIiIKCiAgICAgICAgIyBzZWxmLnJhbiBpcyB1c2VkIGZvciBhdWRpdGluZy
B3aGF0IGFjdHVhbGx5IHJhbi4gIGZvciBleGFtcGxlLCBpbgogICAgICAgICMgZXhjZXB0aW9ucywg
b3IgaWYgeW91IGp1c3Qgd2FudCB0byBrbm93IHdoYXQgd2FzIHJhbiBhZnRlciB0aGUKICAgICAgIC
AjIGNvbW1hbmQgcmFuCiAgICAgICAgIwogICAgICAgICMgaGVyZSB3ZSdyZSBtYWtpbmcgYSBjb25z
aXN0ZW50IHVuaWNvZGUgc3RyaW5nIG91dCBpZiBvdXIgY21kLgogICAgICAgICMgd2UncmUgYWxzby
Bhc3N1bWluZyAoY29ycmVjdGx5LCBpIHRoaW5rKSB0aGF0IHRoZSBjb21tYW5k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nRlcnJ1cHQKICAg
ICAgICAjIHNvIHRoZSBzbGlnaHQgdGltZW91dCBhbGxvd3MgZm9yIHRoYXQuCiAgICAgICAgd2hpbG
UgVHJ1ZToKICAgICAgICAgICAgdHJ5OgogICAgICAgICAgICAgICAgY2h1bmsgPSBzZWxmLnByb2Nl
c3MuX3BpcGVfcXVldWUuZ2V0KFRydWUsIDAuMDAxKQogICAgICAgICAgICBleGNlcHQgRW1wdHk6Ci
AgICAgICAgICAgICAgICBpZiBzZWxmLmNhbGxfYXJnc1siaXRlcl9ub2Jsb2NrIl06CiAgICAgICAg
ICAgICAgICAgICAgcmV0dXJuIGVycm5vLkVXT1VMREJMT0NLCiAgICAgICAgICAgIGVsc2U6CiAgIC
AgICAgICAgICAgICBpZiBjaHVuayBpcyBOb25lOgogICAgICAgICAgICAgICAgICAgIHNlbGYud2Fp
dCgpCiAgICAgICAgICAgICAgICAgICAgc2VsZi5fc3RvcHBlZF9pdGVyYXRpb24gPSBUcnVlCiAgIC
AgICAgICAgICAgICAgICAgcmFpc2UgU3RvcEl0ZXJhdGlvbigpCiAgICAgICAgICAgICAgICB0cnk6
CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNodW5rLmRlY29kZShzZWxmLmNhbGxfYXJnc1siZW
5jb2RpbmciXSwKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5jYWxsX2FyZ3NbImRlY29kZV9l
cnJvcnMiXSkKICAgICAgICAgICAgICAgIGV4Y2VwdCBVbmljb2RlRGVjb2RlRXJyb3I6CiAgICAgIC
AgICAgICAgICAgICAgcmV0dXJuIGNodW5rCgoKICAgICMgcHl0aG9uIDMKICAgIF9fbmV4dF9fID0g
bmV4dAoKICAgIGRlZiBfX2V4aXRfXyhzZWxmLCB0eXAsIHZhbHVlLCB0cmFjZWJhY2spOgogICAgIC
AgIGlmIHNlbGYuY2FsbF9hcmdzWyJ3aXRoIl0gYW5kIGdldF9wcmVwZW5kX3N0YWNrKCk6CiAgICAg
ICAgICAgIGdldF9wcmVwZW5kX3N0YWNrKCkucG9wKCkKCiAgICBkZWYgX19zdHJfXyhzZWxmKToKIC
AgICAgICAiIiIgaW4gcHl0aG9uMywgc2hvdWxkIHJldHVybiB1bmljb2RlLiAgaW4gcHl0aG9uMiwg
c2hvdWxkIHJldHVybiBhCiAgICAgICAgc3RyaW5nIG9mIGJ5dGVzICIiIgogICAgICAgIGlmIElTX1
BZMzoKICAgICAgICAgICAgcmV0dXJuIHNlbGYuX191bmljb2RlX18oKQogICAgICAgIGVsc2U6CiAg
ICAgICAgICAgIHJldHVybiB1bmljb2RlKHNlbGYpLmVuY29kZShzZWxmLmNhbGxfYXJnc1siZW5jb2
RpbmciXSkKCiAgICBkZWYgX191bmljb2RlX18oc2VsZik6CiAgICAgICAgIiIiIGEgbWFnaWMgbWV0
aG9kIGRlZmluZWQgZm9yIHB5dGhvbjIuICBjYWxsaW5nIHVuaWNvZGUoKSBvbiBhCiAgICAgICAgUn
VubmluZ0NvbW1hbmQgb2JqZWN0IHdpbGwgY2FsbCB0aGlzICIiIgogICAgICAgIGlmIHNlbGYucHJv
Y2VzcyBhbmQgc2VsZi5zdGRvdXQ6CiAgICAgICAgICAgIHJldHVybiBzZWxmLnN0ZG91dC5kZWNvZG
Uoc2VsZi5jYWxsX2FyZ3NbImVuY29kaW5nIl0sCiAgICAgICAgICAgICAgICBzZWxmLmNhbGxfYXJn
c1siZGVjb2RlX2Vycm9ycyJdKQogICAgICAgIGVsaWYgSVNfUFkzOgogICAgICAgICAgICByZXR1cm
4gIiIKICAgICAgICBlbHNlOgogICAgICAgICAgICByZXR1cm4gdW5pY29kZSgiIikKCiAgICBkZWYg
X19lcV9fKHNlbGYsIG90aGVyKToKICAgICAgICByZXR1cm4gdW5pY29kZShzZWxmKSA9PSB1bmljb2
RlKG90aGVyKQogICAgX19oYXNoX18gPSBOb25lICAjIEF2b2lkIERlcHJlY2F0aW9uV2FybmluZyBp
biBQeXRob24gPCAzCgogICAgZGVmIF9fY29udGFp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ICAgIGRlbCBr
d2FyZ3Nba2V5XQoKICAgICAgICBpbnZhbGlkX2t3YXJncyA9IHNwZWNpYWxfa3dhcmdfdmFsaWRhdG
9yKGNhbGxfYXJncywKICAgICAgICAgICAgICAgIENvbW1hbmQuX2t3YXJnX3ZhbGlkYXRvcnMpCgog
ICAgICAgIGlmIGludmFsaWRfa3dhcmdzOgogICAgICAgICAgICBleGNfbXNnID0gW10KICAgICAgIC
AgICAgZm9yIGFyZ3MsIGVycm9yX21zZyBpbiBpbnZhbGlkX2t3YXJnczoKICAgICAgICAgICAgICAg
IGV4Y19tc2cuYXBwZW5kKCIgICVyOiAlcyIgJSAoYXJncywgZXJyb3JfbXNnKSkKICAgICAgICAgIC
AgZXhjX21zZyA9ICJcbiIuam9pbihleGNfbXNnKQogICAgICAgICAgICByYWlzZSBUeXBlRXJyb3Io
IkludmFsaWQgc3BlY2lhbCBhcmd1bWVudHM6XG5cbiVzXG4iICUgZXhjX21zZykKCiAgICAgICAgcm
V0dXJuIGNhbGxfYXJncywga3dhcmdzCgoKICAgICMgVE9ETyBuZWVkcyBkb2N1bWVudGF0aW9uCiAg
ICBkZWYgYmFrZShzZWxmLCAqYXJncywgKiprd2FyZ3MpOgogICAgICAgIGZuID0gdHlwZShzZWxmKS
hzZWxmLl9wYXRoKQogICAgICAgIGZuLl9wYXJ0aWFsID0gVHJ1ZQoKICAgICAgICBjYWxsX2FyZ3Ms
IGt3YXJncyA9IHNlbGYuX2V4dHJhY3RfY2FsbF9hcmdzKGt3YXJncykKCiAgICAgICAgcHJ1bmVkX2
NhbGxfYXJncyA9IGNhbGxfYXJncwogICAgICAgIGZvciBrLCB2IGluIENvbW1hbmQuX2NhbGxfYXJn
cy5pdGVtcygpOgogICAgICAgICAgICB0cnk6CiAgICAgICAgICAgICAgICBpZiBwcnVuZWRfY2FsbF
9hcmdzW2tdID09IHY6CiAgICAgICAgICAgICAgICAgICAgZGVsIHBydW5lZF9jYWxsX2FyZ3Nba10K
ICAgICAgICAg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5cGFzcwogICAgICAgICMgbGF1bmNoaW5nIGEgUnVubmluZ0NvbW1hbmQgYW5kIE9Qcm
9jIGFuZCBqdXN0IGRvIGEgc3Bhd24KICAgICAgICBpZiBjYWxsX2FyZ3NbImZnIl06CiAgICAgICAg
ICAgIGlmIGNhbGxfYXJnc1siZW52Il0gaXMgTm9uZToKICAgICAgICAgICAgICAgIGxhdW5jaCA9IG
xhbWJkYTogb3Muc3Bhd252KG9zLlBfV0FJVCwgY21kWzBdLCBjbWQpCiAgICAgICAgICAgIGVsc2U6
CiAgICAgICAgICAgICAgICBsYXVuY2ggPSBsYW1iZGE6IG9zLnNwYXdudmUob3MuUF9XQUlULCBjbW
RbMF0sIGNtZCwgY2FsbF9hcmdzWyJlbnYiXSkKCiAgICAgICAgICAgIGV4aXRfY29kZSA9IGxhdW5j
aCgpCiAgICAgICAgICAgIGV4Y19jbGFzcyA9IGdldF9leGNfZXhpdF9jb2RlX3dvdWxkX3JhaXNlKG
V4aXRfY29kZSwKICAgICAgICAgICAgICAgICAgICBjYWxsX2FyZ3NbIm9rX2NvZGUiXSwgY2FsbF9h
cmdzWyJwaXBlZCJdKQogICAgICAgICAgICBpZiBleGNfY2xhc3M6CiAgICAgICAgICAgICAgICBpZi
BJU19QWTM6CiAgICAgICAgICAgICAgICAgICAgcmFuID0gIiAiLmpvaW4oW2FyZy5kZWNvZGUoREVG
QVVMVF9FTkNPRElORywgImlnbm9yZSIpIGZvciBhcmcgaW4gY21kXSkKICAgICAgICAgICAgICAgIG
Vsc2U6CiAgICAgICAgICAgICAgICAgICAgcmFuID0gIiAiLmpvaW4oY21kKQogICAgICAgICAgICAg
ICAgZXhjID0gZXhjX2NsYXNzKHJhbiwgYiIiLCBiIiIsIGNhbGxfYXJnc1sidHJ1bmNhdGVfZXhjIl
0pCiAgICAgICAgICAgICAgICByYWlzZSBleGMKICAgICAgICAgICAgcmV0dXJuIE5vbmUKCgogICAg
ICAgICMgc3Rkb3V0IHJlZGlyZWN0aW9uCi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9uOgogICAgICAgICAgICAgIC
AgICAgIG9zLnNldHNpZCgpCiAgICAgICAgICAgICAgICAjIGlmIHdlJ3JlIG5vdCBnb2luZyBpbiBh
IG5ldyBzZXNzaW9uLCB3ZSBzaG91bGQgZ28gaW4gYSBuZXcKICAgICAgICAgICAgICAgICMgcHJvY2
VzcyBncm91cC4gIHRoaXMgd2F5LCBvdXIgcHJvY2VzcywgYW5kIGFueSBjaGlsZHJlbiBpdAogICAg
ICAgICAgICAgICAgIyBzcGF3bnMsIGFyZSBhbG9uZSwgY29udGFpbmVkIGVudGlyZWx5IGluIG9uZS
Bncm91cC4gIGlmIHdlCiAgICAgICAgICAgICAgICAjIGRpZG4ndCBkbyB0aGlzLCBhbmQgZGlkbid0
IHVzZSBhIG5ldyBzZXNzaW9uLCB0aGVuIG91ciBleGVjJ2QKICAgICAgICAgICAgICAgICMgcHJvY2
VzcyAqY291bGQqIGV4aXN0IGluIHRoZSBzYW1lIGdyb3VwIGFzIG91ciBweXRob24gcHJvY2VzcywK
ICAgICAgICAgICAgICAgICMgZGVwZW5kaW5nIG9uIGhvdyB3ZSBsYXVuY2ggdGhlIHByb2Nlc3MgKG
Zyb20gYSBzaGVsbCwgb3Igc29tZQogICAgICAgICAgICAgICAgIyBvdGhlciB3YXkpCiAgICAgICAg
ICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgICAgIG9zLnNldHBncnAoKQoKICAgICAgICAgIC
AgICAgIHNpZCA9IG9zLmdldHNpZCgwKQogICAgICAgICAgICAgICAgcGdpZCA9IG9zLmdldHBnaWQo
MCkKICAgICAgICAgICAgICAgIHBheWxvYWQgPSAoIiVkLCVkIiAlIChzaWQsIHBnaWQpKS5lbmNvZG
UoREVGQVVMVF9FTkNPRElORykKICAgICAgICAgICAgICAgIG9zLndyaXRlKHNlc3Npb25fcGlwZV93
cml0ZSwgcGF5bG9hZCkKCiAgICAgICAgICAgICAgICBpZiBjYVsidHR5X291dCJdIGFuZCBub3Qgc3
Rkb3V0X2l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WVzLzIwMgogICAgICAgICAgICAj
CiAgICAgICAgICAgICMgaWYgeW91ciBwYXJlbnQgcHJvY2VzcyBleHBlcmllbmNlcyBhbiBleGl0IG
NvZGUgMjU1LCBpdCBpcyBtb3N0CiAgICAgICAgICAgICMgbGlrZWx5IHRoYXQgYW4gZXhjZXB0aW9u
IG9jY3VycmVkIGJldHdlZW4gdGhlIGZvcmsgb2YgdGhlIGNoaWxkCiAgICAgICAgICAgICMgYW5kIH
RoZSBleGVjLiAgdGhpcyBzaG91bGQgYmUgcmVwb3J0ZWQuCiAgICAgICAgICAgIGV4Y2VwdDoKICAg
ICAgICAgICAgICAgICMgc29tZSBoZWxwZnVsIGRlYnVnZ2luZwogICAgICAgICAgICAgICAgdHJ5Og
ogICAgICAgICAgICAgICAgICAgIHRiID0gdHJhY2ViYWNrLmZvcm1hdF9leGMoKS5lbmNvZGUoInV0
ZjgiLCAiaWdub3JlIikKICAgICAgICAgICAgICAgICAgICBvcy53cml0ZShleGNfcGlwZV93cml0ZS
wgdGIpCgogICAgICAgICAgICAgICAgZmluYWxseToKICAgICAgICAgICAgICAgICAgICBvcy5fZXhp
dCgyNTUpCgogICAgICAgICMgcGFyZW50CiAgICAgICAgZWxzZToKICAgICAgICAgICAgaWYgZ2NfZW
5hYmxlZDoKICAgICAgICAgICAgICAgIGdjLmVuYWJsZSgpCgogICAgICAgICAgICBvcy5jbG9zZShz
ZWxmLl9zdGRpbl93cml0ZV9mZCkKICAgICAgICAgICAgb3MuY2xvc2Uoc2VsZi5fc3Rkb3V0X3dyaX
RlX2ZkKQogICAgICAgICAgICBvcy5jbG9zZShzZWxmLl9zdGRlcnJfd3JpdGVfZmQpCgogICAgICAg
ICAgICAjIHRlbGwgb3VyIGNoaWxkIHByb2Nlc3MgdGhhdCB3ZSd2ZSBjbG9zZWQgb3VyIHdyaXRlX2
Zkcywgc28gaXQgaXMKICAgICAgICAgICAgIyBvayB0byBwcm9jZWVkIHRvd2FyZHMgZXhlYy4gIHNl
Z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mcgZGlyZWN0bHkgaW50byBhbm90aGVyIHByb2Nlc3MncyBmaWxlZGVzY3JpcHRvciwgd2
UKICAgICAgICAgICAgIyBieXBhc3MgcmVhZGluZyBmcm9tIHRoZSBzdGRvdXQgc3RyZWFtIGFsdG9n
ZXRoZXIsIGJlY2F1c2Ugd2UndmUKICAgICAgICAgICAgIyBhbHJlYWR5IGhvb2tlZCB1cCB0aGlzIH
Byb2Nlc3NlcydzIHN0ZG91dCBmZCB0byB0aGUgb3RoZXIKICAgICAgICAgICAgIyBwcm9jZXNzZXMn
cyBzdGRpbiBmZAogICAgICAgICAgICBzZWxmLl9zdGRvdXRfc3RyZWFtID0gTm9uZQogICAgICAgIC
AgICBpZiBub3QgcGlwZV9vdXQgYW5kIHNlbGYuX3N0ZG91dF9yZWFkX2ZkOgogICAgICAgICAgICAg
ICAgaWYgY2FsbGFibGUoc3Rkb3V0KToKICAgICAgICAgICAgICAgICAgICBzdGRvdXQgPSBjb25zdH
J1Y3Rfc3RyZWFtcmVhZGVyX2NhbGxiYWNrKHNlbGYsIHN0ZG91dCkKICAgICAgICAgICAgICAgIHNl
bGYuX3N0ZG91dF9zdHJlYW0gPSBcCiAgICAgICAgICAgICAgICAgICAgICAgIFN0cmVhbVJlYWRlci
gKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmxvZy5nZXRfY2hpbGQoInN0cmVh
bXJlYWRlciIsICJzdGRvdXQiKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl
9zdGRvdXRfcmVhZF9mZCwgc3Rkb3V0LCBzZWxmLl9zdGRvdXQsCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgY2FbIm91dF9idWZzaXplIl0sIGNhWyJlbmNvZGluZyJdLAogICAgICAgICAgIC
AgICAgICAgICAgICAgICAgICAgIGNhWyJkZWNvZGVfZXJyb3JzIl0sIHN0ZG91dF9waXBlLAogICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN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ICAgICAgICBpZiBjYWxsYWJsZShzdGRlcnIpOgogIC
AgICAgICAgICAgICAgICAgIHN0ZGVyciA9IGNvbnN0cnVjdF9zdHJlYW1yZWFkZXJfY2FsbGJhY2so
c2VsZiwgc3RkZXJyKQoKICAgICAgICAgICAgICAgIHNlbGYuX3N0ZGVycl9zdHJlYW0gPSBTdHJlYW
1SZWFkZXIoTG9nZ2VyKCJzdHJlYW1yZWFkZXIiKSwKICAgICAgICAgICAgICAgICAgICAgICAgc2Vs
Zi5fc3RkZXJyX3JlYWRfZmQsIHN0ZGVyciwgc2VsZi5fc3RkZXJyLAogICAgICAgICAgICAgICAgIC
AgICAgICBjYVsiZXJyX2J1ZnNpemUiXSwgY2FbImVuY29kaW5nIl0sIGNhWyJkZWNvZGVfZXJyb3Jz
Il0sCiAgICAgICAgICAgICAgICAgICAgICAgIHN0ZGVycl9waXBlLCBzYXZlX2RhdGE9c2F2ZV9zdG
RlcnIpCgogICAgICAgICAgICBlbGlmIHNlbGYuX3N0ZGVycl9yZWFkX2ZkOgogICAgICAgICAgICAg
ICAgb3MuY2xvc2Uoc2VsZi5fc3RkZXJyX3JlYWRfZmQpCgoKICAgICAgICAgICAgZGVmIHRpbWVvdX
RfZm4oKToKICAgICAgICAgICAgICAgIHNlbGYudGltZWRfb3V0ID0gVHJ1ZQogICAgICAgICAgICAg
ICAgc2VsZi5zaWduYWwoY2FbInRpbWVvdXRfc2lnbmFsIl0pCgoKICAgICAgICAgICAgc2VsZi5fdG
ltZW91dF9ldmVudCA9IE5vbmUKICAgICAgICAgICAgc2VsZi5fdGltZW91dF90aW1lciA9IE5vbmUK
ICAgICAgICAgICAgaWYgY2FbInRpbWVvdXQiXToKICAgICAgICAgICAgICAgIHNlbGYuX3RpbWVvdX
RfZXZlbnQgPSB0aHJlYWRpbmcuRXZlbnQoKQogICAgICAgICAgICAgICAgc2VsZi5fdGltZW91dF90
aW1lciA9IHRocmVhZGluZy5UaW1lcihjYVsidGltZW91dCJdLAogICAgICA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XVldW
UoMSkKICAgICAgICAgICAgdGhyZWFkX25hbWUgPSAiU1RET1VUL0VSUiB0aHJlYWQgZm9yIHBpZCAl
ZCIgJSBzZWxmLnBpZAogICAgICAgICAgICBzZWxmLl9vdXRwdXRfdGhyZWFkID0gX3N0YXJ0X2RhZW
1vbl90aHJlYWQob3V0cHV0X3RocmVhZCwKICAgICAgICAgICAgICAgICAgICB0aHJlYWRfbmFtZSwg
c2VsZi5fb3V0cHV0X3RocmVhZF9leGNfcXVldWUsIHNlbGYubG9nLAogICAgICAgICAgICAgICAgIC
AgIHNlbGYuX3N0ZG91dF9zdHJlYW0sIHNlbGYuX3N0ZGVycl9zdHJlYW0sCiAgICAgICAgICAgICAg
ICAgICAgc2VsZi5fdGltZW91dF9ldmVudCwgc2VsZi5pc19hbGl2ZSwgc2VsZi5fcXVpdF90aHJlYW
RzLAogICAgICAgICAgICAgICAgICAgIHNlbGYuX3N0b3Bfb3V0cHV0X2V2ZW50KQoKCiAgICBkZWYg
X19yZXByX18oc2VsZik6CiAgICAgICAgcmV0dXJuICI8UHJvY2VzcyAlZCAlcj4iICUgKHNlbGYucG
lkLCBzZWxmLmNtZFs6NTAwXSkKCgogICAgIyB0aGVzZSBuZXh0IDMgcHJvcGVydGllcyBhcmUgcHJp
bWFyeSBmb3IgdGVzdHMKICAgIEBwcm9wZXJ0eQogICAgZGVmIG91dHB1dF90aHJlYWRfZXhjKHNlbG
YpOgogICAgICAgIGV4YyA9IE5vbmUKICAgICAgICB0cnk6CiAgICAgICAgICAgIGV4YyA9IHNlbGYu
X291dHB1dF90aHJlYWRfZXhjX3F1ZXVlLmdldChGYWxzZSkKICAgICAgICBleGNlcHQgRW1wdHk6Ci
AgICAgICAgICAgIHBhc3MKICAgICAgICByZXR1cm4gZXhjCgogICAgQHByb3BlcnR5CiAgICBkZWYg
aW5wdXRfdGhyZWFkX2V4YyhzZWxmKToKICAgICAgICBleGMgPSBOb25lCiAgICAgICAgdHJ5OgogIC
AgICAgICAgICBle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zZyA9ICJnZW5lcmF0
b3IiCiAgICAgICAgZ2V0X2NodW5rID0gZ2V0X2l0ZXJfY2h1bmtfcmVhZGVyKGl0ZXIoaW5wdXRfb2
JqKSkKCiAgICBlbHNlOgogICAgICAgIHRyeToKICAgICAgICAgICAgaXQgPSBpdGVyKGlucHV0X29i
aikKICAgICAgICBleGNlcHQgVHlwZUVycm9yOgogICAgICAgICAgICByYWlzZSBFeGNlcHRpb24oIn
Vua25vd24gaW5wdXQgb2JqZWN0IikKICAgICAgICBlbHNlOgogICAgICAgICAgICBsb2dfbXNnID0g
ImdlbmVyYWwgaXRlcmFibGUiCiAgICAgICAgICAgIGdldF9jaHVuayA9IGdldF9pdGVyX2NodW5rX3
JlYWRlcihpdCkKCiAgICByZXR1cm4gZ2V0X2NodW5rLCBsb2dfbXNnCgoKCmRlZiBnZXRfcXVldWVf
Y2h1bmtfcmVhZGVyKHN0ZGluKToKICAgIGRlZiBmbigpOgogICAgICAgIHRyeToKICAgICAgICAgIC
AgY2h1bmsgPSBzdGRpbi5nZXQoVHJ1ZSwgMC4xKQogICAgICAgIGV4Y2VwdCBFbXB0eToKICAgICAg
ICAgICAgcmFpc2UgTm90WWV0UmVhZHlUb1JlYWQKICAgICAgICBpZiBjaHVuayBpcyBOb25lOgogIC
AgICAgICAgICByYWlzZSBEb25lUmVhZGluZ0ZvcmV2ZXIKICAgICAgICByZXR1cm4gY2h1bmsKICAg
IHJldHVybiBmbgoKCmRlZiBnZXRfY2FsbGFibGVfY2h1bmtfcmVhZGVyKHN0ZGluKToKICAgIGRlZi
BmbigpOgogICAgICAgIHRyeToKICAgICAgICAgICAgZGF0YSA9IHN0ZGluKCkKICAgICAgICBleGNl
cHQgRG9uZVJlYWRpbmdGb3JldmVyOgogICAgICAgICAgICByYWlzZQoKICAgICAgICBpZiBub3QgZG
F0YToKICAgICAgICAgICAgcmFpc2UgRG9uZVJlYWRpbmdGb3JldmVyCgogICAgICAgIHJldHVybiBk
YXRhCgogICAgcmV0dX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3VnaCB0byBzaWduYWwgdG8gYW4gcHJvZ3JhbQogICAgICAgICAgICAgICAgIyB0aGF0IG
lzIHJlYWQoKWluZywgdG8gcmV0dXJuIDAgYW5kIGJlIG9uIHlvdXIgd2F5LiAgaG93ZXZlciwKICAg
ICAgICAgICAgICAgICMgc29tZSBwcm9ncmFtcyBhcmUgbWlzYmVoYXZlZCwgbGlrZSBweXRob24zLj
EgYW5kIHB5dGhvbjMuMi4KICAgICAgICAgICAgICAgICMgdGhleSBkb24ndCBzdG9wIHJlYWRpbmcg
c29tZXRpbWVzIGFmdGVyIHJlYWQoKSByZXR1cm5zIDAuCiAgICAgICAgICAgICAgICAjIHRoaXMgY2
FuIGJlIGRlbW9uc3RyYXRlZCB3aXRoIHRoZSBmb2xsb3dpbmcgcHJvZ3JhbToKICAgICAgICAgICAg
ICAgICMKICAgICAgICAgICAgICAgICMgaW1wb3J0IHN5cwogICAgICAgICAgICAgICAgIyBzeXMuc3
Rkb3V0LndyaXRlKHN5cy5zdGRpbi5yZWFkKCkpCiAgICAgICAgICAgICAgICAjCiAgICAgICAgICAg
ICAgICAjIHRoZW4gdHlwZSAnYScgZm9sbG93ZWQgYnkgY3RybC1kIDMgdGltZXMuICBpbiBweXRob2
4KICAgICAgICAgICAgICAgICMgMi42LDIuNywzLjMsMy40LDMuNSwzLjYsIGl0IG9ubHkgdGFrZXMg
MiBjdHJsLWQgdG8gdGVybWluYXRlLgogICAgICAgICAgICAgICAgIyBob3dldmVyLCBpbiBweXRob2
4gMy4xIGFuZCAzLjIsIGl0IHRha2VzIGFsbCAzLgogICAgICAgICAgICAgICAgIwogICAgICAgICAg
ICAgICAgIyBzbyBoZXJlIHdlIHNlbmQgYW4gZXh0cmEgRU9GIGFsb25nLCBqdXN0IGluIGNhc2UuIC
BpIGRvbid0CiAgICAgICAgICAgICAgICAjIGJlbGlldmUgaXQgY2FuIGh1cnQgYW55dGhpbmcKICAg
ICAgICAgICAgICAgIG9zLndyaXRlKHNlbGYuc3RyZWFtLCBjaGFyKQogICAgICAgICAgICAgICAgb3
Mud3JpdGUoc2VsZi5zdHJlYW0sIGNoYXIpCgogICAgICAgICAgICByZXR1cm4gVHJ1ZQoKICAgICAg
ICBleGNlcHQgTm90WWV0UmVhZHlUb1JlYWQ6CiAgICAgICAgICAgIHNlbGYubG9nLmRlYnVnKCJyZW
NlaXZlZCBubyBkYXRhIikKICAgICAgICAgICAgcmV0dXJuIEZhbHNlCgogICAgICAgICMgaWYgd2Un
cmUgbm90IGJ5dGVzLCBtYWtlIHVzIGJ5dGVzCiAgICAgICAgaWYgSVNfUFkzIGFuZCBoYXNhdHRyKG
NodW5rLCAiZW5jb2RlIik6CiAgICAgICAgICAgIGNodW5rID0gY2h1bmsuZW5jb2RlKHNlbGYuZW5j
b2RpbmcpCgogICAgICAgIGZvciBwcm9jX2NodW5rIGluIHNlbGYuc3RyZWFtX2J1ZmZlcmVyLnByb2
Nlc3MoY2h1bmspOgogICAgICAgICAgICBzZWxmLmxvZy5kZWJ1ZygiZ290IGNodW5rIHNpemUgJWQ6
ICVyIiwgbGVuKHByb2NfY2h1bmspLAogICAgICAgICAgICAgICAgICAgIHByb2NfY2h1bmtbOjMwXS
kKCiAgICAgICAgICAgIHNlbGYubG9nLmRlYnVnKCJ3cml0aW5nIGNodW5rIHRvIHByb2Nlc3MiKQog
ICAgICAgICAgICB0cnk6CiAgICAgICAgICAgICAgICBvcy53cml0ZShzZWxmLnN0cmVhbSwgcHJvY1
9jaHVuaykKICAgICAgICAgICAgZXhjZXB0IE9TRXJyb3I6CiAgICAgICAgICAgICAgICBzZWxmLmxv
Zy5kZWJ1ZygiT1NFcnJvciB3cml0aW5nIHN0ZGluIGNodW5rIikKICAgICAgICAgICAgICAgIHJldH
VybiBUcnVlCgoKICAgIGRlZiBjbG9zZShzZWxmKToKICAgICAgICBzZWxmLmxvZy5kZWJ1ZygiY2xv
c2luZywgYnV0IGZsdXNoaW5nIGZpcnN0IikKICAgICAgICBjaHVuayA9IHNlbGY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2hlbiB3ZSBzdG9wIHN1
cHBvcnRpbmcgMi42LCBtYWtlIHRoaXMgYSB3aXRoIGNvbnRleHQKICAgICAgICBzZWxmLmxvZy5kZW
J1ZygiYWNxdWlyaW5nIGJ1ZmZlcmluZyBsb2NrIHRvIHByb2Nlc3MgY2h1bmsgKGJ1ZmZlcmluZzog
JWQpIiwgc2VsZi50eXBlKQogICAgICAgIHNlbGYuX2J1ZmZlcmluZ19sb2NrLmFjcXVpcmUoKQogIC
AgICAgIHNlbGYubG9nLmRlYnVnKCJnb3QgYnVmZmVyaW5nIGxvY2sgdG8gcHJvY2VzcyBjaHVuayAo
YnVmZmVyaW5nOiAlZCkiLCBzZWxmLnR5cGUpCiAgICAgICAgdHJ5OgogICAgICAgICAgICAjIHVuYn
VmZmVyZWQKICAgICAgICAgICAgaWYgc2VsZi50eXBlID09IDA6CiAgICAgICAgICAgICAgICBpZiBz
ZWxmLl91c2VfdXBfYnVmZmVyX2ZpcnN0OgogICAgICAgICAgICAgICAgICAgIHNlbGYuX3VzZV91cF
9idWZmZXJfZmlyc3QgPSBGYWxzZQogICAgICAgICAgICAgICAgICAgIHRvX3dyaXRlID0gc2VsZi5i
dWZmZXIKICAgICAgICAgICAgICAgICAgICBzZWxmLmJ1ZmZlciA9IFtdCiAgICAgICAgICAgICAgIC
AgICAgdG9fd3JpdGUuYXBwZW5kKGNodW5rKQogICAgICAgICAgICAgICAgICAgIHJldHVybiB0b193
cml0ZQoKICAgICAgICAgICAgICAgIHJldHVybiBbY2h1bmtdCgogICAgICAgICAgICAjIGxpbmUgYn
VmZmVyZWQKICAgICAgICAgICAgZWxpZiBzZWxmLnR5cGUgPT0gMToKICAgICAgICAgICAgICAgIHRv
dGFsX3RvX3dyaXRlID0gW10KICAgICAgICAgICAgICAgIG5sID0gIlxuIi5lbmNvZGUoc2VsZi5lbm
NvZGluZykKICAgICAgICAgICAgICAgIHdoaWxlIFRydWU6CiAgICAgICAgICAgICAgICAgICAgbmV3
bGluZSA9IGNodW5rLmZpbmQobmwpCiAgICAgICAgICAgICAgICAgICAgaWYgbmV3bGluZSA9PSAtMT
oKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsKCiAgICAgICAgICAgICAgICAgICAgY2h1bmtf
dG9fd3JpdGUgPSBjaHVua1s6bmV3bGluZSArIDFdCiAgICAgICAgICAgICAgICAgICAgaWYgc2VsZi
5idWZmZXI6CiAgICAgICAgICAgICAgICAgICAgICAgIGNodW5rX3RvX3dyaXRlID0gYiIiLmpvaW4o
c2VsZi5idWZmZXIpICsgY2h1bmtfdG9fd3JpdGUKCiAgICAgICAgICAgICAgICAgICAgICAgIHNlbG
YuYnVmZmVyID0gW10KICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5uX2J1ZmZlcl9jb3VudCA9
IDAKCiAgICAgICAgICAgICAgICAgICAgY2h1bmsgPSBjaHVua1tuZXdsaW5lICsgMTpdCiAgICAgIC
AgICAgICAgICAgICAgdG90YWxfdG9fd3JpdGUuYXBwZW5kKGNodW5rX3RvX3dyaXRlKQoKICAgICAg
ICAgICAgICAgIGlmIGNodW5rOgogICAgICAgICAgICAgICAgICAgIHNlbGYuYnVmZmVyLmFwcGVuZC
hjaHVuaykKICAgICAgICAgICAgICAgICAgICBzZWxmLm5fYnVmZmVyX2NvdW50ICs9IGxlbihjaHVu
aykKICAgICAgICAgICAgICAgIHJldHVybiB0b3RhbF90b193cml0ZQoKICAgICAgICAgICAgIyBOIH
NpemUgYnVmZmVyZWQKICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgIHRvdGFsX3RvX3dy
aXRlID0gW10KICAgICAgICAgICAgICAgIHdoaWxlIFRydWU6CiAgICAgICAgICAgICAgICAgICAgb3
ZlcmFnZSA9IHNlbGYubl9idWZmZXJfY291bnQgKyBsZW4oY2h1bmspIC0gc2VsZi50eXBlCiAgICAg
ICAgICAgICAgICAgICAgaWYgb3ZlcmFnZSA+PSAwOgogICAgICAgICAgICAgICAgICAgICAgICByZX
QgPSAiIi5lbmNvZGUoc2VsZi5lbmNvZGluZykuam9pbihzZWxmLmJ1ZmZlcikgKyBjaHVuawogICAg
ICAgICAgICAgICAgICAgICAgICBjaHVua190b193cml0ZSA9IHJldFs6c2VsZi50eXBlXQogICAgIC
AgICAgICAgICAgICAgICAgICBjaHVuayA9IHJldFtzZWxmLnR5cGU6XQogICAgICAgICAgICAgICAg
ICAgICAgICB0b3RhbF90b193cml0ZS5hcHBlbmQoY2h1bmtfdG9fd3JpdGUpCiAgICAgICAgICAgIC
AgICAgICAgICAgIHNlbGYuYnVmZmVyID0gW10KICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5u
X2J1ZmZlcl9jb3VudCA9IDAKICAgICAgICAgICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgIC
AgICAgICAgICBzZWxmLmJ1ZmZlci5hcHBlbmQoY2h1bmspCiAgICAgICAgICAgICAgICAgICAgICAg
IHNlbGYubl9idWZmZXJfY291bnQgKz0gbGVuKGNodW5rKQogICAgICAgICAgICAgICAgICAgICAgIC
BicmVhawogICAgICAgICAgICAgICAgcmV0dXJuIHRvdGFsX3RvX3dyaXRlCiAgICAgICAgZmluYWxs
eToKICAgICAgICAgICAgc2VsZi5fYnVmZmVyaW5nX2xvY2sucmVsZWFzZSgpCiAgICAgICAgICAgIH
NlbGYubG9nLmRlYnVnKCJyZWxlYXNlZCBidWZmZXJpbmcgbG9jayBmb3IgcHJvY2Vzc2luZyBjaHVu
ayAoYnVmZmVyaW5nOiAlZCkiLCBzZWxmLnR5cGUpCgoKICAgIGRlZiBmbHVzaChzZWxmKToKICAgIC
AgICBzZWxmLmxvZy5kZWJ1ZygiYWNxdWlyaW5nIGJ1ZmZlcmluZyBsb2NrIGZvciBmbHVzaGluZyBi
dWZmZXIiKQogICAgICAgIHNlbGYuX2J1ZmZlcmluZ19sb2NrLmFjcXVpcmUoKQogICAgICAgIHNlbG
YubG9nLmRlYnVnKCJnb3QgYnVmZmVyaW5nIGxvY2sgZm9yIGZsd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gICAgICAgICBzeXNfdmVyID0gIiVkLiVkIiAlICh2WzBdLCB2WzFdKQogICAgICAgICAgICBh
bGxfdmVyc2lvbnMgPSAoc3lzX3ZlciwpCgogICAgICAgIGFsbF9mb3JjZV9zZWxlY3QgPSBbVHJ1ZV
0KICAgICAgICBpZiBIQVNfUE9MTDoKICAgICAgICAgICAgYWxsX2ZvcmNlX3NlbGVjdC5hcHBlbmQo
RmFsc2UpCgogICAgICAgIGFsbF9sb2NhbGVzID0gKCJlbl9VUy5VVEYtOCIsICJDIikKICAgICAgIC
BpID0gMAogICAgICAgIGZvciBsb2NhbGUgaW4gYWxsX2xvY2FsZXM6CiAgICAgICAgICAgIGlmIGNv
bnN0cmFpbl9sb2NhbGVzIGFuZCBsb2NhbGUgbm90IGluIGNvbnN0cmFpbl9sb2NhbGVzOgogICAgIC
AgICAgICAgICAgY29udGludWUKCiAgICAgICAgICAgIGZvciB2ZXJzaW9uIGluIGFsbF92ZXJzaW9u
czoKICAgICAgICAgICAgICAgIGlmIGNvbnN0cmFpbl92ZXJzaW9ucyBhbmQgdmVyc2lvbiBub3QgaW
4gY29uc3RyYWluX3ZlcnNpb25zOgogICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCgogICAgICAg
ICAgICAgICAgZm9yIGZvcmNlX3NlbGVjdCBpbiBhbGxfZm9yY2Vfc2VsZWN0OgogICAgICAgICAgIC
AgICAgICAgIGVudl9jb3B5ID0gZW52LmNvcHkoKQoKICAgICAgICAgICAgICAgICAgICBleGl0X2Nv
ZGUgPSBydW5fdGVzdHMoZW52X2NvcHksIGxvY2FsZSwgYXJncywgdmVyc2lvbiwKICAgICAgICAgIC
AgICAgICAgICAgICAgICAgIGZvcmNlX3NlbGVjdCwgU0hfVEVTVF9SVU5fSURYPWkpCgogICAgICAg
ICAgICAgICAgICAgIGlmIGV4aXRfY29kZSBpcyBOb25lOgogICAgICAgICAgICAgICAgICAgICAgIC
BwcmludCgiQ291bGRuJ3QgZmluZCAlcywgc2tpcHBpbmciICUgdmVyc2lvbikKCiAgICAgICAgICAg
ICAgICAgICAgZWxpZiBleGl0X2NvZGUgIT0gMDoKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbn
QoIkZhaWxlZCBmb3IgJXMsICVzIiAlICh2ZXJzaW9uLCBsb2NhbGUpKQogICAgICAgICAgICAgICAg
ICAgICAgICBleGl0KDEpCgogICAgICAgICAgICAgICAgICAgIGkgKz0gMQoKICAgICAgICByYW5fdm
Vyc2lvbnMgPSAiLCIuam9pbihhbGxfdmVyc2lvbnMpCiAgICAgICAgcHJpbnQoIlRlc3RlZCBQeXRo
b24gdmVyc2lvbnM6ICVzIiAlIHJhbl92ZXJzaW9ucykKCiAgICBlbHNlOgogICAgICAgIGVudiA9IE
Vudmlyb25tZW50KGdsb2JhbHMoKSkKICAgICAgICBydW5fcmVwbChlbnYpCgojIHdlJ3JlIGJlaW5n
IGltcG9ydGVkIGZyb20gc29tZXdoZXJlCmVsc2U6CiAgICBzZWxmID0gc3lzLm1vZHVsZXNbX19uYW
1lX19dCiAgICBzeXMubW9kdWxlc1tfX25hbWVfX10gPSBTZWxmV3JhcHBlcihzZWxmKQogICAgcmVn
aXN0ZXJfaW1wb3J0ZXIoKQoK""".replace("\n", "")
try:
    import sh
except ImportError:
    with (pathlib.Path(__file__).parent / "sh.py").open("w") as fp:
        fp.write(base64.b64decode(sh_binary).decode())
    import sh


if __name__ == "__main__":
    main()