Skip to content

Commit 21d1366

Browse files
committed
overlord: restructure dir structure, add setup.py
1 parent 4f5f5bc commit 21d1366

14 files changed

+90
-16
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
apk add git python3 make gcc linux-headers libc-dev py-pip
2020
python3 -m venv .venv
2121
source .venv/bin/activate
22-
pip install -r requirements.txt
22+
pip install -r py/requirements.txt
2323
- name: Fix permission
2424
run: git config --global --add safe.directory $PWD
2525
- name: test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ dist
1414
xcuserdata
1515
__pycache__
1616
*.pyc
17+
.DS_Store

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN mkdir -p /config /app /app/webroot/upgrade
3636
WORKDIR /app
3737

3838
COPY --from=gobuilder /src/bin/overlordd /app
39-
COPY --from=gobuilder /src/scripts/start_overlordd.sh /app
39+
COPY --from=gobuilder /src/sh/start_overlordd.sh /app
4040
COPY --from=gobuilder /src/bin/ghost.* /app/webroot/upgrade/
4141
COPY --from=pybuilder /src/bin/ghost.* /app/webroot/upgrade/
4242
COPY --from=pybuilder /src/bin/ovl.* /app/webroot/upgrade/

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LDFLAGS=
1111
WEBROOT_DIR=$(CURDIR)/webroot
1212
DIST_APPS_DIR=$(WEBROOT_DIR)/apps
1313
GO_DIRS=./overlord/... ./cmd/...
14-
PY_FILES=$(shell find scripts -name "*.py")
14+
PY_FILES=$(shell find py -name "*.py")
1515

1616
# Supported architectures for ghost binary
1717
GHOST_ARCHS=amd64 386 arm64 arm
@@ -74,9 +74,9 @@ ghost-all: $(GHOST_BINS) $(GHOST_BINS:=.sha1)
7474
build-go: overlordd ghost ghost-all
7575

7676
build-py:
77-
@ln -sf ../scripts/ghost.py bin
77+
@ln -sf ../py/ghost.py bin
7878
$(call cmd_msg,SHA1,ghost.py)
79-
@sha1sum scripts/ghost.py > bin/ghost.py.sha1
79+
@sha1sum py/ghost.py > bin/ghost.py.sha1
8080

8181
@mkdir -p $(BUILD)
8282
$(call cmd_msg,VENV,creating virtualenv)
@@ -85,19 +85,19 @@ build-py:
8585
$(call cmd_msg,PIP,installing requirements)
8686
@cd $(BUILD); \
8787
. $(BUILD)/.venv/bin/activate; \
88-
pip install -q -r $(CURDIR)/requirements.txt; \
88+
pip install -q -r $(CURDIR)/py/requirements.txt; \
8989
pip install -q pyinstaller
9090

9191
$(call cmd_msg,GEN,ovl.pybin)
9292
@cd $(BUILD); . $(BUILD)/.venv/bin/activate; \
93-
pyinstaller --onefile $(CURDIR)/scripts/ovl.py > /dev/null;
93+
pyinstaller --onefile $(CURDIR)/py/ovl.py > /dev/null;
9494
@mv $(BUILD)/dist/ovl $(BIN)/ovl.pybin
9595
$(call cmd_msg,SHA1,ovl.pybin)
9696
@cd $(BIN) && sha1sum ovl.pybin > ovl.pybin.sha1
9797

9898
$(call cmd_msg,GEN,ghost.pybin)
9999
@cd $(BUILD); . $(BUILD)/.venv/bin/activate; \
100-
pyinstaller --onefile $(CURDIR)/scripts/ghost.py > /dev/null
100+
pyinstaller --onefile $(CURDIR)/py/ghost.py > /dev/null
101101
@mv $(BUILD)/dist/ghost $(BIN)/ghost.pybin
102102
$(call cmd_msg,SHA1,ghost.pybin)
103103
@cd $(BIN) && sha1sum ghost.pybin > ghost.pybin.sha1
File renamed without changes.

scripts/ovl.py renamed to py/ovl.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,10 @@ def CheckDaemon(self):
909909
self._state = DaemonState.FromDict(self._server.State())
910910
sha1sum = GetVersionDigest()
911911

912-
#if sha1sum != self._state.version_sha1sum:
913-
# print('ovl server is out of date. killing...')
914-
# KillGraceful(self._server.GetPid())
915-
# self.StartServer()
912+
if sha1sum != self._state.version_sha1sum:
913+
print('ovl server is out of date. killing...')
914+
KillGraceful(self._server.GetPid())
915+
self.StartServer()
916916

917917
def GetSSHControlFile(self, host):
918918
return _SSH_CONTROL_SOCKET_PREFIX + host
@@ -1765,11 +1765,11 @@ def main():
17651765
ovl = OverlordCliClient()
17661766
try:
17671767
ovl.Main()
1768-
#except KeyboardInterrupt:
1769-
# print('Ctrl-C received, abort')
1768+
except KeyboardInterrupt:
1769+
print('Ctrl-C received, abort')
17701770
except Exception as e:
17711771
logging.exception(e)
1772-
#print(f'error: {str(e)}')
1772+
print(f'error: {str(e)}')
17731773

17741774

17751775
if __name__ == '__main__':
File renamed without changes.
File renamed without changes.

py/setup.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env python
2+
# Copyright 2023 The Overlord Authors. All rights reserved.
3+
4+
from setuptools import setup
5+
import subprocess
6+
import sys
7+
8+
# Check if we're installing
9+
if 'install' in sys.argv or 'develop' in sys.argv:
10+
# Try to install ws4py from git directly
11+
print("Installing ws4py dependency from git...")
12+
try:
13+
subprocess.check_call([
14+
sys.executable, '-m', 'pip', 'install',
15+
'git+https://github.com/aitjcize/WebSocket-for-Python.git#egg=ws4py'
16+
])
17+
print("Successfully installed ws4py")
18+
except subprocess.CalledProcessError as e:
19+
print(f"Warning: Failed to install ws4py dependency: {e}")
20+
print("You may need to install it manually with:")
21+
print("pip install git+https://github.com/aitjcize/WebSocket-for-Python.git")
22+
23+
# Read requirements from requirements.txt
24+
with open('requirements.txt') as f:
25+
requirements = f.read().splitlines()
26+
27+
# Filter out git dependencies for setup.py
28+
filtered_requirements = []
29+
for req in requirements:
30+
if not req.startswith('ws4py @ git+') and req.strip():
31+
filtered_requirements.append(req)
32+
33+
# Add ws4py as a regular requirement
34+
filtered_requirements.append('ws4py')
35+
36+
setup(
37+
name="overlord",
38+
version="1.0.0",
39+
description="Overlord - Remote Device Management and Control System",
40+
author="Wei-Ning Huang",
41+
author_email="[email protected]",
42+
url="https://github.com/aitjcize/Overlord",
43+
py_modules=["ovl", "ghost", "update_ui_status", "relay_overlord_discovery_packet", "stream_camera"],
44+
entry_points={
45+
'console_scripts': [
46+
'ovl=ovl:main',
47+
'ghost=ghost:main',
48+
'update_ui_status=update_ui_status:main',
49+
'relay_overlord_discovery_packet=relay_overlord_discovery_packet:main',
50+
'stream_camera=stream_camera:main',
51+
],
52+
},
53+
install_requires=filtered_requirements,
54+
python_requires='>=3.6',
55+
classifiers=[
56+
"Development Status :: 4 - Beta",
57+
"Environment :: Console",
58+
"Intended Audience :: Developers",
59+
"License :: OSI Approved :: BSD License",
60+
"Operating System :: OS Independent",
61+
"Programming Language :: Python :: 3",
62+
"Programming Language :: Python :: 3.6",
63+
"Programming Language :: Python :: 3.7",
64+
"Programming Language :: Python :: 3.8",
65+
"Programming Language :: Python :: 3.9",
66+
"Topic :: Software Development :: Testing",
67+
"Topic :: System :: Monitoring",
68+
"Topic :: System :: Systems Administration",
69+
],
70+
dependency_links=[
71+
"https://github.com/aitjcize/WebSocket-for-Python/tarball/master#egg=ws4py-0.5.1"
72+
],
73+
)

0 commit comments

Comments
 (0)