39 lines
No EOL
1.6 KiB
Python
39 lines
No EOL
1.6 KiB
Python
"""
|
|
Initramfs command for apt-ostree CLI.
|
|
|
|
This module implements the 'initramfs' command for managing initramfs
|
|
using the apt-ostree daemon.
|
|
"""
|
|
|
|
import argparse
|
|
from typing import Any
|
|
|
|
def setup_parser(subparsers: argparse._SubParsersAction):
|
|
initramfs_parser = subparsers.add_parser('initramfs', help='Manage initramfs')
|
|
initramfs_parser.add_argument('action', choices=['enable', 'disable', 'regenerate'], help='Action to perform')
|
|
|
|
def run(cli: Any, args: argparse.Namespace) -> int:
|
|
try:
|
|
if args.action == 'enable':
|
|
print("Enabling initramfs regeneration...")
|
|
result = cli.call_daemon_method('EnableInitramfs')
|
|
elif args.action == 'disable':
|
|
print("Disabling initramfs regeneration...")
|
|
result = cli.call_daemon_method('DisableInitramfs')
|
|
elif args.action == 'regenerate':
|
|
print("Regenerating initramfs...")
|
|
result = cli.call_daemon_method('RegenerateInitramfs')
|
|
else:
|
|
print("Error: Invalid action for initramfs command")
|
|
return 1
|
|
if result.get('success'):
|
|
print(f"✓ Initramfs action '{args.action}' completed successfully")
|
|
return 0
|
|
else:
|
|
print(f"✗ Initramfs action '{args.action}' failed: {result.get('error', 'Unknown error')}")
|
|
cli.logger.error(f"Initramfs action '{args.action}' failed: {result.get('error', 'Unknown error')}")
|
|
return 1
|
|
except Exception as e:
|
|
print(f"Error managing initramfs: {e}")
|
|
cli.logger.error(f"Error managing initramfs: {e}")
|
|
return 1 |