|
| 1 | +Name: mbpfan |
| 2 | +URL: https://github.com/dgraziotin/mbpfan |
| 3 | +License: GPLv3 |
| 4 | +Group: System Environment/Daemons |
| 5 | +Version: %{SOURCE_VERSION} |
| 6 | +Release: 1 |
| 7 | +Summary: A simple daemon to control fan speed on all MacBook/MacBook Pros (probably all Apple computers) for Linux 3.x.x and 4.x.x |
| 8 | +Source: v%{version}.tar.gz |
| 9 | + |
| 10 | +%description |
| 11 | +This is an enhanced version of Allan McRae mbpfan |
| 12 | + |
| 13 | +mbpfan is a daemon that uses input from coretemp module and sets the fan speed using the applesmc module. This enhanced version assumes any number of processors and fans (max. 10). |
| 14 | + |
| 15 | +It only uses the temperatures from the processors as input. |
| 16 | +It requires coretemp and applesmc kernel modules to be loaded. |
| 17 | +It requires root use |
| 18 | +It daemonizes or stays in foreground |
| 19 | +Verbose mode for both syslog and stdout |
| 20 | +Users can configure it using the file /etc/mbpfan.conf |
| 21 | + |
| 22 | +%prep |
| 23 | +%setup -q -n %{name}-%{version} |
| 24 | + |
| 25 | +%build |
| 26 | +make |
| 27 | + |
| 28 | +%install |
| 29 | +install -D -m755 bin/mbpfan $RPM_BUILD_ROOT/usr/sbin/mbpfan |
| 30 | +install -D -m644 mbpfan.conf $RPM_BUILD_ROOT/etc/mbpfan.conf |
| 31 | +install -D -m644 mbpfan.service $RPM_BUILD_ROOT/usr/lib/systemd/system/mbpfan.service |
| 32 | + |
| 33 | +%clean |
| 34 | +rm -rf $RPM_BUILD_ROOT |
| 35 | + |
| 36 | +%post |
| 37 | +%systemd_post mbpfan.service |
| 38 | +# If it is a first installation then autoconfigure daemon |
| 39 | +if [[ ${1} == 1 ]]; then |
| 40 | + min_fan_speed="$(cat /sys/devices/platform/applesmc.768/fan*_min| uniq| sort |head -1)" |
| 41 | + max_fan_speed="$(cat /sys/devices/platform/applesmc.768/fan*_max| uniq| sort |tail -1)" |
| 42 | + let max_temp=$(cat /sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_max|uniq |sort |tail -1)/1000 |
| 43 | + sed -i "s/min_fan_speed = [^\t]\+/min_fan_speed = $min_fan_speed/g" /etc/mbpfan.conf |
| 44 | + sed -i "s/max_fan_speed = [^\t]\+/max_fan_speed = $max_fan_speed/g" /etc/mbpfan.conf |
| 45 | + sed -i "s/max_temp = [^\t]\+/max_temp = $max_temp/g" /etc/mbpfan.conf |
| 46 | +fi |
| 47 | +echo "Attention: mbpfan preconfigured with sane values, to run it type:" |
| 48 | +echo "systemctl start mbpfan" |
| 49 | +echo "To run also at boot, type:" |
| 50 | +echo "systemctl enable mbpfan" |
| 51 | + |
| 52 | +%preun |
| 53 | +%systemd_preun mbpfan.service |
| 54 | + |
| 55 | +%postun |
| 56 | +%systemd_postun_with_restart mbpfan.service |
| 57 | + |
| 58 | +%files |
| 59 | +%defattr (-,root,root) |
| 60 | +%doc AUTHORS README.md |
| 61 | +/usr/sbin/mbpfan |
| 62 | +%config /etc/mbpfan.conf |
| 63 | +/usr/lib/systemd/system/mbpfan.service |
| 64 | + |
| 65 | +%changelog |
| 66 | +* Sun Aug 19 2018 Michele Codutti <[email protected]> - 2.0.2-2 |
| 67 | +- Autoconfig with suggested procedure. |
| 68 | +- Initial packaging |
0 commit comments