qvm-start-daemon: allow starting only if service enabled

This commit is contained in:
Frédéric Pierret (fepitre) 2020-01-17 15:04:33 +01:00
parent f7fa577c47
commit 05e479cf92
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2
2 changed files with 11 additions and 1 deletions

View File

@ -5,4 +5,3 @@ Icon=qubes
Exec=qvm-start-daemon --all --watch
Terminal=false
Type=Application
NotShowIn=X-QUBES

View File

@ -26,6 +26,7 @@ import subprocess
import asyncio
import re
import functools
import sys
import xcffib
import xcffib.xproto # pylint: disable=unused-import
@ -460,10 +461,20 @@ parser.add_argument('--pidfile', action='store', default=pidfile_path,
parser.add_argument('--notify-monitor-layout', action='store_true',
help='Notify running instance in --watch mode'
' about changed monitor layout')
# Add it for the help only
parser.add_argument('--force', action='store_true', default=False,
help='Force running daemon without enabled services'
' \'guivm-gui-agent\' or \'audiovm-audio-agent\'')
def main(args=None):
""" Main function of qvm-start-daemon tool"""
only_if_service_enabled = ['guivm-gui-agent', 'audiovm-audio-agent']
enabled_services = [service for service in only_if_service_enabled if
os.path.exists('/var/run/qubes-service/%s' % service)]
if not enabled_services and '--force' not in sys.argv:
print(parser.format_help())
return
args = parser.parse_args(args)
if args.watch and not args.all_domains:
parser.error('--watch option must be used with --all')