diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/__init__.py b/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/main.py b/main.py new file mode 100755 index 0000000..05dd797 --- /dev/null +++ b/main.py @@ -0,0 +1,100 @@ +# Universal Docker Setup Tool by Raphael Lucas Dittberner +import os +import subprocess +import sys +import typer +import yaml + +app = typer.Typer() + +if "REPO" in os.environ: + repo = os.environ['REPO'] + '/' + print("Your current repository path is " + repo + ". To change it, change the REPO environment variable.") +else: + repo = '' + print("The tool will use the config file from the directory it is running in. If you want to change this, " + "set the REPO environment variable.") + + +config = repo + 'udtconfig.yml' +with open(config, 'r') as udtcfg: + read_config = yaml.safe_load(udtcfg) + +compose_config = repo + "docker-compose.yml" + +services = read_config['services'] + + +@app.command(help="Create docker containers for services specified in utdconfig.yml without starting them") +def create(): + subprocess.run(["rm", "-rf", compose_config]) + invalid_options = ['addons', 'bindings', 'commands'] + with open(config) as oldfile, open(compose_config, 'w') as newfile: + for line in oldfile: + if not any(invalid_option in line for invalid_option in invalid_options): + newfile.write(line) + subprocess.run(["docker-compose", "-f", compose_config, "up", "--no-start"]) + for i in list(read_config['services']): + for index in list(read_config['services'][i]['addons']['bindings']['commands']): + subprocess.run([index]) + + +@app.command(help="Start all or specific services specified in udtconfig.yml") +def start(): + start_service = input("Enter the name of the service you want to start, or press ENTER to start all: ") + if start_service == "": + start_service = list(services) + index = 0 + for i in start_service: + subprocess.run(["docker-compose", "start", start_service[index]]) + index += 1 + sys.exit(0) + else: + subprocess.run(["docker-compose", "start", start_service]) + sys.exit(0) + + +@app.command(help="Stop all or specific services specified in udtconfig.yml") +def stop(): + stop_service = input("Enter the name of the service you want to stop, or press ENTER to stop all: ") + if stop_service == "": + while True: + confirm = input("Are you sure you want to stop all services? Type YES or NO! ") + if confirm == "NO": + print("aborting") + sys.exit(0) + elif confirm == "YES": + stop_service = list(services) + index = 0 + for i in stop_service: + subprocess.run(["docker-compose", "stop", stop_service[index]]) + index += 1 + sys.exit(0) + else: + print("Please type YES or NO!") + continue + else: + subprocess.run(["docker-compose", "stop", stop_service]) + sys.exit(0) + + +@app.command(help="Run shell in docker container of specified service") +def shell(): + service = input("Enter service name: ") + subprocess.run(["docker", "compose", "run", service, "sh"]) + + +@app.command(help="Run karaf shell in specified openhab container") +def karaf(): + service = input("Enter service name: ") + subprocess.run(["docker", "compose", "run", service, "/openhab/runtime/bin/client"]) + + +@app.command(help="Stop all services and delete all docker containers") +def down(): + subprocess.run(["docker-compose", "-f", compose_config, "down"]) + sys.exit(0) + + +if __name__ == "__main__": + app() diff --git a/out.ps b/out.ps new file mode 100755 index 0000000..cb13bb2 --- /dev/null +++ b/out.ps @@ -0,0 +1,1459 @@ +%!PS-Adobe-3.0 +%%BoundingBox: 18 36 577 806 +%%Title: Enscript Output +%%Creator: GNU Enscript 1.6.5.90 +%%CreationDate: Mon May 13 19:41:23 2024 +%%Orientation: Portrait +%%Pages: (atend) +%%DocumentMedia: A4 595 842 0 () () +%%DocumentNeededResources: (atend) +%%EndComments +%%BeginProlog +%%BeginResource: procset Enscript-Prolog 1.6.5 90 +% +% Procedures. +% + +/_S { % save current state + /_s save def +} def +/_R { % restore from saved state + _s restore +} def + +/S { % showpage protecting gstate + gsave + showpage + grestore +} bind def + +/MF { % fontname newfontname -> - make a new encoded font + /newfontname exch def + /fontname exch def + + /fontdict fontname findfont def + /newfont fontdict maxlength dict def + + fontdict { + exch + dup /FID eq { + % skip FID pair + pop pop + } { + % copy to the new font dictionary + exch newfont 3 1 roll put + } ifelse + } forall + + newfont /FontName newfontname put + + % insert only valid encoding vectors + encoding_vector length 256 eq { + newfont /Encoding encoding_vector put + } if + + newfontname newfont definefont pop +} def + +/MF_PS { % fontname newfontname -> - make a new font preserving its enc + /newfontname exch def + /fontname exch def + + /fontdict fontname findfont def + /newfont fontdict maxlength dict def + + fontdict { + exch + dup /FID eq { + % skip FID pair + pop pop + } { + % copy to the new font dictionary + exch newfont 3 1 roll put + } ifelse + } forall + + newfont /FontName newfontname put + + newfontname newfont definefont pop +} def + +/SF { % fontname width height -> - set a new font + /height exch def + /width exch def + + findfont + [width 0 0 height 0 0] makefont setfont +} def + +/SUF { % fontname width height -> - set a new user font + /height exch def + /width exch def + + /F-gs-user-font MF + /F-gs-user-font width height SF +} def + +/SUF_PS { % fontname width height -> - set a new user font preserving its enc + /height exch def + /width exch def + + /F-gs-user-font MF_PS + /F-gs-user-font width height SF +} def + +/M {moveto} bind def +/s {show} bind def + +/Box { % x y w h -> - define box path + /d_h exch def /d_w exch def /d_y exch def /d_x exch def + d_x d_y moveto + d_w 0 rlineto + 0 d_h rlineto + d_w neg 0 rlineto + closepath +} def + +/bgs { % x y height blskip gray str -> - show string with bg color + /str exch def + /gray exch def + /blskip exch def + /height exch def + /y exch def + /x exch def + + gsave + x y blskip sub str stringwidth pop height Box + gray setgray + fill + grestore + x y M str s +} def + +/bgcs { % x y height blskip red green blue str -> - show string with bg color + /str exch def + /blue exch def + /green exch def + /red exch def + /blskip exch def + /height exch def + /y exch def + /x exch def + + gsave + x y blskip sub str stringwidth pop height Box + red green blue setrgbcolor + fill + grestore + x y M str s +} def + +% Highlight bars. +/highlight_bars { % nlines lineheight output_y_margin gray -> - + gsave + setgray + /ymarg exch def + /lineheight exch def + /nlines exch def + + % This 2 is just a magic number to sync highlight lines to text. + 0 d_header_y ymarg sub 2 sub translate + + /cw d_output_w cols div def + /nrows d_output_h ymarg 2 mul sub lineheight div cvi def + + % for each column + 0 1 cols 1 sub { + cw mul /xp exch def + + % for each rows + 0 1 nrows 1 sub { + /rn exch def + rn lineheight mul neg /yp exch def + rn nlines idiv 2 mod 0 eq { + % Draw highlight bar. 4 is just a magic indentation. + xp 4 add yp cw 8 sub lineheight neg Box fill + } if + } for + } for + + grestore +} def + +% Line highlight bar. +/line_highlight { % x y width height gray -> - + gsave + /gray exch def + Box gray setgray fill + grestore +} def + +% Column separator lines. +/column_lines { + gsave + .1 setlinewidth + 0 d_footer_h translate + /cw d_output_w cols div def + 1 1 cols 1 sub { + cw mul 0 moveto + 0 d_output_h rlineto stroke + } for + grestore +} def + +% Column borders. +/column_borders { + gsave + .1 setlinewidth + 0 d_footer_h moveto + 0 d_output_h rlineto + d_output_w 0 rlineto + 0 d_output_h neg rlineto + closepath stroke + grestore +} def + +% Do the actual underlay drawing +/draw_underlay { + ul_style 0 eq { + ul_str true charpath stroke + } { + ul_str show + } ifelse +} def + +% Underlay +/underlay { % - -> - + gsave + 0 d_page_h translate + d_page_h neg d_page_w atan rotate + + ul_gray setgray + ul_font setfont + /dw d_page_h dup mul d_page_w dup mul add sqrt def + ul_str stringwidth pop dw exch sub 2 div ul_h_ptsize -2 div moveto + draw_underlay + grestore +} def + +/user_underlay { % - -> - + gsave + ul_x ul_y translate + ul_angle rotate + ul_gray setgray + ul_font setfont + 0 0 ul_h_ptsize 2 div sub moveto + draw_underlay + grestore +} def + +% Page prefeed +/page_prefeed { % bool -> - + statusdict /prefeed known { + statusdict exch /prefeed exch put + } { + pop + } ifelse +} def + +% Wrapped line markers +/wrapped_line_mark { % x y charwith charheight type -> - + /type exch def + /h exch def + /w exch def + /y exch def + /x exch def + + type 2 eq { + % Black boxes (like TeX does) + gsave + 0 setlinewidth + x w 4 div add y M + 0 h rlineto w 2 div 0 rlineto 0 h neg rlineto + closepath fill + grestore + } { + type 3 eq { + % Small arrows + gsave + .2 setlinewidth + x w 2 div add y h 2 div add M + w 4 div 0 rlineto + x w 4 div add y lineto stroke + + x w 4 div add w 8 div add y h 4 div add M + x w 4 div add y lineto + w 4 div h 8 div rlineto stroke + grestore + } { + % do nothing + } ifelse + } ifelse +} def + +% EPSF import. + +/BeginEPSF { + /b4_Inc_state save def % Save state for cleanup + /dict_count countdictstack def % Count objects on dict stack + /op_count count 1 sub def % Count objects on operand stack + userdict begin + /showpage { } def + 0 setgray 0 setlinecap + 1 setlinewidth 0 setlinejoin + 10 setmiterlimit [ ] 0 setdash newpath + /languagelevel where { + pop languagelevel + 1 ne { + false setstrokeadjust false setoverprint + } if + } if +} bind def + +/EndEPSF { + count op_count sub { pos } repeat % Clean up stacks + countdictstack dict_count sub { end } repeat + b4_Inc_state restore +} bind def + +% Check PostScript language level. +/languagelevel where { + pop /gs_languagelevel languagelevel def +} { + /gs_languagelevel 1 def +} ifelse +%%EndResource +%%BeginResource: procset Enscript-Encoding-88591 1.6.5 90 +/encoding_vector [ +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/space /exclam /quotedbl /numbersign +/dollar /percent /ampersand /quoteright +/parenleft /parenright /asterisk /plus +/comma /hyphen /period /slash +/zero /one /two /three +/four /five /six /seven +/eight /nine /colon /semicolon +/less /equal /greater /question +/at /A /B /C +/D /E /F /G +/H /I /J /K +/L /M /N /O +/P /Q /R /S +/T /U /V /W +/X /Y /Z /bracketleft +/backslash /bracketright /asciicircum /underscore +/quoteleft /a /b /c +/d /e /f /g +/h /i /j /k +/l /m /n /o +/p /q /r /s +/t /u /v /w +/x /y /z /braceleft +/bar /braceright /tilde /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef +/space /exclamdown /cent /sterling +/currency /yen /brokenbar /section +/dieresis /copyright /ordfeminine /guillemotleft +/logicalnot /hyphen /registered /macron +/degree /plusminus /twosuperior /threesuperior +/acute /mu /paragraph /bullet +/cedilla /onesuperior /ordmasculine /guillemotright +/onequarter /onehalf /threequarters /questiondown +/Agrave /Aacute /Acircumflex /Atilde +/Adieresis /Aring /AE /Ccedilla +/Egrave /Eacute /Ecircumflex /Edieresis +/Igrave /Iacute /Icircumflex /Idieresis +/Eth /Ntilde /Ograve /Oacute +/Ocircumflex /Otilde /Odieresis /multiply +/Oslash /Ugrave /Uacute /Ucircumflex +/Udieresis /Yacute /Thorn /germandbls +/agrave /aacute /acircumflex /atilde +/adieresis /aring /ae /ccedilla +/egrave /eacute /ecircumflex /edieresis +/igrave /iacute /icircumflex /idieresis +/eth /ntilde /ograve /oacute +/ocircumflex /otilde /odieresis /divide +/oslash /ugrave /uacute /ucircumflex +/udieresis /yacute /thorn /ydieresis +] def +%%EndResource +%%EndProlog +%%BeginSetup +%%IncludeResource: font Courier-Bold +%%IncludeResource: font Courier +/HFpt_w 10 def +/HFpt_h 10 def +/Courier-Bold /HF-gs-font MF +/HF /HF-gs-font findfont [HFpt_w 0 0 HFpt_h 0 0] makefont def +/Courier /F-gs-font MF +/F-gs-font 10 10 SF +/#copies 1 def +% Pagedevice definitions: +gs_languagelevel 1 gt { + << + /PageSize [595 842] + >> setpagedevice +} if +%%BeginResource: procset Enscript-Header-enscript 1.6.5 90 +%%IncludeResource: font Times-Bold +%%IncludeResource: font Times-Roman + +% Fonts. +/Times-Bold /HeaderFont-Bold MF +/HeaderDateF /HeaderFont-Bold findfont 12 scalefont def + +/Times-Roman /HeaderFont-Times MF +/HeaderHDRF /HeaderFont-Times findfont 14 scalefont def + +/HeaderPageNumF /Helvetica-Bold findfont 28.8 scalefont def + +/do_header { % print enscript header + gsave + d_header_x d_header_y translate + + % light bar + 0 0 d_header_w d_header_h 2 div Box + .95 setgray fill + + % dark gray boxes + /dbw d_header_h 2 mul def % dark box width + /dbc .7 def % dark box color + + % left dark box. + 0 0 dbw d_header_h Box + dbc setgray fill + + 0 setgray + HeaderDateF setfont + moddatestr dup stringwidth pop dbw exch sub 2 div + d_header_h 2 div 2 add moveto show + modtimestr dup stringwidth pop dbw exch sub 2 div + d_header_h 5 div moveto show + + % right dark box + d_header_w dbw sub 0 dbw d_header_h Box + dbc setgray fill + + HeaderPageNumF setfont + 1 setgray + pagenumstr dup + stringwidth pop dbw exch sub 2 div d_header_w dbw sub add + d_header_h .2 mul moveto show + + % filename + 0 setgray + HeaderHDRF setfont + d_header_w fname stringwidth pop sub 2 div d_header_h 8 div moveto + fname show + + % user supplied header string. + user_header_p { + /h d_header_h 8 div 5 mul def + + % Implement strict enscript compatibility. + user_header_center_str () eq user_header_right_str () eq and { + d_header_w user_header_left_str stringwidth pop sub 2 div + h moveto user_header_left_str show + } { + dbw 5 add h moveto user_header_left_str show + + d_header_w user_header_center_str stringwidth pop sub 2 div + h moveto user_header_center_str show + + d_header_w dbw sub 5 sub user_header_right_str stringwidth pop + sub h moveto user_header_right_str show + } ifelse + } if + + grestore +} def +%%EndResource +/d_page_w 559 def +/d_page_h 770 def +/d_header_x 0 def +/d_header_y 734 def +/d_header_w 559 def +/d_header_h 36 def +/d_footer_x 0 def +/d_footer_y 0 def +/d_footer_w 559 def +/d_footer_h 0 def +/d_output_w 559 def +/d_output_h 734 def +/cols 1 def +%%EndSetup +%%Page: (1) 1 +%%BeginPageSetup +_S +18 36 translate +/pagenum 1 def +/fname (main.py) def +/fdir (.) def +/ftail (main.py) def +% User defined strings: +/pagenumstr (1) def +/moddatestr (05/13/24) def +/modtimestr (19:24:45) def +/user_header_p false def +/user_footer_p false def +%%EndPageSetup +do_header +30 721 M (1:) s +/Courier-Oblique 10 10 SUF +48 721 M +(# Universal Docker Setup Tool by Raphael Lucas Dittberner) s +/F-gs-font 10 10 SF +30 710 M (2:) s +/Courier-Oblique 10 10 SUF +/F-gs-font 10 10 SF +/Courier-Bold 10 10 SUF +48 710 M +(import) s +/F-gs-font 10 10 SF +84 710 M +( os) s +30 699 M (3:) s +/Courier-Bold 10 10 SUF +48 699 M +(import) s +/F-gs-font 10 10 SF +84 699 M +( subprocess) s +30 688 M (4:) s +/Courier-Bold 10 10 SUF +48 688 M +(import) s +/F-gs-font 10 10 SF +84 688 M +( sys) s +30 677 M (5:) s +/Courier-Bold 10 10 SUF +48 677 M +(import) s +/F-gs-font 10 10 SF +84 677 M +( typer) s +30 666 M (6:) s +/Courier-Bold 10 10 SUF +48 666 M +(import) s +/F-gs-font 10 10 SF +84 666 M +( yaml) s +30 655 M (7:) s +30 644 M (8:) s +48 644 M +(app = typer.Typer\(\)) s +30 633 M (9:) s +24 622 M (10:) s +/Courier-Bold 10 10 SUF +48 622 M +(if) s +/F-gs-font 10 10 SF +60 622 M +( ) s +/Courier-Bold 10 10 SUF +66 622 M +("REPO") s +/F-gs-font 10 10 SF +102 622 M +( ) s +/Courier-Bold 10 10 SUF +108 622 M +(in) s +/F-gs-font 10 10 SF +120 622 M +( os.environ:) s +24 611 M (11:) s +48 611 M +( repo = os.environ[) s +/Courier-Bold 10 10 SUF +180 611 M +('REPO') s +/F-gs-font 10 10 SF +216 611 M +(] + ) s +/Courier-Bold 10 10 SUF +240 611 M +('/') s +/F-gs-font 10 10 SF +24 600 M (12:) s +48 600 M +( ) s +/Courier-Bold 10 10 SUF +72 600 M +(print) s +/F-gs-font 10 10 SF +102 600 M +(\() s +/Courier-Bold 10 10 SUF +108 600 M +("Your current repository path is ") s +/F-gs-font 10 10 SF +312 600 M +( + repo + ) s +/Courier-Bold 10 10 SUF +372 600 M +(". To change it, change the RE) s +5 589 M +(PO environment variable.") s +/F-gs-font 10 10 SF +155 589 M +(\)) s +24 578 M (13:) s +/Courier-Bold 10 10 SUF +48 578 M +(else) s +/F-gs-font 10 10 SF +72 578 M +(:) s +24 567 M (14:) s +48 567 M +( repo = ) s +/Courier-Bold 10 10 SUF +114 567 M +('') s +/F-gs-font 10 10 SF +24 556 M (15:) s +48 556 M +( ) s +/Courier-Bold 10 10 SUF +72 556 M +(print) s +/F-gs-font 10 10 SF +102 556 M +(\() s +/Courier-Bold 10 10 SUF +108 556 M +("The tool will use the config file from the directory it is running in. If) s +5 545 M +( you want to change this, ") s +/F-gs-font 10 10 SF +24 534 M (16:) s +48 534 M +( ) s +/Courier-Bold 10 10 SUF +108 534 M +("set the REPO environment variable.") s +/F-gs-font 10 10 SF +324 534 M +(\)) s +24 523 M (17:) s +24 512 M (18:) s +24 501 M (19:) s +48 501 M +(config = repo + ) s +/Courier-Bold 10 10 SUF +144 501 M +('udtconfig.yml') s +/F-gs-font 10 10 SF +24 490 M (20:) s +48 490 M +(with open\(config, ) s +/Courier-Bold 10 10 SUF +156 490 M +('r') s +/F-gs-font 10 10 SF +174 490 M +(\) as udtcfg:) s +24 479 M (21:) s +48 479 M +( read_config = yaml.safe_load\(udtcfg\)) s +24 468 M (22:) s +24 457 M (23:) s +48 457 M +(compose_config = repo + ) s +/Courier-Bold 10 10 SUF +192 457 M +("docker-compose.yml") s +/F-gs-font 10 10 SF +24 446 M (24:) s +24 435 M (25:) s +48 435 M +(services = read_config[) s +/Courier-Bold 10 10 SUF +186 435 M +('services') s +/F-gs-font 10 10 SF +246 435 M +(]) s +24 424 M (26:) s +24 413 M (27:) s +24 402 M (28:) s +48 402 M +(@app.command\(help=) s +/Courier-Bold 10 10 SUF +156 402 M +("Create docker containers for services specified in utdconfig.yml ) s +5 391 M +(without starting them") s +/F-gs-font 10 10 SF +137 391 M +(\)) s +24 380 M (29:) s +/Courier-Bold 10 10 SUF +48 380 M +(def) s +/F-gs-font 10 10 SF +66 380 M +( ) s +/Courier-Bold 10 10 SUF +72 380 M +(create) s +/F-gs-font 10 10 SF +108 380 M +(\(\):) s +24 369 M (30:) s +48 369 M +( subprocess.run\([) s +/Courier-Bold 10 10 SUF +168 369 M +("rm") s +/F-gs-font 10 10 SF +192 369 M +(, ) s +/Courier-Bold 10 10 SUF +204 369 M +("-rf") s +/F-gs-font 10 10 SF +234 369 M +(, compose_config]\)) s +24 358 M (31:) s +48 358 M +( invalid_options = [) s +/Courier-Bold 10 10 SUF +186 358 M +('addons') s +/F-gs-font 10 10 SF +234 358 M +(, ) s +/Courier-Bold 10 10 SUF +246 358 M +('bindings') s +/F-gs-font 10 10 SF +306 358 M +(, ) s +/Courier-Bold 10 10 SUF +318 358 M +('commands') s +/F-gs-font 10 10 SF +378 358 M +(]) s +24 347 M (32:) s +48 347 M +( with open\(config\) as oldfile, open\(compose_config, ) s +/Courier-Bold 10 10 SUF +378 347 M +('w') s +/F-gs-font 10 10 SF +396 347 M +(\) as newfile:) s +24 336 M (33:) s +48 336 M +( ) s +/Courier-Bold 10 10 SUF +96 336 M +(for) s +/F-gs-font 10 10 SF +114 336 M +( line ) s +/Courier-Bold 10 10 SUF +150 336 M +(in) s +/F-gs-font 10 10 SF +162 336 M +( oldfile:) s +24 325 M (34:) s +48 325 M +( ) s +/Courier-Bold 10 10 SUF +120 325 M +(if) s +/F-gs-font 10 10 SF +132 325 M +( ) s +/Courier-Bold 10 10 SUF +138 325 M +(not) s +/F-gs-font 10 10 SF +156 325 M +( any\(invalid_option ) s +/Courier-Bold 10 10 SUF +276 325 M +(in) s +/F-gs-font 10 10 SF +288 325 M +( line ) s +/Courier-Bold 10 10 SUF +324 325 M +(for) s +/F-gs-font 10 10 SF +342 325 M +( invalid_option ) s +/Courier-Bold 10 10 SUF +438 325 M +(in) s +/F-gs-font 10 10 SF +450 325 M +( invalid_options\)) s +5 314 M +(:) s +24 303 M (35:) s +48 303 M +( newfile.write\(line\)) s +24 292 M (36:) s +48 292 M +( subprocess.run\([) s +/Courier-Bold 10 10 SUF +168 292 M +("docker-compose") s +/F-gs-font 10 10 SF +264 292 M +(, ) s +/Courier-Bold 10 10 SUF +276 292 M +("-f") s +/F-gs-font 10 10 SF +300 292 M +(, compose_config, ) s +/Courier-Bold 10 10 SUF +408 292 M +("up") s +/F-gs-font 10 10 SF +432 292 M +(, ) s +/Courier-Bold 10 10 SUF +444 292 M +("--no-start") s +/F-gs-font 10 10 SF +516 292 M +(]\)) s +24 281 M (37:) s +48 281 M +( ) s +/Courier-Bold 10 10 SUF +72 281 M +(for) s +/F-gs-font 10 10 SF +90 281 M +( i ) s +/Courier-Bold 10 10 SUF +108 281 M +(in) s +/F-gs-font 10 10 SF +120 281 M +( list\(read_config[) s +/Courier-Bold 10 10 SUF +228 281 M +('services') s +/F-gs-font 10 10 SF +288 281 M +(]\):) s +24 270 M (38:) s +48 270 M +( ) s +/Courier-Bold 10 10 SUF +96 270 M +(for) s +/F-gs-font 10 10 SF +114 270 M +( index ) s +/Courier-Bold 10 10 SUF +156 270 M +(in) s +/F-gs-font 10 10 SF +168 270 M +( list\(read_config[) s +/Courier-Bold 10 10 SUF +276 270 M +('services') s +/F-gs-font 10 10 SF +336 270 M +(][i][) s +/Courier-Bold 10 10 SUF +366 270 M +('addons') s +/F-gs-font 10 10 SF +414 270 M +(][) s +/Courier-Bold 10 10 SUF +426 270 M +('bindings') s +/F-gs-font 10 10 SF +486 270 M +(][) s +/Courier-Bold 10 10 SUF +498 270 M +('commands) s +5 259 M +(') s +/F-gs-font 10 10 SF +11 259 M +(]\):) s +24 248 M (39:) s +48 248 M +( subprocess.run\([index]\)) s +24 237 M (40:) s +24 226 M (41:) s +24 215 M (42:) s +48 215 M +(@app.command\(help=) s +/Courier-Bold 10 10 SUF +156 215 M +("Start all or specific services specified in udtconfig.yml") s +/F-gs-font 10 10 SF +510 215 M +(\)) s +24 204 M (43:) s +/Courier-Bold 10 10 SUF +48 204 M +(def) s +/F-gs-font 10 10 SF +66 204 M +( ) s +/Courier-Bold 10 10 SUF +72 204 M +(start) s +/F-gs-font 10 10 SF +102 204 M +(\(\):) s +24 193 M (44:) s +48 193 M +( start_service = input\() s +/Courier-Bold 10 10 SUF +204 193 M +("Enter the name of the service you want to start, or press) s +5 182 M +( ENTER to start all: ") s +/F-gs-font 10 10 SF +137 182 M +(\)) s +24 171 M (45:) s +48 171 M +( ) s +/Courier-Bold 10 10 SUF +72 171 M +(if) s +/F-gs-font 10 10 SF +84 171 M +( start_service == ) s +/Courier-Bold 10 10 SUF +192 171 M +("") s +/F-gs-font 10 10 SF +204 171 M +(:) s +24 160 M (46:) s +48 160 M +( start_service = list\(services\)) s +24 149 M (47:) s +48 149 M +( index = 0) s +24 138 M (48:) s +48 138 M +( ) s +/Courier-Bold 10 10 SUF +96 138 M +(for) s +/F-gs-font 10 10 SF +114 138 M +( i ) s +/Courier-Bold 10 10 SUF +132 138 M +(in) s +/F-gs-font 10 10 SF +144 138 M +( start_service:) s +24 127 M (49:) s +48 127 M +( subprocess.run\([) s +/Courier-Bold 10 10 SUF +216 127 M +("docker-compose") s +/F-gs-font 10 10 SF +312 127 M +(, ) s +/Courier-Bold 10 10 SUF +324 127 M +("start") s +/F-gs-font 10 10 SF +366 127 M +(, start_service[index]]\)) s +24 116 M (50:) s +48 116 M +( index += 1) s +24 105 M (51:) s +48 105 M +( sys.exit\(0\)) s +24 94 M (52:) s +48 94 M +( ) s +/Courier-Bold 10 10 SUF +72 94 M +(else) s +/F-gs-font 10 10 SF +96 94 M +(:) s +24 83 M (53:) s +48 83 M +( subprocess.run\([) s +/Courier-Bold 10 10 SUF +192 83 M +("docker-compose") s +/F-gs-font 10 10 SF +288 83 M +(, ) s +/Courier-Bold 10 10 SUF +300 83 M +("start") s +/F-gs-font 10 10 SF +342 83 M +(, start_service]\)) s +24 72 M (54:) s +48 72 M +( sys.exit\(0\)) s +24 61 M (55:) s +24 50 M (56:) s +24 39 M (57:) s +48 39 M +(@app.command\(help=) s +/Courier-Bold 10 10 SUF +156 39 M +("Stop all or specific services specified in udtconfig.yml") s +/F-gs-font 10 10 SF +504 39 M +(\)) s +24 28 M (58:) s +/Courier-Bold 10 10 SUF +48 28 M +(def) s +/F-gs-font 10 10 SF +66 28 M +( ) s +/Courier-Bold 10 10 SUF +72 28 M +(stop) s +/F-gs-font 10 10 SF +96 28 M +(\(\):) s +24 17 M (59:) s +48 17 M +( stop_service = input\() s +/Courier-Bold 10 10 SUF +198 17 M +("Enter the name of the service you want to stop, or press E) s +5 6 M +(NTER to stop all: ") s +/F-gs-font 10 10 SF +119 6 M +(\)) s +_R +S +%%Page: (2) 2 +%%BeginPageSetup +_S +18 36 translate +/pagenum 2 def +/fname (main.py) def +/fdir (.) def +/ftail (main.py) def +% User defined strings: +/pagenumstr (2) def +/moddatestr (05/13/24) def +/modtimestr (19:24:45) def +/user_header_p false def +/user_footer_p false def +%%EndPageSetup +do_header +24 721 M (60:) s +48 721 M +( ) s +/Courier-Bold 10 10 SUF +72 721 M +(if) s +/F-gs-font 10 10 SF +84 721 M +( stop_service == ) s +/Courier-Bold 10 10 SUF +186 721 M +("") s +/F-gs-font 10 10 SF +198 721 M +(:) s +24 710 M (61:) s +48 710 M +( ) s +/Courier-Bold 10 10 SUF +96 710 M +(while) s +/F-gs-font 10 10 SF +126 710 M +( True:) s +24 699 M (62:) s +48 699 M +( confirm = input\() s +/Courier-Bold 10 10 SUF +216 699 M +("Are you sure you want to stop all services? Type YES or) s +5 688 M +( NO! ") s +/F-gs-font 10 10 SF +41 688 M +(\)) s +24 677 M (63:) s +48 677 M +( ) s +/Courier-Bold 10 10 SUF +120 677 M +(if) s +/F-gs-font 10 10 SF +132 677 M +( confirm == ) s +/Courier-Bold 10 10 SUF +204 677 M +("NO") s +/F-gs-font 10 10 SF +228 677 M +(:) s +24 666 M (64:) s +48 666 M +( ) s +/Courier-Bold 10 10 SUF +144 666 M +(print) s +/F-gs-font 10 10 SF +174 666 M +(\() s +/Courier-Bold 10 10 SUF +180 666 M +("aborting") s +/F-gs-font 10 10 SF +240 666 M +(\)) s +24 655 M (65:) s +48 655 M +( sys.exit\(0\)) s +24 644 M (66:) s +48 644 M +( ) s +/Courier-Bold 10 10 SUF +120 644 M +(elif) s +/F-gs-font 10 10 SF +144 644 M +( confirm == ) s +/Courier-Bold 10 10 SUF +216 644 M +("YES") s +/F-gs-font 10 10 SF +246 644 M +(:) s +24 633 M (67:) s +48 633 M +( stop_service = list\(services\)) s +24 622 M (68:) s +48 622 M +( index = 0) s +24 611 M (69:) s +48 611 M +( ) s +/Courier-Bold 10 10 SUF +144 611 M +(for) s +/F-gs-font 10 10 SF +162 611 M +( i ) s +/Courier-Bold 10 10 SUF +180 611 M +(in) s +/F-gs-font 10 10 SF +192 611 M +( stop_service:) s +24 600 M (70:) s +48 600 M +( subprocess.run\([) s +/Courier-Bold 10 10 SUF +264 600 M +("docker-compose") s +/F-gs-font 10 10 SF +360 600 M +(, ) s +/Courier-Bold 10 10 SUF +372 600 M +("stop") s +/F-gs-font 10 10 SF +408 600 M +(, stop_service[index]]\)) s +24 589 M (71:) s +48 589 M +( index += 1) s +24 578 M (72:) s +48 578 M +( sys.exit\(0\)) s +24 567 M (73:) s +48 567 M +( ) s +/Courier-Bold 10 10 SUF +120 567 M +(else) s +/F-gs-font 10 10 SF +144 567 M +(:) s +24 556 M (74:) s +48 556 M +( ) s +/Courier-Bold 10 10 SUF +144 556 M +(print) s +/F-gs-font 10 10 SF +174 556 M +(\() s +/Courier-Bold 10 10 SUF +180 556 M +("Please type YES or NO!") s +/F-gs-font 10 10 SF +324 556 M +(\)) s +24 545 M (75:) s +48 545 M +( ) s +/Courier-Bold 10 10 SUF +144 545 M +(continue) s +/F-gs-font 10 10 SF +24 534 M (76:) s +48 534 M +( ) s +/Courier-Bold 10 10 SUF +72 534 M +(else) s +/F-gs-font 10 10 SF +96 534 M +(:) s +24 523 M (77:) s +48 523 M +( subprocess.run\([) s +/Courier-Bold 10 10 SUF +192 523 M +("docker-compose") s +/F-gs-font 10 10 SF +288 523 M +(, ) s +/Courier-Bold 10 10 SUF +300 523 M +("stop") s +/F-gs-font 10 10 SF +336 523 M +(, stop_service]\)) s +24 512 M (78:) s +48 512 M +( sys.exit\(0\)) s +24 501 M (79:) s +24 490 M (80:) s +24 479 M (81:) s +48 479 M +(@app.command\(help=) s +/Courier-Bold 10 10 SUF +156 479 M +("Run shell in docker container of specified service") s +/F-gs-font 10 10 SF +468 479 M +(\)) s +24 468 M (82:) s +/Courier-Bold 10 10 SUF +48 468 M +(def) s +/F-gs-font 10 10 SF +66 468 M +( ) s +/Courier-Bold 10 10 SUF +72 468 M +(shell) s +/F-gs-font 10 10 SF +102 468 M +(\(\):) s +24 457 M (83:) s +48 457 M +( service = input\() s +/Courier-Bold 10 10 SUF +168 457 M +("Enter service name: ") s +/F-gs-font 10 10 SF +300 457 M +(\)) s +24 446 M (84:) s +48 446 M +( subprocess.run\([) s +/Courier-Bold 10 10 SUF +168 446 M +("docker") s +/F-gs-font 10 10 SF +216 446 M +(, ) s +/Courier-Bold 10 10 SUF +228 446 M +("compose") s +/F-gs-font 10 10 SF +282 446 M +(, ) s +/Courier-Bold 10 10 SUF +294 446 M +("run") s +/F-gs-font 10 10 SF +324 446 M +(, service, ) s +/Courier-Bold 10 10 SUF +390 446 M +("sh") s +/F-gs-font 10 10 SF +414 446 M +(]\)) s +24 435 M (85:) s +24 424 M (86:) s +24 413 M (87:) s +48 413 M +(@app.command\(help=) s +/Courier-Bold 10 10 SUF +156 413 M +("Run karaf shell in specified openhab container") s +/F-gs-font 10 10 SF +444 413 M +(\)) s +24 402 M (88:) s +/Courier-Bold 10 10 SUF +48 402 M +(def) s +/F-gs-font 10 10 SF +66 402 M +( ) s +/Courier-Bold 10 10 SUF +72 402 M +(karaf) s +/F-gs-font 10 10 SF +102 402 M +(\(\):) s +24 391 M (89:) s +48 391 M +( service = input\() s +/Courier-Bold 10 10 SUF +168 391 M +("Enter service name: ") s +/F-gs-font 10 10 SF +300 391 M +(\)) s +24 380 M (90:) s +48 380 M +( subprocess.run\([) s +/Courier-Bold 10 10 SUF +168 380 M +("docker") s +/F-gs-font 10 10 SF +216 380 M +(, ) s +/Courier-Bold 10 10 SUF +228 380 M +("compose") s +/F-gs-font 10 10 SF +282 380 M +(, ) s +/Courier-Bold 10 10 SUF +294 380 M +("run") s +/F-gs-font 10 10 SF +324 380 M +(, service, ) s +/Courier-Bold 10 10 SUF +390 380 M +("/openhab/runtime/bin/clien) s +5 369 M +(t") s +/F-gs-font 10 10 SF +17 369 M +(]\)) s +24 358 M (91:) s +24 347 M (92:) s +24 336 M (93:) s +48 336 M +(@app.command\(help=) s +/Courier-Bold 10 10 SUF +156 336 M +("Stop all services and delete all docker containers") s +/F-gs-font 10 10 SF +468 336 M +(\)) s +24 325 M (94:) s +/Courier-Bold 10 10 SUF +48 325 M +(def) s +/F-gs-font 10 10 SF +66 325 M +( ) s +/Courier-Bold 10 10 SUF +72 325 M +(down) s +/F-gs-font 10 10 SF +96 325 M +(\(\):) s +24 314 M (95:) s +48 314 M +( subprocess.run\([) s +/Courier-Bold 10 10 SUF +168 314 M +("docker-compose") s +/F-gs-font 10 10 SF +264 314 M +(, ) s +/Courier-Bold 10 10 SUF +276 314 M +("-f") s +/F-gs-font 10 10 SF +300 314 M +(, compose_config, ) s +/Courier-Bold 10 10 SUF +408 314 M +("down") s +/F-gs-font 10 10 SF +444 314 M +(]\)) s +24 303 M (96:) s +48 303 M +( sys.exit\(0\)) s +24 292 M (97:) s +24 281 M (98:) s +24 270 M (99:) s +/Courier-Bold 10 10 SUF +48 270 M +(if) s +/F-gs-font 10 10 SF +60 270 M +( __name__ == ) s +/Courier-Bold 10 10 SUF +138 270 M +("__main__") s +/F-gs-font 10 10 SF +198 270 M +(:) s +18 259 M (100:) s +48 259 M +( app\(\)) s +_R +S +%%Trailer +%%Pages: 2 +%%DocumentNeededResources: font Times-Roman Courier-Oblique Courier-Bold +%%+ font Courier Times-Bold +%%EOF diff --git a/requirements.txt b/requirements.txt new file mode 100755 index 0000000..b06730d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ + +docker-compose==1.29.2 +typer==0.9.0 + diff --git a/udtconfig template b/udtconfig template new file mode 100755 index 0000000..13c12b5 --- /dev/null +++ b/udtconfig template @@ -0,0 +1,2 @@ +[udtconfig] +docker_image = test diff --git a/udtconfig.yml b/udtconfig.yml new file mode 100755 index 0000000..e940f4b --- /dev/null +++ b/udtconfig.yml @@ -0,0 +1,34 @@ +services: + alpine1: + image: redis:alpine + addons: + bindings: + commands: [ls] + alpine2: + image: redis:alpine + addons: + bindings: + commands: [ls] + debian: + image: debian:latest + addons: + bindings: + commands: [ls] + openhab: + image: openhab/openhab:latest + restart: always + network_mode: host + volumes: + - "/etc/localtime:/etc/localtime:ro" + - "/etc/timezone:/etc/timezone:ro" + - "./openhab_addons:/openhab/addons" + - "./openhab_conf:/openhab/conf" + - "./openhab_userdata:/openhab/userdata" + environment: + CRYPTO_POLICY: "unlimited" + EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin" + OPENHAB_HTTP_PORT: "8080" + OPENHAB_HTTPS_PORT: "8443" + addons: + bindings: + commands: [ls] \ No newline at end of file