mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-07 23:43:54 +00:00
Add force flag to bypass broken packages upon installation
This commit is contained in:
@@ -45,6 +45,7 @@ const HostDetail = () => {
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||
const [showAllUpdates, setShowAllUpdates] = useState(false);
|
||||
const [activeTab, setActiveTab] = useState("host");
|
||||
const [forceInstall, setForceInstall] = useState(false);
|
||||
|
||||
const {
|
||||
data: host,
|
||||
@@ -1083,6 +1084,7 @@ const HostDetail = () => {
|
||||
const CredentialsModal = ({ host, isOpen, onClose }) => {
|
||||
const [showApiKey, setShowApiKey] = useState(false);
|
||||
const [activeTab, setActiveTab] = useState("quick-install");
|
||||
const [forceInstall, setForceInstall] = useState(false);
|
||||
const apiIdInputId = useId();
|
||||
const apiKeyInputId = useId();
|
||||
|
||||
@@ -1104,6 +1106,12 @@ const CredentialsModal = ({ host, isOpen, onClose }) => {
|
||||
return settings?.ignore_ssl_self_signed ? "-sk" : "-s";
|
||||
};
|
||||
|
||||
// Helper function to build installation URL with optional force flag
|
||||
const getInstallUrl = () => {
|
||||
const baseUrl = `${serverUrl}/api/v1/hosts/install`;
|
||||
return forceInstall ? `${baseUrl}?force=true` : baseUrl;
|
||||
};
|
||||
|
||||
const copyToClipboard = async (text) => {
|
||||
try {
|
||||
// Try modern clipboard API first
|
||||
@@ -1197,10 +1205,30 @@ const CredentialsModal = ({ host, isOpen, onClose }) => {
|
||||
Copy and run this command on the target host to securely install
|
||||
and configure the PatchMon agent:
|
||||
</p>
|
||||
|
||||
{/* Force Install Toggle */}
|
||||
<div className="mb-3">
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={forceInstall}
|
||||
onChange={(e) => setForceInstall(e.target.checked)}
|
||||
className="rounded border-secondary-300 dark:border-secondary-600 text-primary-600 focus:ring-primary-500 dark:focus:ring-primary-400 dark:bg-secondary-700"
|
||||
/>
|
||||
<span className="text-primary-800 dark:text-primary-200">
|
||||
Force install (bypass broken packages)
|
||||
</span>
|
||||
</label>
|
||||
<p className="text-xs text-primary-600 dark:text-primary-400 mt-1">
|
||||
Enable this if the target host has broken packages
|
||||
(CloudPanel, WHM, etc.) that block apt-get operations
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={`curl ${getCurlFlags()} ${serverUrl}/api/v1/hosts/install -H "X-API-ID: ${host.api_id}" -H "X-API-KEY: ${host.api_key}" | bash`}
|
||||
value={`curl ${getCurlFlags()} ${getInstallUrl()} -H "X-API-ID: ${host.api_id}" -H "X-API-KEY: ${host.api_key}" | bash`}
|
||||
readOnly
|
||||
className="flex-1 px-3 py-2 border border-primary-300 dark:border-primary-600 rounded-md bg-white dark:bg-secondary-800 text-sm font-mono text-secondary-900 dark:text-white"
|
||||
/>
|
||||
@@ -1208,7 +1236,7 @@ const CredentialsModal = ({ host, isOpen, onClose }) => {
|
||||
type="button"
|
||||
onClick={() =>
|
||||
copyToClipboard(
|
||||
`curl ${getCurlFlags()} ${serverUrl}/api/v1/hosts/install -H "X-API-ID: ${host.api_id}" -H "X-API-KEY: ${host.api_key}" | bash`,
|
||||
`curl ${getCurlFlags()} ${getInstallUrl()} -H "X-API-ID: ${host.api_id}" -H "X-API-KEY: ${host.api_key}" | bash`,
|
||||
)
|
||||
}
|
||||
className="btn-primary flex items-center gap-1"
|
||||
|
||||
@@ -22,6 +22,7 @@ const Integrations = () => {
|
||||
const [new_token, setNewToken] = useState(null);
|
||||
const [show_secret, setShowSecret] = useState(false);
|
||||
const [server_url, setServerUrl] = useState("");
|
||||
const [force_proxmox_install, setForceProxmoxInstall] = useState(false);
|
||||
|
||||
// Form state
|
||||
const [form_data, setFormData] = useState({
|
||||
@@ -34,6 +35,12 @@ const Integrations = () => {
|
||||
|
||||
const [copy_success, setCopySuccess] = useState({});
|
||||
|
||||
// Helper function to build Proxmox enrollment URL with optional force flag
|
||||
const getProxmoxUrl = () => {
|
||||
const baseUrl = `${server_url}/api/v1/auto-enrollment/proxmox-lxc?token_key=${new_token.token_key}&token_secret=${new_token.token_secret}`;
|
||||
return force_proxmox_install ? `${baseUrl}&force=true` : baseUrl;
|
||||
};
|
||||
|
||||
const handleTabChange = (tabName) => {
|
||||
setActiveTab(tabName);
|
||||
};
|
||||
@@ -664,10 +671,32 @@ const Integrations = () => {
|
||||
Run this command on your Proxmox host to download and
|
||||
execute the enrollment script:
|
||||
</p>
|
||||
|
||||
{/* Force Install Toggle */}
|
||||
<div className="mb-3">
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={force_proxmox_install}
|
||||
onChange={(e) =>
|
||||
setForceProxmoxInstall(e.target.checked)
|
||||
}
|
||||
className="rounded border-secondary-300 dark:border-secondary-600 text-primary-600 focus:ring-primary-500 dark:focus:ring-primary-400 dark:bg-secondary-700"
|
||||
/>
|
||||
<span className="text-secondary-800 dark:text-secondary-200">
|
||||
Force install (bypass broken packages in containers)
|
||||
</span>
|
||||
</label>
|
||||
<p className="text-xs text-secondary-600 dark:text-secondary-400 mt-1">
|
||||
Enable this if your LXC containers have broken packages
|
||||
(CloudPanel, WHM, etc.) that block apt-get operations
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={`curl -s "${server_url}/api/v1/auto-enrollment/proxmox-lxc?token_key=${new_token.token_key}&token_secret=${new_token.token_secret}" | bash`}
|
||||
value={`curl -s "${getProxmoxUrl()}" | bash`}
|
||||
readOnly
|
||||
className="flex-1 px-3 py-2 border border-secondary-300 dark:border-secondary-600 rounded-md bg-secondary-50 dark:bg-secondary-900 text-secondary-900 dark:text-white font-mono text-xs"
|
||||
/>
|
||||
@@ -675,7 +704,7 @@ const Integrations = () => {
|
||||
type="button"
|
||||
onClick={() =>
|
||||
copy_to_clipboard(
|
||||
`curl -s "${server_url}/api/v1/auto-enrollment/proxmox-lxc?token_key=${new_token.token_key}&token_secret=${new_token.token_secret}" | bash`,
|
||||
`curl -s "${getProxmoxUrl()}" | bash`,
|
||||
"curl-command",
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user