mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 18:50:38 +03:00
gpupdate-setup: get default localpolicy from /etc/altlinux-release
This commit is contained in:
parent
633637bee2
commit
75485eeb62
30
dist/gpupdate-setup
vendored
30
dist/gpupdate-setup
vendored
@ -23,12 +23,29 @@ import sys
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
import re
|
||||
|
||||
def command(args):
|
||||
try:
|
||||
subprocess.check_call(args.split())
|
||||
except:
|
||||
print ('command: \'%s\' error' % args)
|
||||
|
||||
def get_default_localpolicy():
|
||||
localpolicy = 'workstation'
|
||||
|
||||
try:
|
||||
release = '/etc/altlinux-release'
|
||||
if os.path.isfile(release):
|
||||
f = open(release)
|
||||
s = f.readline()
|
||||
if re.search('server', s, re.I):
|
||||
localpolicy = 'server'
|
||||
except:
|
||||
pass
|
||||
|
||||
return localpolicy
|
||||
|
||||
def parse_arguments():
|
||||
'''
|
||||
Parse CLI arguments.
|
||||
@ -98,6 +115,9 @@ def get_policy_variants():
|
||||
|
||||
return general_listing
|
||||
|
||||
def validate_policy_name(policy_name):
|
||||
return policy_name in [os.path.basename(d) for d in get_policy_variants()]
|
||||
|
||||
def get_status():
|
||||
systemd_unit_link = '/etc/systemd/system/multi-user.target.wants/gpupdate.service'
|
||||
|
||||
@ -123,14 +143,16 @@ def disable_gp():
|
||||
command('systemctl disable gpupdate.service')
|
||||
command('systemctl --global --user disable gpupdate-user.service')
|
||||
|
||||
def enable_gp(policy_name='default'):
|
||||
def enable_gp(policy_name):
|
||||
policy_dir = '/usr/share/local-policy'
|
||||
etc_policy_dir = '/etc/local-policy'
|
||||
target_policy_name = 'default'
|
||||
target_policy_name = get_default_localpolicy()
|
||||
if policy_name:
|
||||
target_policy_name = policy_name
|
||||
if validate_policy_name(policy_name):
|
||||
target_policy_name = policy_name
|
||||
|
||||
default_policy_name = os.path.join(policy_dir, policy_name)
|
||||
print (target_policy_name)
|
||||
default_policy_name = os.path.join(policy_dir, target_policy_name)
|
||||
active_policy_name = os.path.join(etc_policy_dir, 'active')
|
||||
|
||||
if not os.path.isdir(etc_policy_dir):
|
||||
|
Loading…
x
Reference in New Issue
Block a user