-
Notifications
You must be signed in to change notification settings - Fork 15
160 lines (138 loc) · 5.11 KB
/
mor-agents-build-linux.yml
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
name: MOR Agents Build Linux
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build with PyInstaller
run: |
pyinstaller --name="MORagents" --add-data "images/moragents.png:images" main.py
- name: Create Debian package
run: |
mkdir -p debian/DEBIAN
mkdir -p debian/usr/bin
mkdir -p debian/usr/share/applications
mkdir -p debian/usr/share/icons/hicolor/256x256/apps
cp -r dist/MORagents/* debian/usr/bin/
cp images/moragents.png debian/usr/share/icons/hicolor/256x256/apps/moragents.png
echo "[Desktop Entry]
Name=MORagents
Exec=/usr/bin/MORagents
Icon=moragents
Type=Application
Categories=Utility;" > debian/usr/share/applications/moragents.desktop
echo "Package: moragents
Version: 1.0
Section: utils
Priority: optional
Architecture: amd64
Maintainer: LachsBagel
Description: MORagents application
MORagents is a desktop application for AI agents." > debian/DEBIAN/control
# Create postinst script with improved lock handling
cat << EOF > debian/DEBIAN/postinst
#!/bin/bash
set -e
# Function to wait for lock release
wait_for_lock_release() {
local lock_file=\$1
local max_wait=300 # Maximum wait time in seconds
local wait_time=0
while fuser \$lock_file >/dev/null 2>&1; do
if [ \$wait_time -ge \$max_wait ]; then
echo "Timeout waiting for lock release. Installation may be incomplete."
return 1
fi
sleep 5
wait_time=\$((wait_time + 5))
echo "Waiting for lock release... (\$wait_time seconds)"
done
return 0
}
# Function to run apt operations safely
run_apt_safely() {
local max_attempts=3
local attempt=1
while [ \$attempt -le \$max_attempts ]; do
if wait_for_lock_release /var/lib/dpkg/lock; then
if wait_for_lock_release /var/lib/apt/lists/lock; then
if "\$@"; then
return 0
fi
fi
fi
echo "Attempt \$attempt failed. Retrying..."
attempt=\$((attempt + 1))
sleep 10
done
echo "Failed to complete apt operation after \$max_attempts attempts."
return 1
}
# Ensure curl is installed
if ! command -v curl &> /dev/null; then
echo "Installing curl..."
if ! run_apt_safely apt-get update && run_apt_safely apt-get install -y curl; then
echo "Failed to install curl. Exiting."
exit 1
fi
fi
# Install Docker if not present
if ! command -v docker &> /dev/null; then
echo "Installing Docker..."
if curl -fsSL https://get.docker.com -o get-docker.sh; then
if sh get-docker.sh; then
usermod -aG docker \$SUDO_USER
systemctl enable docker
systemctl start docker
else
echo "Failed to install Docker. Exiting."
exit 1
fi
else
echo "Failed to download Docker installation script. Exiting."
exit 1
fi
fi
# Pull necessary Docker images
echo "Pulling Docker images..."
if ! docker pull morpheusai/nginx-agent:latest || ! docker pull morpheusai/agents:latest; then
echo "Failed to pull Docker images. Exiting."
exit 1
fi
# Start Docker containers
echo "Starting Docker containers..."
if ! docker run -d --name agents -p 8080:5000 --restart always -v /var/lib/agents -v /app/src morpheusai/agents:latest; then
echo "Failed to start agents container. Exiting."
exit 1
fi
if ! docker run -d --name nginx -p 3333:80 morpheusai/nginx-agent:latest; then
echo "Failed to start nginx container. Exiting."
exit 1
fi
echo "Installation complete!"
echo "You can now start MORagents from your application menu or by running 'MORagents' in the terminal."
EOF
chmod 755 debian/DEBIAN/postinst
dpkg-deb --build debian moragents.deb
- name: Upload Debian Package
uses: actions/upload-artifact@v4
with:
name: MORagentsSetup-Linux
path: moragents.deb