mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-05 22:43:23 +00:00
chore: clarify auto-update feature
This commit is contained in:
@@ -821,7 +821,7 @@ EOF
|
||||
success "Update sent successfully"
|
||||
echo "$response" | grep -o '"packagesProcessed":[0-9]*' | cut -d':' -f2 | xargs -I {} info "Processed {} packages"
|
||||
|
||||
# Check for auto-update instructions (look specifically in autoUpdate section)
|
||||
# Check for PatchMon agent update instructions (this updates the agent script, not system packages)
|
||||
if echo "$response" | grep -q '"autoUpdate":{'; then
|
||||
local auto_update_section=$(echo "$response" | grep -o '"autoUpdate":{[^}]*}')
|
||||
local should_update=$(echo "$auto_update_section" | grep -o '"shouldUpdate":true' | cut -d':' -f2)
|
||||
@@ -830,15 +830,15 @@ EOF
|
||||
local current_version=$(echo "$auto_update_section" | grep -o '"currentVersion":"[^"]*' | cut -d'"' -f4)
|
||||
local update_message=$(echo "$auto_update_section" | grep -o '"message":"[^"]*' | cut -d'"' -f4)
|
||||
|
||||
info "Auto-update detected: $update_message"
|
||||
info "PatchMon agent update detected: $update_message"
|
||||
info "Current version: $current_version, Latest version: $latest_version"
|
||||
|
||||
# Automatically run update-agent command
|
||||
info "Automatically updating agent to latest version..."
|
||||
# Automatically run update-agent command to update the PatchMon agent script
|
||||
info "Automatically updating PatchMon agent to latest version..."
|
||||
if "$0" update-agent; then
|
||||
success "Agent auto-update completed successfully"
|
||||
success "PatchMon agent update completed successfully"
|
||||
else
|
||||
warning "Agent auto-update failed, but data was sent successfully"
|
||||
warning "PatchMon agent update failed, but data was sent successfully"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -158,8 +158,8 @@ else
|
||||
warning "Initial package data failed, but agent is configured. You can run 'patchmon-agent.sh update' manually."
|
||||
fi
|
||||
|
||||
# Setup crontab for automatic updates
|
||||
info "⏰ Setting up automatic updates every $UPDATE_INTERVAL minutes..."
|
||||
# Setup crontab for automatic package status updates
|
||||
info "⏰ Setting up automatic package status update every $UPDATE_INTERVAL minutes..."
|
||||
if [[ $UPDATE_INTERVAL -eq 60 ]]; then
|
||||
# Hourly updates
|
||||
echo "0 * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1" | crontab -
|
||||
@@ -179,7 +179,7 @@ if [[ "$EXPECTED_VERSION" != "Unknown" ]]; then
|
||||
fi
|
||||
echo " • Config directory: /etc/patchmon/"
|
||||
echo " • Credentials file: /etc/patchmon/credentials"
|
||||
echo " • Automatic updates: Every $UPDATE_INTERVAL minutes via crontab"
|
||||
echo " • Status updates: Every $UPDATE_INTERVAL minutes via crontab"
|
||||
echo " • View logs: tail -f /var/log/patchmon-agent.log"
|
||||
echo ""
|
||||
echo "🔧 Manual commands:"
|
||||
|
||||
@@ -527,11 +527,11 @@ router.post(
|
||||
});
|
||||
});
|
||||
|
||||
// Check if auto-update is enabled and if there's a newer agent version available
|
||||
// Check if agent auto-update is enabled and if there's a newer version available
|
||||
let autoUpdateResponse = null;
|
||||
try {
|
||||
const settings = await prisma.settings.findFirst();
|
||||
// Check both global auto-update setting AND host-specific auto-update setting
|
||||
// Check both global agent auto-update setting AND host-specific agent auto-update setting
|
||||
if (settings?.auto_update && host.auto_update) {
|
||||
// Get current agent version from the request
|
||||
const currentAgentVersion = req.body.agentVersion;
|
||||
@@ -560,8 +560,8 @@ router.post(
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Auto-update check error:", error);
|
||||
// Don't fail the update if auto-update check fails
|
||||
console.error("Agent auto-update check error:", error);
|
||||
// Don't fail the update if agent auto-update check fails
|
||||
}
|
||||
|
||||
const response = {
|
||||
@@ -571,7 +571,7 @@ router.post(
|
||||
securityUpdates: securityCount,
|
||||
};
|
||||
|
||||
// Add auto-update response if available
|
||||
// Add agent auto-update response if available
|
||||
if (autoUpdateResponse) {
|
||||
response.autoUpdate = autoUpdateResponse;
|
||||
}
|
||||
@@ -1060,7 +1060,7 @@ router.delete(
|
||||
},
|
||||
);
|
||||
|
||||
// Toggle host auto-update setting
|
||||
// Toggle agent auto-update setting
|
||||
router.patch(
|
||||
"/:hostId/auto-update",
|
||||
authenticateToken,
|
||||
@@ -1068,7 +1068,7 @@ router.patch(
|
||||
[
|
||||
body("auto_update")
|
||||
.isBoolean()
|
||||
.withMessage("Auto-update must be a boolean"),
|
||||
.withMessage("Agent auto-update setting must be a boolean"),
|
||||
],
|
||||
async (req, res) => {
|
||||
try {
|
||||
@@ -1089,7 +1089,7 @@ router.patch(
|
||||
});
|
||||
|
||||
res.json({
|
||||
message: `Host auto-update ${auto_update ? "enabled" : "disabled"} successfully`,
|
||||
message: `Agent auto-update ${auto_update ? "enabled" : "disabled"} successfully`,
|
||||
host: {
|
||||
id: host.id,
|
||||
friendlyName: host.friendly_name,
|
||||
@@ -1097,8 +1097,8 @@ router.patch(
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Host auto-update toggle error:", error);
|
||||
res.status(500).json({ error: "Failed to toggle host auto-update" });
|
||||
console.error("Agent auto-update toggle error:", error);
|
||||
res.status(500).json({ error: "Failed to toggle agent auto-update" });
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -84,7 +84,7 @@ const HostDetail = () => {
|
||||
},
|
||||
});
|
||||
|
||||
// Toggle auto-update mutation
|
||||
// Toggle agent auto-update mutation (updates PatchMon agent script, not system packages)
|
||||
const toggleAutoUpdateMutation = useMutation({
|
||||
mutationFn: (auto_update) =>
|
||||
adminHostsAPI
|
||||
@@ -350,7 +350,7 @@ const HostDetail = () => {
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300 mb-1">
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300 mb-1.5">
|
||||
Friendly Name
|
||||
</p>
|
||||
<InlineEdit
|
||||
@@ -374,7 +374,7 @@ const HostDetail = () => {
|
||||
|
||||
{host.hostname && (
|
||||
<div>
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300">
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300 mb-1.5">
|
||||
System Hostname
|
||||
</p>
|
||||
<p className="font-medium text-secondary-900 dark:text-white font-mono text-sm">
|
||||
@@ -384,7 +384,7 @@ const HostDetail = () => {
|
||||
)}
|
||||
|
||||
<div>
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300">
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300 mb-1.5">
|
||||
Host Group
|
||||
</p>
|
||||
{host.host_groups ? (
|
||||
@@ -402,7 +402,7 @@ const HostDetail = () => {
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300">
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300 mb-1.5">
|
||||
Operating System
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -413,43 +413,38 @@ const HostDetail = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{host.agent_version && (
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300">
|
||||
Agent Version
|
||||
</p>
|
||||
<p className="font-medium text-secondary-900 dark:text-white text-sm">
|
||||
{host.agent_version}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-secondary-500 dark:text-secondary-300">
|
||||
Auto-update
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
toggleAutoUpdateMutation.mutate(!host.auto_update)
|
||||
}
|
||||
disabled={toggleAutoUpdateMutation.isPending}
|
||||
className={`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 ${
|
||||
host.auto_update
|
||||
? "bg-primary-600 dark:bg-primary-500"
|
||||
: "bg-secondary-200 dark:bg-secondary-600"
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${
|
||||
host.auto_update
|
||||
? "translate-x-5"
|
||||
: "translate-x-1"
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300 mb-1.5">
|
||||
Agent Version
|
||||
</p>
|
||||
<p className="font-medium text-secondary-900 dark:text-white text-sm">
|
||||
{host.agent_version || "Unknown"}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p className="text-xs text-secondary-500 dark:text-secondary-300 mb-1.5">
|
||||
Auto-update
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
toggleAutoUpdateMutation.mutate(!host.auto_update)
|
||||
}
|
||||
disabled={toggleAutoUpdateMutation.isPending}
|
||||
className={`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 ${
|
||||
host.auto_update
|
||||
? "bg-primary-600 dark:bg-primary-500"
|
||||
: "bg-secondary-200 dark:bg-secondary-600"
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${
|
||||
host.auto_update ? "translate-x-5" : "translate-x-1"
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -326,7 +326,12 @@ const Hosts = () => {
|
||||
{ id: "os", label: "OS", visible: true, order: 4 },
|
||||
{ id: "os_version", label: "OS Version", visible: false, order: 5 },
|
||||
{ id: "agent_version", label: "Agent Version", visible: true, order: 6 },
|
||||
{ id: "auto_update", label: "Auto-update", visible: true, order: 7 },
|
||||
{
|
||||
id: "auto_update",
|
||||
label: "Agent Auto-Update",
|
||||
visible: true,
|
||||
order: 7,
|
||||
},
|
||||
{ id: "status", label: "Status", visible: true, order: 8 },
|
||||
{ id: "updates", label: "Updates", visible: true, order: 9 },
|
||||
{ id: "last_update", label: "Last Update", visible: true, order: 10 },
|
||||
|
||||
Reference in New Issue
Block a user