Cleanup glean.sh variable names

Rename things to be slightly clearer by removing references to
glean.sh from various variable names and subsitutions.

Change-Id: Ib05220cd2de5a59b608c3e94e26ea44a89a77c49
This commit is contained in:
Ian Wienand 2021-03-23 14:12:07 +11:00
parent 3cb334dbbb
commit dfbb27b886
8 changed files with 25 additions and 36 deletions

View File

@ -7,7 +7,7 @@ After=local-fs.target
[Service] [Service]
Type=oneshot Type=oneshot
User=root User=root
ExecStart=%%GLEANSH_PATH%%/glean-early.sh --debug ExecStart=%%GLEAN_SCRIPTS_DIR%%/glean-early.sh --debug
RemainAfterExit=true RemainAfterExit=true
StandardOutput=journal+console StandardOutput=journal+console

View File

@ -8,7 +8,7 @@ Wants=glean-early.service
[Service] [Service]
Type=oneshot Type=oneshot
User=root User=root
ExecStart=%%GLEANSH_PATH%%/python-glean --distro networkd %%EXTRA_ARGS%% ExecStart=%%GLEAN_SCRIPTS_DIR%%/python-glean --distro networkd %%EXTRA_ARGS%%
RemainAfterExit=true RemainAfterExit=true
[Install] [Install]

View File

@ -13,7 +13,7 @@ ConditionPathExists=!/etc/sysconfig/network/ifcfg-%I
Type=oneshot Type=oneshot
User=root User=root
Environment="ARGS=--interface %I" Environment="ARGS=--interface %I"
ExecStart=%%GLEANSH_PATH%%/python-glean --use-nm --debug %%EXTRA_ARGS%% $ARGS ExecStart=%%GLEAN_SCRIPTS_DIR%%/python-glean --use-nm --debug %%EXTRA_ARGS%% $ARGS
RemainAfterExit=true RemainAfterExit=true
StandardOutput=journal+console StandardOutput=journal+console

View File

@ -11,4 +11,4 @@ start on starting networking
task task
exec %%GLEANSH_PATH%%/glean-legacy.sh %%EXTRA_ARGS%% exec %%GLEAN_SCRIPTS_DIR%%/glean-legacy.sh %%EXTRA_ARGS%%

View File

@ -12,7 +12,7 @@
NAME=glean NAME=glean
INIT_NAME=/etc/init.d/${NAME} INIT_NAME=/etc/init.d/${NAME}
SCRIPT_NAME=%%GLEANSH_PATH%%/glean-legacy.sh SCRIPT_NAME=%%GLEAN_SCRIPTS_DIR%%/glean-legacy.sh
[ -x $SCRIPT_NAME ] || exit 0 [ -x $SCRIPT_NAME ] || exit 0

View File

@ -5,7 +5,7 @@
description="basic instance setup" description="basic instance setup"
start() { start() {
%%GLEANSH_PATH%%/glean-legacy.sh %%GLEAN_SCRIPTS_DIR%%/glean-legacy.sh
eend 0 eend 0
} }

View File

@ -16,7 +16,7 @@ ConditionPathExists=!/etc/network/interfaces.d/%I.cfg
Type=oneshot Type=oneshot
User=root User=root
Environment="ARGS=--interface %I" Environment="ARGS=--interface %I"
ExecStartPre=%%GLEANSH_PATH%%/python-glean %%EXTRA_ARGS%% ${ARGS} ExecStartPre=%%GLEAN_SCRIPTS_DIR%%/python-glean %%EXTRA_ARGS%% ${ARGS}
ExecStart=/sbin/ifup %I ExecStart=/sbin/ifup %I
RemainAfterExit=true RemainAfterExit=true

View File

@ -23,9 +23,7 @@ import sys
log = logging.getLogger("glean-install") log = logging.getLogger("glean-install")
def _find_gleansh_path(): def _find_scripts_dir():
# glean.sh is a script installed by setup.cfg as a sibling to this
# script
p = pkg_resources.resource_filename(__name__, "init") p = pkg_resources.resource_filename(__name__, "init")
return p return p
@ -45,8 +43,7 @@ def install(source_file, target_file, mode='0755', replacements=dict()):
log.info("Installing %s -> %s" % (source_file, target_file)) log.info("Installing %s -> %s" % (source_file, target_file))
script_dir = os.path.join( script_dir = _find_scripts_dir()
os.path.dirname(os.path.realpath(__file__)), 'init')
cmd = ('install -D -g root -o root' cmd = ('install -D -g root -o root'
' -m {mode} {source_file} {target_file}').format( ' -m {mode} {source_file} {target_file}').format(
@ -94,7 +91,7 @@ def main():
"it will be left unconfigured.") "it will be left unconfigured.")
args = parser.parse_args() args = parser.parse_args()
p = _find_gleansh_path() p = _find_scripts_dir()
extra_args = '--no-dhcp-fallback' if args.no_dhcp_fallback else '' extra_args = '--no-dhcp-fallback' if args.no_dhcp_fallback else ''
if args.quiet: if args.quiet:
@ -102,19 +99,23 @@ def main():
else: else:
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
# Write the path of the currently executing interpreter into a replacements = {
# file alongside glean.sh. This means glean.sh can call the 'INTERP': sys.executable,
'GLEAN_SCRIPTS_DIR': p,
'EXTRA_ARGS': extra_args,
}
# Write the path of the currently executing interpreter into the
# scripts dir. This means glean shell scripts can call the
# sibling python-glean and know that it's using the glean we # sibling python-glean and know that it's using the glean we
# installed, even in a virtualenv etc. # installed, even in a virtualenv etc.
install('python-glean.template', os.path.join(p, 'python-glean'), install('python-glean.template', os.path.join(p, 'python-glean'),
mode='0755', replacements={'INTERP': sys.executable}) mode='0755', replacements=replacements)
# needs to go first because gentoo can have systemd along side openrc # needs to go first because gentoo can have systemd along side openrc
if os.path.exists('/etc/gentoo-release'): if os.path.exists('/etc/gentoo-release'):
log.info('installing openrc services') log.info('installing openrc services')
install('glean.openrc', '/etc/init.d/glean', install('glean.openrc', '/etc/init.d/glean', replacements=replacements)
replacements={'GLEANSH_PATH': p,
'EXTRA_ARGS': extra_args})
# Needs to check for the presence of systemd and systemctl # Needs to check for the presence of systemd and systemctl
# as apparently some packages may stage systemd init files # as apparently some packages may stage systemd init files
# when systemd is not present. # when systemd is not present.
@ -127,22 +128,18 @@ def main():
or os.path.exists('/bin/systemctl'))): or os.path.exists('/bin/systemctl'))):
log.info("Installing systemd services") log.info("Installing systemd services")
log.info("glean.sh in %s" % p)
log.info("Install early service") log.info("Install early service")
install( install(
'glean-early.service', 'glean-early.service',
'/usr/lib/systemd/system/glean-early.service', '/usr/lib/systemd/system/glean-early.service',
mode='0644', mode='0644', replacements=replacements)
replacements={'GLEANSH_PATH': p})
subprocess.call(['systemctl', 'enable', 'glean-early.service']) subprocess.call(['systemctl', 'enable', 'glean-early.service'])
if os.path.exists('/etc/gentoo-release'): if os.path.exists('/etc/gentoo-release'):
install( install(
'glean-networkd.service', 'glean-networkd.service',
'/lib/systemd/system/glean.service', '/lib/systemd/system/glean.service',
mode='0644', mode='0644', replacements=replacements)
replacements={'GLEANSH_PATH': p,
'EXTRA_ARGS': extra_args})
subprocess.call(['systemctl', 'enable', 'glean.service']) subprocess.call(['systemctl', 'enable', 'glean.service'])
else: else:
log.info("Installing %s NetworkManager support" % log.info("Installing %s NetworkManager support" %
@ -154,9 +151,7 @@ def main():
install( install(
service_file, service_file,
'/usr/lib/systemd/system/glean@.service', '/usr/lib/systemd/system/glean@.service',
mode='0644', mode='0644', replacements=replacements)
replacements={'GLEANSH_PATH': p,
'EXTRA_ARGS': extra_args})
install( install(
'glean-udev.rules', 'glean-udev.rules',
'/etc/udev/rules.d/99-glean.rules', '/etc/udev/rules.d/99-glean.rules',
@ -181,19 +176,13 @@ def main():
elif os.path.exists('/etc/init'): elif os.path.exists('/etc/init'):
log.info("Installing upstart services") log.info("Installing upstart services")
install('glean.conf', '/etc/init/glean.conf', install('glean.conf', '/etc/init/glean.conf',
replacements={ replacements=replacements)
'GLEANSH_PATH': p,
'EXTRA_ARGS': extra_args
})
elif os.path.exists('/sbin/rc-update'): elif os.path.exists('/sbin/rc-update'):
subprocess.call(['rc-update', 'add', 'glean', 'boot']) subprocess.call(['rc-update', 'add', 'glean', 'boot'])
else: else:
log.info("Installing sysv services") log.info("Installing sysv services")
install('glean.init', '/etc/init.d/glean', install('glean.init', '/etc/init.d/glean',
replacements={ replacements=replacements)
'GLEANSH_PATH': p,
'EXTRA_ARGS': extra_args
})
os.system('update-rc.d glean defaults') os.system('update-rc.d glean defaults')