mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-28 21:54:34 +02:00
jw.pkg.cmds.distro.CmdRebootRequired: Add class
Add the command distro.CmdRebootRequired, adding support for "distro reboot-required". The command exits with status code 1 if a reboot is required and 0 otherwise. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
5d95ca01ca
commit
79d40af558
4 changed files with 85 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from argparse import Namespace
|
||||
|
||||
from .....lib.log import *
|
||||
from ...Cmd import Cmd
|
||||
from ..BeRebootRequired import BeRebootRequired as Base
|
||||
|
||||
class RebootRequired(Base):
|
||||
|
||||
def __init__(self, parent: Cmd):
|
||||
super().__init__(parent)
|
||||
|
||||
async def run(self, args: Namespace):
|
||||
reboot_required = '/run/reboot_required'
|
||||
if os.path.exists(reboot_required):
|
||||
if args.verbose:
|
||||
log(NOTICE, f'Yes. {reboot_required} exists.')
|
||||
required_pkgs = '/run/reboot-required.pkgs'
|
||||
if os.path.exists(required_pkgs):
|
||||
with open(required_pkgs, 'r') as f:
|
||||
content = f.read()
|
||||
print(f'-- From {required_pkgs}:')
|
||||
print(content.strip())
|
||||
return 1
|
||||
if args.verbose:
|
||||
log(NOTICE, f'No. {reboot_required} doesn\'t exist.')
|
||||
return 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue