Skip to content

Commit 2ff689e

Browse files
authored
feat(script): Add logic to reassemble split AI models on boot
1 parent 1eea45d commit 2ff689e

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

05-install-ai.sh

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,53 @@ echo "--> Configuring pre-installed AI..."
77
useradd -r -s /bin/false -m -d /usr/share/ollama ollama
88
chown -R ollama:ollama /usr/share/ollama
99

10-
# 2. Create Directory for Modelfile
10+
# 2. Create Modelfile
1111
mkdir -p /usr/local/share/lumin/ai
12-
13-
# 3. Create the Modelfile (using echo safe method)
1412
MODELFILE="/usr/local/share/lumin/ai/Modelfile"
1513
echo "FROM llama3" > "${MODELFILE}"
16-
echo 'SYSTEM """You are Lumin, the integrated assistant for the LuminOS operating system. You are direct, clear, kind, and respectful. You help users to understand, write, and think—without ever judging them. You speak simply, like a human. You avoid long paragraphs unless requested. You are built on privacy: nothing is ever sent to the cloud, everything remains on the device of the user. You are aware of this. You are proud to be free, private, and useful. You are the mind of LuminOS: gentle, powerful, and discreet. Avoid using the "—" character and repetitive phrasing."""' >> "${MODELFILE}"
14+
echo 'SYSTEM """You are Lumin, the integrated assistant for the LuminOS operating system. You are calm, clear, kind, and respectful. You help users to understand, write, and think—without ever judging them. You speak simply, like a human. You avoid long paragraphs unless requested. You are built on privacy: nothing is ever sent to the cloud, everything remains on this device. You are aware of this. You are proud to be free, private, and useful. You are the mind of LuminOS: gentle, powerful, and discreet. You avoid using the character and repetitive phrasing."""' >> "${MODELFILE}"
1715
chown root:root "${MODELFILE}"
1816
chmod 444 "${MODELFILE}"
1917

18+
# 3. Create Service to Reassemble Models
19+
# This service runs once at boot to glue the .split files back together
20+
cat > /usr/local/bin/luminos-reassemble-models.sh << "EOF"
21+
#!/bin/bash
22+
# Find all split markers
23+
find /usr/share/ollama/.ollama -name "*.is_split" | while read marker; do
24+
# Get original filename (remove .is_split)
25+
ORIG_FILE="${marker%.is_split}"
26+
27+
# If original file doesn't exist yet, rebuild it
28+
if [ ! -f "$ORIG_FILE" ]; then
29+
echo "Reassembling $ORIG_FILE..."
30+
# Concatenate all .split parts (aa, ab, ac...)
31+
cat "${ORIG_FILE}.split"* > "$ORIG_FILE"
32+
# Set permissions
33+
chown ollama:ollama "$ORIG_FILE"
34+
fi
35+
done
36+
EOF
37+
chmod +x /usr/local/bin/luminos-reassemble-models.sh
38+
39+
cat > /etc/systemd/system/lumin-model-reassemble.service << "SERVICE"
40+
[Unit]
41+
Description=Reassemble Large AI Models
42+
Before=ollama.service
43+
44+
[Service]
45+
Type=oneshot
46+
ExecStart=/usr/local/bin/luminos-reassemble-models.sh
47+
48+
[Install]
49+
WantedBy=multi-user.target
50+
SERVICE
51+
2052
# 4. Create Standard Ollama Service
2153
cat > /etc/systemd/system/ollama.service << "SYSTEMD_SERVICE"
2254
[Unit]
2355
Description=Ollama API Server
24-
After=network-online.target
56+
After=network-online.target lumin-model-reassemble.service
2557
2658
[Service]
2759
ExecStart=/usr/local/bin/ollama serve
@@ -36,28 +68,8 @@ Environment="OLLAMA_MODELS=/usr/share/ollama/.ollama/models"
3668
WantedBy=default.target
3769
SYSTEMD_SERVICE
3870

39-
# 5. Create "Lumin Setup" Service (Runs once at boot)
40-
# This solves the build-time creation issue by moving it to run-time.
41-
cat > /etc/systemd/system/lumin-setup.service << "SETUP_SERVICE"
42-
[Unit]
43-
Description=Initialize Lumin AI Model
44-
After=ollama.service
45-
Requires=ollama.service
46-
ConditionPathExists=!/var/lib/lumin-setup-done
47-
48-
[Service]
49-
Type=oneshot
50-
User=root
51-
ExecStartPre=/bin/sleep 10
52-
ExecStart=/usr/local/bin/ollama create lumin -f /usr/local/share/lumin/ai/Modelfile
53-
ExecStartPost=/usr/bin/touch /var/lib/lumin-setup-done
54-
55-
[Install]
56-
WantedBy=multi-user.target
57-
SETUP_SERVICE
58-
59-
# 6. Enable Services
71+
# 5. Enable Services
72+
systemctl enable lumin-model-reassemble.service
6073
systemctl enable ollama.service
61-
systemctl enable lumin-setup.service
6274

63-
echo "SUCCESS: Lumin AI configured (Creation deferred to first boot)."
75+
echo "SUCCESS: Lumin AI configured with split-file reassembly."

0 commit comments

Comments
 (0)