コード例 #1
0
ファイル: raspberrypi.py プロジェクト: mbr/remand
def enable_hwrng():
    c = linux.enable_module('bcm2708_rng').changed
    c |= apt.install_packages(['rng-tools']).changed
    c |= systemd.enable_unit('rng-tools.service').changed
    c |= systemd.start_unit('rng-tools.service').changed

    return c
コード例 #2
0
def enable_auto_upgrades(boot_time='10min', unit_active_time='1d', start=True):
    timer_tpl = debian.templates.render('autoupdate.timer',
                                        boot_time=boot_time,
                                        unit_active_time=unit_active_time)

    c = False
    # install both timer and service
    c |= systemd.install_unit_string('autoupdate.timer', timer_tpl).changed
    c |= systemd.install_unit_file(debian.files['autoupdate.service']).changed

    # enable both timer and service
    c |= systemd.enable_unit('autoupdate.timer').changed
    c |= systemd.enable_unit('autoupdate.service').changed

    # start timer
    if start:
        c |= systemd.start_unit('autoupdate.timer').changed

    if c:
        return Changed(msg='Enabled automatic apt-updates via systemd timer')
    return Unchanged(
        msg='Automatic apt-updates via systemd timer already enabled')