hetzner_robot_rhai/examples/boot_management.rhai
2025-07-24 13:01:05 +02:00

73 lines
2.6 KiB
Plaintext

// --- Input Variables ---
// These variables should be updated by the user before running the script.
// Server number for boot management operations.
// Example: 1825193
let SERVER_NUMBER = 0; // Replace with an actual server number
// Operating System for enabling rescue mode.
// Example: "linux", "linux64", "freebsd64"
let RESCUE_OS = "linux";
// SSH Key Fingerprint to be used for rescue mode.
// Example: "13:dc:a2:1e:a9:d2:1d:a9:39:f4:44:c5:f1:00:ec:c7"
let SSH_KEY_FINGERPRINT = "YOUR_SSH_KEY_FINGERPRINT_HERE";
// --- Boot Management Operations ---
// 1. Get the boot configuration for a server
// This section retrieves the current boot configuration for a specified server.
// Uncomment the following lines and set SERVER_NUMBER to an actual server number to use.
/*
print("Fetching boot configuration for server number: " + SERVER_NUMBER);
try {
let boot_config = hetzner.get_boot_configuration(SERVER_NUMBER);
print("Boot configuration details:");
print(boot_config);
} catch (err) {
print("Error fetching boot configuration: " + err);
}
*/
// 2. Get the rescue boot configuration for a server
// This section retrieves the rescue boot configuration for a specified server.
// Uncomment the following lines and set SERVER_NUMBER to an actual server number to use.
/*
print("\nFetching rescue boot configuration for server number: " + SERVER_NUMBER);
try {
let rescue_config = hetzner.get_rescue_boot_configuration(SERVER_NUMBER);
print("Rescue boot configuration details:");
print(rescue_config);
} catch (err) {
print("Error fetching rescue boot configuration: " + err);
}
*/
// 3. Enable rescue mode
// This section enables rescue mode for a specified server with a chosen OS and SSH key.
// Uncomment the following lines and set SERVER_NUMBER, RESCUE_OS, and SSH_KEY_FINGERPRINT to actual values to use.
/*
print("\nAttempting to enable rescue mode for server number: " + SERVER_NUMBER + " with OS: " + RESCUE_OS);
try {
let enabled_rescue = hetzner.enable_rescue_mode(SERVER_NUMBER, RESCUE_OS, [SSH_KEY_FINGERPRINT]);
print("Rescue mode enabled successfully:");
print(enabled_rescue);
} catch (err) {
print("Error enabling rescue mode: " + err);
}
*/
// 4. Disable rescue mode
// This section disables rescue mode for a specified server.
// Uncomment the following lines and set SERVER_NUMBER to an actual server number to use.
/*
print("\nAttempting to disable rescue mode for server number: " + SERVER_NUMBER);
try {
let disabled_rescue = hetzner.disable_rescue_mode(SERVER_NUMBER);
print("Rescue mode disabled successfully:");
print(disabled_rescue);
} catch (err) {
print("Error disabling rescue mode: " + err);
}
*/