Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: address feedback for Fedora package #36

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .tito/packages/smfc

This file was deleted.

4 changes: 2 additions & 2 deletions Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ docker run \
-v /run:/run:ro \
-v /etc/timezone:/etc/timezone:ro
-v /etc/localtime:/etc/localtime:ro
-v /opt/smfc/smfc.conf:/opt/smfc/smfc.conf:ro \
-v /etc/smfc/smfc.conf:/etc/smfc/smfc.conf:ro \
-e SMFC_ARGS="-l 3" \
petersulyok/smfc
```
Expand All @@ -58,7 +58,7 @@ services:
volumes:
- /dev:/dev:ro
- /run:/run:ro
- /opt/smfc/smfc.conf:/opt/smfc/smfc.conf:ro
- /etc/smfc/smfc.conf:/etc/smfc/smfc.conf:ro
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN <<EOT
apk del .depends
EOT

WORKDIR /opt/smfc
WORKDIR /etc/smfc
ADD --chmod=755 src/smfc.py smfc.py

CMD /opt/smfc/smfc.py -c /opt/smfc/smfc.conf $SMFC_ARGS
CMD /usr/bin/smfc -c /etc/smfc/smfc.conf $SMFC_ARGS
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ You can also run `smfc` in docker, see more details in [Docker.md](Docker.md).
1. Set up the IPMI threshold values for your fans (see script `ipmi/set_ipmi_threshold.sh`).
2. Optional: enable advanced power management features for your CPU and SATA hard disks for lower power consumption, heat generation and fan noise.
3. Load kernel modules (`coretemp/k10temp` and `drivetemp`).
4. Install the service with running the script `install.sh`.
5. Edit the configuration file `/opt/smfc/smfc.conf` and command line options in `/etc/default/smfc`.
6. Start the `systemd` service
7. Check results in system log
8. Leave a feedback in [issue #19](https://github.com/petersulyok/smfc/issues/19)
4. Add distro specific repository for smfc.
5. Install the service using your package manager.
6. Edit the configuration file `/etc/smfc/smfc.conf` and command line options in `/etc/default/smfc`.
7. Start the `systemd` service
8. Check results in system log
9. Leave a feedback in [issue #19](https://github.com/petersulyok/smfc/issues/19)

## Details
### 1. How does it work?
Expand Down Expand Up @@ -275,13 +276,13 @@ For the installation you need a root user. The default installation script `inst
|----------------|-----------------------|---------------------------------|
| `smsc.service` | `/etc/systemd/system` | systemd service definition file |
| `smsc` | `/etc/default` | service command line options |
| `smsc.py` | `/opt/smfc` | service (python program) |
| `smsc.conf` | `/opt/smfc` | service configuration file |
| `smsc.py` | `/etc/smfc` | service (python program) |
| `smsc.conf` | `/etc/smfc` | service configuration file |

but you can use freely any other folders too. The service has the following command line options:

root@home:~/opt/smfc# ./smfc.py --help
usage: smfc.py [-h] [-c CONFIG_FILE] [-v] [-l {0,1,2,3,4}] [-o {0,1,2}]
root@home:~/etc/smfc# smfc --help
usage: smfc [-h] [-c CONFIG_FILE] [-v] [-l {0,1,2,3,4}] [-o {0,1,2}]

optional arguments:
-h, --help show this help message and exit
Expand All @@ -293,7 +294,7 @@ but you can use freely any other folders too. The service has the following comm
You may configure logging output and logging level here and these options can be specified in `/etc/default/smfc`in a persistent way.

### 11. Configuration file
Edit `/opt/smfc/smfc.conf` and specify your configuration parameters here:
Edit `/etc/smfc/smfc.conf` and specify your configuration parameters here:

#
# smfc.conf
Expand Down Expand Up @@ -420,21 +421,20 @@ This `systemd` service can be started and stopped in the standard way. Do not fo
● smfc.service - Super Micro Fan Control
Loaded: loaded (/etc/systemd/system/smfc.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-09-17 23:28:10 CEST; 1 day 19h ago
Main PID: 1064180 (smfc.py)
Main PID: 1064180 (smfc)
Tasks: 1 (limit: 38371)
Memory: 7.4M
CPU: 41.917s
CGroup: /system.slice/smfc.service
└─1064180 /usr/bin/python3 /opt/smfc/smfc.py -c /opt/smfc/smfc.conf -l 2
└─1064180 /usr/bin/python3 /usr/bin/smfc -c /etc/smfc/smfc.conf -l 2

Sep 19 17:12:39 home smfc.service[1064180]: CPU zone: new level > 39.0C > [T:40.0C/L:61%]
Sep 19 17:12:42 home smfc.service[1064180]: CPU zone: new level > 33.0C > [T:35.0C/L:48%]
Sep 19 17:48:14 home smfc.service[1064180]: CPU zone: new level > 38.0C > [T:40.0C/L:61%]

If you are testing your configuration, you can start `smfc.py` directly in a terminal. Logging to the standard output and debug log level are useful in this case:
If you are testing your configuration, you can start `smfc` directly in a terminal. Logging to the standard output and debug log level are useful in this case:

cd /opt
sudo smfc.py -o 0 -l 3
sudo smfc -o 0 -l 3

### 13. Checking result and monitoring logs
All messages will be logged to the specific output and the specific level.
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
volumes:
- /dev:/dev:ro
- /run:/run:ro
- /opt/smfc/smfc.conf:/opt/smfc/smfc.conf:ro
- /etc/smfc/smfc.conf:/etc/smfc/smfc.conf:ro
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
2 changes: 1 addition & 1 deletion docker/docker-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ docker run \
-v /run:/run:ro \
-v /etc/timezone:/etc/timezone:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /opt/smfc/smfc.conf:/opt/smfc/smfc.conf:ro \
-v /etc/smfc/smfc.conf:/etc/smfc/smfc.conf:ro \
-e SMFC_ARGS="-l 3" \
petersulyok/smfc
56 changes: 0 additions & 56 deletions install.sh

This file was deleted.

45 changes: 44 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
[build-system]
requires = ["setuptools", "pytest"]
build-backend = "setuptools.build_meta"

[project]
name = "smfc"
description = "Super Micro Fan Control for Linux"
readme = "README.md"
version = "3.5.0"
authors = [
{ name = "Peter Sulyok", email = "[email protected]" }
]
requires-python = ">=3.8"
keywords = ["supermicro", "linux", "daemon", "fancontrol"]
license = {file = "LICENSE"}
dependencies = []
classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Topic :: System :: Hardware",
"Development Status :: 5 - Production/Stable"
]

[project.urls]
Homepage = "https://github.com/petersulyok/smfc"
Changelog = "https://github.com/petersulyok/smfc/releases"
Issues = "https://github.com/petersulyok/smfc/issues"

[project.optional-dependencies]
test = [
"pytest",
]

[project.scripts]
smfc = "smfc.cmd:main"

[tool.setuptools]
packages = ["smfc"]

# pytest options
[tool.pytest.ini_options]
pythonpath = "src"
filterwarnings = [ "default", "ignore::pytest.PytestCollectionWarning"]

# flake8 options
Expand Down
2 changes: 1 addition & 1 deletion src/smfc → resources/smfc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#

# Startup options for the service
OPTIONS="-c /opt/smfc/smfc.conf -l 3"
OPTIONS="-c /etc/smfc/smfc.conf -l 3"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[metadata]
name = smfc
version = 3.5.0

[options]
packages =
smfc

[options.entry_points]
console_scripts =
smfc = smfc.cmd:main
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from setuptools import setup

setup(
name='smfc',
version='3.5.0',
packages=['smfc'],
entry_points={
'console_scripts': [
'smfc = smfc.cmd:main',
]
}
)
80 changes: 47 additions & 33 deletions smfc.spec
Original file line number Diff line number Diff line change
@@ -1,61 +1,78 @@
%global forgeurl https://github.com/petersulyok/smfc

Version: 3.5.0

%global tag smfc-3.5.0-1
%forgemeta

Name: smfc
Version: 3.5.0
Release: 1%{?dist}
Summary: Super Micro Fan Control

License: GPL-3.0-or-later
URL: %{forgeurl}
URL: %{forgeurl}
Source: %{forgesource}

Requires: systemd
Requires: python3 >= 3.7
Requires: bash
Requires: ipmitool
Requires: ipmitool
Requires: python3-smfc
Recommends: smartmontools
Recommends: hddtemp

BuildRequires: systemd
BuildRequires: systemd-rpm-macros
BuildArch: noarch

%description
systemd service to control fans in CPU and HD zones with the help of IPMI on Super Micro X10-X13 (and some X9) motherboards.
%global _description %{expand:
systemd service to control fans in CPU and HD zones with the help of IPMI on
Super Micro X10-X13 (and some X9) motherboards.}

%description %_description

%package -n python3-%{name}
Summary: Python 3 bindings for the smfc library
BuildRequires: python3-devel

%global _python_module_description %{expand:
Python 3 bindings for the smfc library.}

%description -n python3-smfc %_python_module_description

%prep
%forgesetup

%build
# not needed, just copying files
%generate_buildrequires -n python3-smfc
%pyproject_buildrequires

%build -n python3-smfc
%pyproject_wheel

%install
mkdir -p %{buildroot}/opt/smfc
install -m 755 src/smfc.py %{buildroot}/opt/smfc/smfc.py
install -m 644 src/smfc.conf %{buildroot}/opt/smfc/smfc.conf
mkdir -p %{buildroot}/%{_sysconfdir}/default
install -m 644 src/smfc %{buildroot}/%{_sysconfdir}/default/smfc
mkdir -p %{buildroot}/%{_unitdir}
install -m 644 src/smfc.service %{buildroot}/%{_unitdir}/smfc.service
mkdir -p %{buildroot}/%{_presetdir}
install -m 644 src/smfc.preset %{buildroot}/%{_presetdir}/90-smfc.preset

%check
# not needed, just copying files
%pyproject_install
%pyproject_save_files smfc
install -Dm 644 resources/smfc.conf %{buildroot}%{_sysconfdir}/smfc/smfc.conf
install -Dm 644 resources/smfc %{buildroot}%{_sysconfdir}/default/smfc
install -Dm 644 systemd/smfc.service %{buildroot}%{_unitdir}/smfc.service
install -Dm 644 systemd/smfc.preset %{buildroot}%{_presetdir}/90-smfc.preset
install -Dm 644 systemd/modules-load.conf %{buildroot}%{_modulesloaddir}/smfc.conf

%check -n python3-smfc
%pytest

%files
/opt/smfc/smfc.py
%config(noreplace) /opt/smfc/smfc.conf
%config(noreplace) /etc/default/smfc
/usr/lib/systemd/system/smfc.service
/usr/lib/systemd/system-preset/90-smfc.preset
%{_bindir}/smfc
%config(noreplace) %{_sysconfdir}/smfc/smfc.conf
%config(noreplace) %{_sysconfdir}/default/smfc
%{_unitdir}/smfc.service
%{_presetdir}/90-smfc.preset
%{_modulesloaddir}/smfc.conf
%doc README.md
%license LICENSE

%files -n python3-smfc
%{python3_sitelib}/smfc/
%{python3_sitelib}/smfc-%{version}.dist-info/
%doc README.md
%license LICENSE

%post
%{_bindir}/systemctl restart systemd-modules-load.service
%systemd_post smfc.service

%preun
Expand All @@ -65,6 +82,3 @@ install -m 644 src/smfc.preset %{buildroot}/%{_presetdir}/90-smfc.preset
%systemd_postun_with_restart smfc.service

%changelog
* Wed Apr 03 2024 Ewout van Mansom <[email protected]> 3.5.0-1
- new package built with tito

5 changes: 5 additions & 0 deletions smfc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .logger import Log
from .bmc import Ipmi
from .fans import FanController
from .zones import CpuZone, HdZone
from .daemon import Service
Loading
Loading