File size: 1,925 Bytes
571f20f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
#/* DARNA.HI
# * Copyright (c) 2023 Seapoe1809   <https://github.com/seapoe1809>
# * 
# * 
# *
# *   This program is free software: you can redistribute it and/or modify
# *   it under the terms of the GNU General Public License as published by
# *   the Free Software Foundation, either version 3 of the License, or
# *   (at your option) any later version.
# *
# *   This program 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. See the
# *   GNU General Public License for more details.
# *
# *   You should have received a copy of the GNU General Public License
# *   along with this program. If not, see <http://www.gnu.org/licenses/>.
# */
#will run to install the docker container and then replace the js module to allow opening port

import os
import subprocess
import sys

# Label current dir and parent dir
HS_path = os.getcwd()
APP_dir = f"{HS_path}/install_module"

if sys.version_info < (3, 0):
    print("This script requires Python 3 or higher!")
    sys.exit(1)

current_dir = f"{APP_dir}/Dock"  # replace this and the following code in new app

try:
    result1 = subprocess.run(['docker', 'volume', 'create', 'yacht'], cwd=HS_path, check=True)
    result2 = subprocess.run([
        'docker', 'run', '-d', '-p', '3009:8000',
        '-v', '/var/run/docker.sock:/var/run/docker.sock',
        '-v', 'yacht:/config', '--name', 'yacht', 'selfhostedpro/yacht'
    ], cwd=HS_path, check=True)
    
    print("Installed Yacht, your Docker Dock")
except subprocess.CalledProcessError:
    print("Failed to create Dock")
except Exception as e:
    print(f"An error occurred while creating Dock: {e}")

# write to static/dock_script.js
file_path = f'{HS_path}/static/'
command3 = f"cp {current_dir}/Dock_script.js {file_path}/Dock_script.js"
os.system(command3)