Added sleep states for FreeBSD

This commit is contained in:
Gregory Ballantine 2023-05-02 21:34:02 -06:00
parent 8536e32204
commit 2923d4d3f4
3 changed files with 59 additions and 33 deletions

View File

@ -1,38 +1,10 @@
{% from "system/map.jinja" import system_settings with context %} {% from "system/map.jinja" import system_settings with context %}
{% set settings = system_settings['sleep'] %} {% set settings = system_settings['sleep'] %}
{% if settings.disable %} {% if salt['grains']['get']('os_family') == 'FreeBSD' %}
# Disable common sleep states include:
disable_sleep_target: - system.sleep.freebsd
service.masked:
- name: 'sleep.target'
disable_suspend_target:
service.masked:
- name: 'suspend.target'
disable_hibernate_target:
service.masked:
- name: 'hibernate.target'
disable_hybrid-sleep_target:
service.masked:
- name: 'hybrid-sleep.target'
{% else %} {% else %}
# Enable sleep states include:
enable_sleep_target: - system.sleep.linux
service.unmasked:
- name: 'sleep.target'
enable_suspend_target:
service.unmasked:
- name: 'suspend.target'
enable_hibernate_target:
service.unmasked:
- name: 'hibernate.target'
enable_hybrid-sleep_target:
service.unmasked:
- name: 'hybrid-sleep.target'
{% endif %} {% endif %}

16
system/sleep/freebsd.sls Normal file
View File

@ -0,0 +1,16 @@
{% from "system/map.jinja" import system_settings with context %}
{% set settings = system_settings['sleep'] %}
{% if settings.disable %}
# Disable sleep via sysrc
sleep_disable_sysrc:
sysrc:
- name: 'kern.suspend_blocked'
- value: '1'
{% else %}
# Enable sleep via sysrc
sleep_enable_sysrc:
sysrc:
- name: 'kern.suspend_blocked'
- value: '0'
{% endif %}

38
system/sleep/linux.sls Normal file
View File

@ -0,0 +1,38 @@
{% from "system/map.jinja" import system_settings with context %}
{% set settings = system_settings['sleep'] %}
{% if settings.disable %}
# Disable common sleep states
disable_sleep_target:
service.masked:
- name: 'sleep.target'
disable_suspend_target:
service.masked:
- name: 'suspend.target'
disable_hibernate_target:
service.masked:
- name: 'hibernate.target'
disable_hybrid-sleep_target:
service.masked:
- name: 'hybrid-sleep.target'
{% else %}
# Enable sleep states
enable_sleep_target:
service.unmasked:
- name: 'sleep.target'
enable_suspend_target:
service.unmasked:
- name: 'suspend.target'
enable_hibernate_target:
service.unmasked:
- name: 'hibernate.target'
enable_hybrid-sleep_target:
service.unmasked:
- name: 'hybrid-sleep.target'
{% endif %}