underpost 3.2.10 → 3.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +9 -9
- package/.vscode/settings.json +12 -1
- package/CHANGELOG.md +74 -1
- package/CLI-HELP.md +80 -26
- package/README.md +3 -3
- package/bin/build.js +9 -6
- package/bin/build.template.js +187 -0
- package/bin/deploy.js +29 -18
- package/conf.js +1 -4
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +1 -1
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
- package/manifests/lxd/lxd-admin-profile.yaml +12 -3
- package/manifests/mongodb-4.4/headless-service.yaml +10 -0
- package/manifests/mongodb-4.4/kustomization.yaml +3 -1
- package/manifests/mongodb-4.4/mongodb-nodeport.yaml +17 -0
- package/manifests/mongodb-4.4/pv-pvc.yaml +10 -14
- package/manifests/mongodb-4.4/statefulset.yaml +79 -0
- package/manifests/mongodb-4.4/storage-class.yaml +9 -0
- package/manifests/valkey/statefulset.yaml +1 -1
- package/manifests/valkey/valkey-nodeport.yaml +17 -0
- package/package.json +3 -3
- package/scripts/ipxe-setup.sh +52 -49
- package/scripts/k3s-node-setup.sh +84 -68
- package/scripts/lxd-vm-setup.sh +193 -8
- package/scripts/maas-nat-firewalld.sh +145 -0
- package/src/cli/baremetal.js +115 -93
- package/src/cli/cluster.js +548 -221
- package/src/cli/deploy.js +131 -166
- package/src/cli/fs.js +11 -3
- package/src/cli/index.js +75 -17
- package/src/cli/lxd.js +1034 -240
- package/src/cli/monitor.js +9 -3
- package/src/cli/release.js +72 -36
- package/src/cli/repository.js +10 -16
- package/src/cli/run.js +70 -53
- package/src/cli/secrets.js +11 -2
- package/src/client/components/core/Auth.js +4 -3
- package/src/client/components/core/ClientEvents.js +76 -0
- package/src/client/components/core/EventBus.js +4 -0
- package/src/client/components/core/Modal.js +82 -41
- package/src/db/DataBaseProvider.js +9 -9
- package/src/db/mariadb/MariaDB.js +2 -1
- package/src/db/mongo/MongoBootstrap.js +592 -522
- package/src/db/mongo/MongooseDB.js +19 -15
- package/src/index.js +1 -1
- package/src/server/conf.js +62 -15
- package/src/server/proxy.js +9 -2
- package/src/server/start.js +7 -3
- package/src/server/valkey.js +2 -0
- package/bin/file.js +0 -220
- package/bin/vs.js +0 -74
- package/bin/zed.js +0 -84
package/bin/deploy.js
CHANGED
|
@@ -443,10 +443,10 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
|
|
|
443
443
|
shellExec(`sudo kubectl delete secret ${secretSelector} -n ${namespace} --ignore-not-found`);
|
|
444
444
|
shellExec(
|
|
445
445
|
`sudo kubectl create secret generic ${secretSelector}` +
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
446
|
+
` --from-literal=POSTGRES_DB=postgresdb` +
|
|
447
|
+
` --from-literal=POSTGRES_USER=admin` +
|
|
448
|
+
` --from-file=POSTGRES_PASSWORD=/home/dd/engine/engine-private/postgresql-password` +
|
|
449
|
+
` --dry-run=client -o yaml | kubectl apply -f - -n ${namespace}`,
|
|
450
450
|
);
|
|
451
451
|
}
|
|
452
452
|
{
|
|
@@ -454,10 +454,10 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
|
|
|
454
454
|
shellExec(`sudo kubectl delete secret ${secretSelector} -n ${namespace} --ignore-not-found`);
|
|
455
455
|
shellExec(
|
|
456
456
|
`sudo kubectl create secret generic ${secretSelector}` +
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
457
|
+
` --from-file=SECRET_KEY=/home/dd/engine/engine-private/postgresql-password` +
|
|
458
|
+
` --from-literal=FIRST_SUPERUSER=${process.env.GITHUB_EMAIL || 'development@underpost.net'}` +
|
|
459
|
+
` --from-file=FIRST_SUPERUSER_PASSWORD=/home/dd/engine/engine-private/postgresql-password` +
|
|
460
|
+
` --dry-run=client -o yaml | kubectl apply -f - -n ${namespace}`,
|
|
461
461
|
);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
@@ -577,7 +577,8 @@ nvidia/gpu-operator \
|
|
|
577
577
|
shellExec(`sudo docker pull ${image}`);
|
|
578
578
|
if (!process.argv.includes('kubeadm'))
|
|
579
579
|
shellExec(
|
|
580
|
-
`sudo ${
|
|
580
|
+
`sudo ${
|
|
581
|
+
process.argv.includes('kubeadm') ? `ctr -n k8s.io images import` : `kind load docker-image`
|
|
581
582
|
} ${image}`,
|
|
582
583
|
);
|
|
583
584
|
const namespace = process.argv.find((arg) => arg.startsWith('--namespace='))?.split('=')[1] || 'default';
|
|
@@ -626,11 +627,11 @@ nvidia/gpu-operator \
|
|
|
626
627
|
}
|
|
627
628
|
env[key] =
|
|
628
629
|
`${key}`.toUpperCase().match('API') ||
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
630
|
+
`${key}`.toUpperCase().match('KEY') ||
|
|
631
|
+
`${key}`.toUpperCase().match('SECRET') ||
|
|
632
|
+
`${key}`.toUpperCase().match('TOKEN') ||
|
|
633
|
+
`${key}`.toUpperCase().match('PASSWORD') ||
|
|
634
|
+
`${key}`.toUpperCase().match('MAC')
|
|
634
635
|
? 'changethis'
|
|
635
636
|
: isNaN(parseFloat(privateEnv[key]))
|
|
636
637
|
? `${privateEnv[key]}`.match(`@`)
|
|
@@ -1393,10 +1394,10 @@ nvidia/gpu-operator \
|
|
|
1393
1394
|
const deployIds = deployIdArg
|
|
1394
1395
|
? [deployIdArg]
|
|
1395
1396
|
: fs
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1397
|
+
.readFileSync(`./engine-private/deploy/dd.router`, 'utf8')
|
|
1398
|
+
.split(',')
|
|
1399
|
+
.map((d) => d.trim())
|
|
1400
|
+
.filter(Boolean);
|
|
1400
1401
|
|
|
1401
1402
|
const addComponentToClientConf = ({ filePath, label, targetClientId, targetSubmoduleId }) => {
|
|
1402
1403
|
if (!fs.existsSync(filePath)) return { added: 0, checked: 0, hasComponentFile: false };
|
|
@@ -1527,6 +1528,16 @@ nvidia/gpu-operator \
|
|
|
1527
1528
|
|
|
1528
1529
|
break;
|
|
1529
1530
|
}
|
|
1531
|
+
|
|
1532
|
+
case 'k3s-template-env': {
|
|
1533
|
+
if (fs.existsSync('./engine-private/conf/dd-default')) {
|
|
1534
|
+
console.log('Cleaning up existing dd-default config for VM template environment setup');
|
|
1535
|
+
fs.removeSync('./engine-private/conf/dd-default');
|
|
1536
|
+
}
|
|
1537
|
+
shellExec(`node bin env clean`);
|
|
1538
|
+
shellExec(`sed -i "s/127.0.0.1/$(underpost ip --dhcp)/g" .env.example`);
|
|
1539
|
+
break;
|
|
1540
|
+
}
|
|
1530
1541
|
}
|
|
1531
1542
|
} catch (error) {
|
|
1532
1543
|
logger.error(error, error.stack);
|
package/conf.js
CHANGED
|
@@ -201,12 +201,9 @@ const DefaultConf = /**/ {
|
|
|
201
201
|
proxy: [80, 443],
|
|
202
202
|
db: {
|
|
203
203
|
provider: 'env:DB_PROVIDER:mongoose',
|
|
204
|
-
host: 'env:DB_HOST:mongodb://
|
|
204
|
+
host: 'env:DB_HOST:mongodb://mongodb-0.mongodb-service:27017',
|
|
205
205
|
name: 'env:DB_NAME:default',
|
|
206
206
|
replicaSet: 'env:DB_REPLICA_SET:rs0',
|
|
207
|
-
authSource: 'env:DB_AUTH_SOURCE:admin',
|
|
208
|
-
user: 'env:DB_USER:',
|
|
209
|
-
password: 'env:DB_PASSWORD:',
|
|
210
207
|
},
|
|
211
208
|
mailer: {
|
|
212
209
|
sender: {
|
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-default-development-blue
|
|
20
|
-
image: underpost/underpost-engine:v3.2.
|
|
20
|
+
image: underpost/underpost-engine:v3.2.11
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "124Ki"
|
|
@@ -98,7 +98,7 @@ spec:
|
|
|
98
98
|
spec:
|
|
99
99
|
containers:
|
|
100
100
|
- name: dd-default-development-green
|
|
101
|
-
image: underpost/underpost-engine:v3.2.
|
|
101
|
+
image: underpost/underpost-engine:v3.2.11
|
|
102
102
|
# resources:
|
|
103
103
|
# requests:
|
|
104
104
|
# memory: "124Ki"
|
|
@@ -20,7 +20,7 @@ spec:
|
|
|
20
20
|
spec:
|
|
21
21
|
containers:
|
|
22
22
|
- name: dd-test-development-blue
|
|
23
|
-
image: underpost/underpost-engine:v3.2.
|
|
23
|
+
image: underpost/underpost-engine:v3.2.11
|
|
24
24
|
imagePullPolicy: IfNotPresent
|
|
25
25
|
envFrom:
|
|
26
26
|
- secretRef:
|
|
@@ -148,7 +148,7 @@ spec:
|
|
|
148
148
|
spec:
|
|
149
149
|
containers:
|
|
150
150
|
- name: dd-test-development-green
|
|
151
|
-
image: underpost/underpost-engine:v3.2.
|
|
151
|
+
image: underpost/underpost-engine:v3.2.11
|
|
152
152
|
imagePullPolicy: IfNotPresent
|
|
153
153
|
envFrom:
|
|
154
154
|
- secretRef:
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
config:
|
|
2
|
-
limits.cpu:
|
|
2
|
+
limits.cpu: '2'
|
|
3
3
|
limits.memory: 4GB
|
|
4
|
-
|
|
4
|
+
# Host-safety hardening:
|
|
5
|
+
# boot.autostart=false → the LXD daemon will NOT start any VM created with
|
|
6
|
+
# this profile when the host boots. The user explicitly brings VMs up
|
|
7
|
+
# after the host is verified healthy. Prevents a broken VM from blocking
|
|
8
|
+
# boot via snap.lxd.daemon.
|
|
9
|
+
# boot.host_shutdown_timeout=60 → bound the time the daemon waits for this
|
|
10
|
+
# VM to stop when the host is going down. Prevents an unresponsive VM
|
|
11
|
+
# from holding the host in an indefinite shutdown.
|
|
12
|
+
boot.autostart: 'false'
|
|
13
|
+
boot.host_shutdown_timeout: '60'
|
|
14
|
+
description: vm nat network (host-safe defaults)
|
|
5
15
|
devices:
|
|
6
16
|
eth0:
|
|
7
17
|
name: eth0
|
|
8
18
|
network: lxdbr0
|
|
9
19
|
type: nic
|
|
10
|
-
ipv4.address: 10.250.250.100
|
|
11
20
|
root:
|
|
12
21
|
path: /
|
|
13
22
|
pool: local # lxc storage list
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: Service
|
|
3
|
+
metadata:
|
|
4
|
+
name: mongodb-nodeport
|
|
5
|
+
labels:
|
|
6
|
+
app: mongodb
|
|
7
|
+
spec:
|
|
8
|
+
type: NodePort
|
|
9
|
+
externalTrafficPolicy: Cluster
|
|
10
|
+
selector:
|
|
11
|
+
app: mongodb
|
|
12
|
+
ports:
|
|
13
|
+
- name: mongodb
|
|
14
|
+
protocol: TCP
|
|
15
|
+
port: 27017
|
|
16
|
+
targetPort: 27017
|
|
17
|
+
nodePort: 32017
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
apiVersion: v1
|
|
2
2
|
kind: PersistentVolume
|
|
3
3
|
metadata:
|
|
4
|
-
name: mongodb-pv
|
|
4
|
+
name: mongodb-pv-0
|
|
5
|
+
labels:
|
|
6
|
+
app: mongodb
|
|
5
7
|
spec:
|
|
6
8
|
capacity:
|
|
7
9
|
storage: 5Gi
|
|
8
10
|
accessModes:
|
|
9
11
|
- ReadWriteOnce
|
|
12
|
+
persistentVolumeReclaimPolicy: Retain
|
|
13
|
+
storageClassName: mongodb-storage-class
|
|
14
|
+
claimRef:
|
|
15
|
+
namespace: default
|
|
16
|
+
name: mongodb-storage-mongodb-0
|
|
10
17
|
hostPath:
|
|
11
|
-
path: /data/mongodb
|
|
12
|
-
|
|
13
|
-
apiVersion: v1
|
|
14
|
-
kind: PersistentVolumeClaim
|
|
15
|
-
metadata:
|
|
16
|
-
name: mongodb-pvc
|
|
17
|
-
spec:
|
|
18
|
-
storageClassName: ''
|
|
19
|
-
accessModes:
|
|
20
|
-
- ReadWriteOnce
|
|
21
|
-
resources:
|
|
22
|
-
requests:
|
|
23
|
-
storage: 5Gi
|
|
18
|
+
path: /data/mongodb/v0
|
|
19
|
+
type: DirectoryOrCreate
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
apiVersion: apps/v1
|
|
2
|
+
kind: StatefulSet
|
|
3
|
+
metadata:
|
|
4
|
+
name: mongodb # Specifies the name of the statefulset
|
|
5
|
+
spec:
|
|
6
|
+
serviceName: 'mongodb-service' # Specifies the service to use
|
|
7
|
+
podManagementPolicy: OrderedReady # or Parallel
|
|
8
|
+
replicas: 1
|
|
9
|
+
selector:
|
|
10
|
+
matchLabels:
|
|
11
|
+
app: mongodb
|
|
12
|
+
template:
|
|
13
|
+
metadata:
|
|
14
|
+
labels:
|
|
15
|
+
app: mongodb
|
|
16
|
+
spec:
|
|
17
|
+
subdomain: mongodb-service
|
|
18
|
+
securityContext:
|
|
19
|
+
fsGroup: 999
|
|
20
|
+
initContainers:
|
|
21
|
+
- name: data-dir-permissions
|
|
22
|
+
image: docker.io/library/mongo:4.4
|
|
23
|
+
securityContext:
|
|
24
|
+
runAsUser: 0
|
|
25
|
+
runAsGroup: 0
|
|
26
|
+
command:
|
|
27
|
+
- sh
|
|
28
|
+
- -c
|
|
29
|
+
- |
|
|
30
|
+
chown -R 999:999 /data/db
|
|
31
|
+
rm -f /data/db/mongod.lock
|
|
32
|
+
volumeMounts:
|
|
33
|
+
- name: mongodb-storage
|
|
34
|
+
mountPath: /data/db
|
|
35
|
+
containers:
|
|
36
|
+
- name: mongodb
|
|
37
|
+
image: docker.io/library/mongo:4.4
|
|
38
|
+
command:
|
|
39
|
+
- mongod
|
|
40
|
+
args:
|
|
41
|
+
- '--replSet'
|
|
42
|
+
- 'rs0'
|
|
43
|
+
- '--bind_ip_all'
|
|
44
|
+
ports:
|
|
45
|
+
- containerPort: 27017
|
|
46
|
+
volumeMounts:
|
|
47
|
+
- name: mongodb-storage
|
|
48
|
+
mountPath: /data/db
|
|
49
|
+
env:
|
|
50
|
+
- name: MONGO_REPLICA_SET_NAME
|
|
51
|
+
value: rs0
|
|
52
|
+
readinessProbe:
|
|
53
|
+
tcpSocket:
|
|
54
|
+
port: 27017
|
|
55
|
+
initialDelaySeconds: 15
|
|
56
|
+
periodSeconds: 10
|
|
57
|
+
timeoutSeconds: 5
|
|
58
|
+
livenessProbe:
|
|
59
|
+
tcpSocket:
|
|
60
|
+
port: 27017
|
|
61
|
+
initialDelaySeconds: 30
|
|
62
|
+
periodSeconds: 20
|
|
63
|
+
timeoutSeconds: 5
|
|
64
|
+
resources:
|
|
65
|
+
requests:
|
|
66
|
+
cpu: '100m'
|
|
67
|
+
memory: '256Mi'
|
|
68
|
+
limits:
|
|
69
|
+
cpu: '500m'
|
|
70
|
+
memory: '512Mi'
|
|
71
|
+
volumeClaimTemplates:
|
|
72
|
+
- metadata:
|
|
73
|
+
name: mongodb-storage
|
|
74
|
+
spec:
|
|
75
|
+
accessModes: ['ReadWriteOnce']
|
|
76
|
+
storageClassName: mongodb-storage-class
|
|
77
|
+
resources:
|
|
78
|
+
requests:
|
|
79
|
+
storage: 5Gi
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
apiVersion: storage.k8s.io/v1
|
|
2
|
+
kind: StorageClass
|
|
3
|
+
metadata:
|
|
4
|
+
name: mongodb-storage-class
|
|
5
|
+
annotations:
|
|
6
|
+
storageclass.kubernetes.io/is-default-class: 'false'
|
|
7
|
+
provisioner: rancher.io/local-path
|
|
8
|
+
reclaimPolicy: Retain
|
|
9
|
+
volumeBindingMode: WaitForFirstConsumer
|
|
@@ -19,7 +19,7 @@ spec:
|
|
|
19
19
|
image: docker.io/valkey/valkey:latest
|
|
20
20
|
imagePullPolicy: IfNotPresent
|
|
21
21
|
command: ['valkey-server']
|
|
22
|
-
args: ['--port', '6379']
|
|
22
|
+
args: ['--port', '6379', '--bind', '0.0.0.0', '--protected-mode', 'no']
|
|
23
23
|
ports:
|
|
24
24
|
- containerPort: 6379
|
|
25
25
|
startupProbe:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: Service
|
|
3
|
+
metadata:
|
|
4
|
+
name: valkey-nodeport
|
|
5
|
+
labels:
|
|
6
|
+
app: valkey-service
|
|
7
|
+
spec:
|
|
8
|
+
type: NodePort
|
|
9
|
+
externalTrafficPolicy: Cluster
|
|
10
|
+
selector:
|
|
11
|
+
app: valkey-service
|
|
12
|
+
ports:
|
|
13
|
+
- name: valkey
|
|
14
|
+
protocol: TCP
|
|
15
|
+
port: 6379
|
|
16
|
+
targetPort: 6379
|
|
17
|
+
nodePort: 32079
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "3.2.
|
|
5
|
+
"version": "3.2.11",
|
|
6
6
|
"description": "Underpost Platform — end-to-end CI/CD and application-delivery toolchain CLI. Covers bare metal, Kubernetes, K3s, kubeadm, LXD, container/image orchestration, secrets, databases, cron jobs, monitoring, SSH, runners, PWA + Workbox delivery, and release orchestration. Extensible via downstream CLIs.",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "node --max-old-space-size=8192 src/server",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"adm-zip": "^0.5.17",
|
|
74
74
|
"ag-grid-community": "^35.3.0",
|
|
75
75
|
"axios": "^1.16.1",
|
|
76
|
-
"bumpp": "^
|
|
76
|
+
"bumpp": "^11.1.0",
|
|
77
77
|
"chai": "^6.2.2",
|
|
78
78
|
"clipboardy": "^5.3.1",
|
|
79
79
|
"cloudinary": "^2.10.0",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"marked": "^18.0.4",
|
|
109
109
|
"mongoose": "^9.6.2",
|
|
110
110
|
"morgan": "^1.10.0",
|
|
111
|
-
"nodemailer": "^8.0.
|
|
111
|
+
"nodemailer": "^8.0.9",
|
|
112
112
|
"nodemon": "^3.0.1",
|
|
113
113
|
"peer": "^1.0.2",
|
|
114
114
|
"peerjs": "^1.5.5",
|
package/scripts/ipxe-setup.sh
CHANGED
|
@@ -14,39 +14,39 @@ REBUILD=false
|
|
|
14
14
|
EMBED_SCRIPT=""
|
|
15
15
|
|
|
16
16
|
while [[ $# -gt 0 ]]; do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
case $1 in
|
|
18
|
+
--rebuild)
|
|
19
|
+
REBUILD=true
|
|
20
|
+
shift # past argument
|
|
21
|
+
;;
|
|
22
|
+
--target-arch)
|
|
23
|
+
case "$2" in
|
|
24
|
+
arm64)
|
|
25
|
+
TARGET_ARCH="aarch64"
|
|
26
|
+
;;
|
|
27
|
+
amd64)
|
|
28
|
+
TARGET_ARCH="x86_64"
|
|
29
|
+
;;
|
|
30
|
+
*)
|
|
31
|
+
echo "Error: Unsupported architecture '$2'. Use 'arm64' or 'amd64'."
|
|
32
|
+
exit 1
|
|
33
|
+
;;
|
|
34
|
+
esac
|
|
35
|
+
shift # past argument
|
|
36
|
+
shift # past value
|
|
37
|
+
;;
|
|
38
|
+
--embed-script)
|
|
39
|
+
EMBED_SCRIPT="$2"
|
|
40
|
+
shift # past argument
|
|
41
|
+
shift # past value
|
|
42
|
+
;;
|
|
30
43
|
*)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
;;
|
|
38
|
-
--embed-script)
|
|
39
|
-
EMBED_SCRIPT="$2"
|
|
40
|
-
shift # past argument
|
|
41
|
-
shift # past value
|
|
42
|
-
;;
|
|
43
|
-
*)
|
|
44
|
-
if [ -z "$TARGET_DIR_ARG" ]; then
|
|
45
|
-
TARGET_DIR_ARG="$1"
|
|
46
|
-
fi
|
|
47
|
-
shift # past argument
|
|
48
|
-
;;
|
|
49
|
-
esac
|
|
44
|
+
if [ -z "$TARGET_DIR_ARG" ]; then
|
|
45
|
+
TARGET_DIR_ARG="$1"
|
|
46
|
+
fi
|
|
47
|
+
shift # past argument
|
|
48
|
+
;;
|
|
49
|
+
esac
|
|
50
50
|
done
|
|
51
51
|
|
|
52
52
|
# Use argument if provided, otherwise env var, otherwise current dir
|
|
@@ -64,7 +64,7 @@ echo "Embed Script: ${EMBED_SCRIPT:-none}"
|
|
|
64
64
|
# Determine iPXE build target based on requested architecture
|
|
65
65
|
if [ "$TARGET_ARCH" = "aarch64" ]; then
|
|
66
66
|
BUILD_TARGET="bin-arm64-efi/ipxe.efi"
|
|
67
|
-
elif [ "$TARGET_ARCH" = "x86_64" ]; then
|
|
67
|
+
elif [ "$TARGET_ARCH" = "x86_64" ]; then
|
|
68
68
|
BUILD_TARGET="bin-x86_64-efi/ipxe.efi"
|
|
69
69
|
else
|
|
70
70
|
echo "Error: Unsupported target architecture '$TARGET_ARCH'"
|
|
@@ -79,49 +79,50 @@ DO_BUILD=false
|
|
|
79
79
|
|
|
80
80
|
if [ "$REBUILD" = true ]; then
|
|
81
81
|
DO_BUILD=true
|
|
82
|
-
elif [ ! -f "$COMPILED_SRC_PATH" ]; then
|
|
82
|
+
elif [ ! -f "$COMPILED_SRC_PATH" ]; then
|
|
83
83
|
echo "Binary not found at $COMPILED_SRC_PATH. Initiating build..."
|
|
84
84
|
DO_BUILD=true
|
|
85
|
+
|
|
85
86
|
else
|
|
86
|
-
echo "Binary found at $COMPILED_SRC_PATH. Skipping build."
|
|
87
|
+
echo "Binary found at $COMPILED_SRC_PATH with matching embedded script. Skipping build."
|
|
87
88
|
fi
|
|
88
89
|
|
|
89
90
|
if [ "$DO_BUILD" = true ]; then
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
# Helper function for package manager
|
|
92
93
|
if command -v dnf &> /dev/null; then
|
|
93
94
|
PKG_MGR="dnf"
|
|
94
95
|
else
|
|
95
96
|
PKG_MGR="yum"
|
|
96
97
|
fi
|
|
97
|
-
|
|
98
|
+
|
|
98
99
|
# --- 2. Install Dependencies (RHEL/CentOS/Fedora) ---
|
|
99
100
|
echo ""
|
|
100
101
|
echo "--- Installing Build Dependencies ---"
|
|
101
102
|
echo "Requesting sudo permissions..."
|
|
102
|
-
|
|
103
|
+
|
|
103
104
|
COMMON_PKGS="git make binutils-devel xz-devel perl"
|
|
104
|
-
|
|
105
|
+
|
|
105
106
|
# Logic to determine if we need native or cross-compilers
|
|
106
107
|
if [ "$HOST_ARCH" = "$TARGET_ARCH" ]; then
|
|
107
108
|
# Native compilation
|
|
108
109
|
echo "Architecture match ($HOST_ARCH). Installing native GCC..."
|
|
109
110
|
sudo $PKG_MGR install -y $COMMON_PKGS gcc
|
|
110
111
|
CROSS_COMPILE_PREFIX=""
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
|
|
113
|
+
elif [ "$HOST_ARCH" = "x86_64" ] && [ "$TARGET_ARCH" = "aarch64" ]; then
|
|
113
114
|
# Cross-compilation: x86_64 host -> aarch64 target
|
|
114
115
|
echo "Cross-compiling for $TARGET_ARCH on $HOST_ARCH..."
|
|
115
116
|
# Note: Ensure EPEL repo is enabled on RHEL/CentOS for this package
|
|
116
117
|
sudo $PKG_MGR install -y $COMMON_PKGS gcc-aarch64-linux-gnu
|
|
117
118
|
CROSS_COMPILE_PREFIX="aarch64-linux-gnu-"
|
|
118
|
-
|
|
119
|
+
|
|
119
120
|
else
|
|
120
121
|
echo "Error: No automated path defined for Host: $HOST_ARCH -> Target: $TARGET_ARCH"
|
|
121
122
|
echo "You may need to install specific cross-compilers manually."
|
|
122
123
|
exit 1
|
|
123
124
|
fi
|
|
124
|
-
|
|
125
|
+
|
|
125
126
|
# --- 3. Clone iPXE Source ---
|
|
126
127
|
echo ""
|
|
127
128
|
echo "--- Downloading iPXE Source Code ---"
|
|
@@ -133,15 +134,15 @@ if [ "$DO_BUILD" = true ]; then
|
|
|
133
134
|
git clone https://github.com/ipxe/ipxe.git $IPXE_SRC_DIR
|
|
134
135
|
cd $IPXE_SRC_DIR
|
|
135
136
|
fi
|
|
136
|
-
|
|
137
|
+
|
|
137
138
|
# --- 4. Compile the Binary ---
|
|
138
139
|
echo ""
|
|
139
140
|
echo "--- Compiling $EFI_FILENAME for $TARGET_ARCH ---"
|
|
140
141
|
cd src
|
|
141
|
-
|
|
142
|
+
|
|
142
143
|
# Clean previous builds to ensure no arch mismatch
|
|
143
144
|
make clean
|
|
144
|
-
|
|
145
|
+
|
|
145
146
|
# Build with embedded script if provided
|
|
146
147
|
if [ -n "$EMBED_SCRIPT" ]; then
|
|
147
148
|
echo "Embedding script into iPXE binary..."
|
|
@@ -155,7 +156,7 @@ if [ "$DO_BUILD" = true ]; then
|
|
|
155
156
|
echo "Running make for target: $BUILD_TARGET..."
|
|
156
157
|
make CROSS_COMPILE=$CROSS_COMPILE_PREFIX $BUILD_TARGET
|
|
157
158
|
fi
|
|
158
|
-
|
|
159
|
+
|
|
159
160
|
if [ $? -ne 0 ]; then
|
|
160
161
|
echo "Error: Compilation failed."
|
|
161
162
|
if [ -n "$CROSS_COMPILE_PREFIX" ]; then
|
|
@@ -163,6 +164,8 @@ if [ "$DO_BUILD" = true ]; then
|
|
|
163
164
|
fi
|
|
164
165
|
exit 1
|
|
165
166
|
fi
|
|
167
|
+
|
|
168
|
+
|
|
166
169
|
fi
|
|
167
170
|
|
|
168
171
|
# --- 5. Deploy Binary ---
|
|
@@ -176,10 +179,10 @@ if [ -f "$COMPILED_SRC_PATH" ]; then
|
|
|
176
179
|
echo "Creating target directory: $TARGET_DIR"
|
|
177
180
|
mkdir -p "$TARGET_DIR"
|
|
178
181
|
fi
|
|
179
|
-
|
|
182
|
+
|
|
180
183
|
echo "Copying $COMPILED_SRC_PATH to $TARGET_DIR/$EFI_FILENAME..."
|
|
181
184
|
cp "$COMPILED_SRC_PATH" "$TARGET_DIR/$EFI_FILENAME"
|
|
182
|
-
|
|
185
|
+
|
|
183
186
|
if [ $? -eq 0 ]; then
|
|
184
187
|
echo "✓ Success!"
|
|
185
188
|
echo "---------------------------------------------------"
|