mbpfan-josie

Added Gentoo support and enhanced README.md

03ac20500b4b78afd2a40be48f5d96a53c40f182
Daniel Graziotin <dgraziotin@task3.cc> · 2012-08-23T11:08 · browse files at this commit

parents: 37847f3 a895bff

diff --cc AUTHORS
index 9ff236c,fe4287c..941e824
--- a/AUTHORS
+++ b/AUTHORS
@@@ -1,12 -1,12 +1,13 @@@
--MAINTAINERS AND CONTRIBUTORS
------------------------------
++AUTHORS, CONTRIBUTORS, MAINTAINERS
++----------------------------------
  
  Daniel Graziotin        <dgraziotin AT task3 DOT cc>
  Ismail Khatib           <ikhatib AT gmail DOT com>
- Trevor Joynson			
++Trevor Joynson
++Magnus Stubman			<magnus AT stubman DOT eu>		
+ 
  
  ORIGINARY AUTHORS
  -----------------
--
  Allan McRae mbpfan      <http://allanmcrae.com/2010/05/simple-macbook-pro-fan-daemon>
  rvega                   <https://github.com/rvega/Fan-Control-Daemon>
diff --cc Makefile
index 7e40233,841b1f0..125897b
--- a/Makefile
+++ b/Makefile
@@@ -54,28 -54,36 +54,28 @@@ all: $(OBJS
  clean:
  	rm -rf $(SOURCE_PATH)*.$(OBJ) $(EXE)
  
 +tests:
 +	make install
 +	sudo /usr/sbin/mbpfan -f -v -t
 +
 +uninstall:
 +	rm /usr/sbin/mbpfan
 +	rm /etc/mbpfan.conf
 +
  install:
 +	make
  	cp $(EXE) /usr/sbin
  	cp -n $(CONF) /etc
 -	@echo "-----------------------------------------------------------------------------"
 -	@echo "An init file suitable for /lib/lsb/init-functions (Debian & Ubuntu for sure)"
 -	@echo "is located in the main folder of the source files, called mbpfan.init.debian"
 -	@echo "Rename it to mbpfan, give it execution permissions (chmod +x mbpfan)"
 -	@echo "and move it to /etc/init.d"
 -	@echo "Then, add it to the default runlevels with sudo update-rc.d mbpfan defaults"
  	@echo ""
 -	@echo "Additionally, an init file suitable for /etc/rc.d/init.d/functions"
 -	@echo "(RHEL/CentOS & Fedora) is also located at the same place, this file is called"
 -	@echo "mbpfan.init.redhat. Also rename it to mbpfan, give it execution permissions"
 -	@echo "and move it to /etc/init.d"
 -	@echo "To add the script to the default runlevels, run the following as root:"
 -	@echo "chkconfig --level 2345 mbpfan on && chkconfig --level 016 mbpfan off"
 +	@echo "******************"
 +	@echo "INSTALL COMPLETED"
 +	@echo "******************"
  	@echo ""
 -	@echo "As a special bonus, a service file for systemd is also included. To use it,"
 -	@echo "execute the following as root:"
 -	@echo "cp mbpfan.service /usr/lib/systemd/system"
 -	@echo "ln -s /usr/lib/systemd/system/mbpfan.service /etc/systemd/system/mbpfan.service"
 -	@echo "systemctl daemon-reload"
 -	@echo "systemctl start mbpfan.service"
 -	@echo "To start the service automatically at boot, also execute the following:"
 -	@echo "systemctl enable mbpfan.service"
 +	@echo "A configuration file has been copied to /etc/mbpfan.conf"
 +	@echo "See README.md file to have mbpfan automatically started at system boot."
 +	@echo ""
 +	@echo "Please run the tests now with the command"
 +	@echo "   sudo make tests"
  	@echo ""
 -	@echo "An init file is available for gentoo users: mbpfan.init.gentoo"
 -	@echo "To install, run # cp mbpfan.init.gentoo /etc/init.d/mbpfan"
 -	@echo "To automatically run mbpfan at boot, run # rc-update add mbpfan default"
 -	@echo "-----------------------------------------------------------------------------"
 -
  rebuild: clean all
--#rebuild is not entirely correct
++#rebuild is not entirely correct
diff --cc README.md
index 29ea2df,f0d75ff..2137929
--- a/README.md
+++ b/README.md
@@@ -14,89 -15,64 +14,144 @@@ This enhanced version assumes any numbe
  *  It requires root use
  *  It daemonizes or stays in foreground
  *  Verbose mode for both syslog and stdout
 +*  Users can configure it using the file /etc/mbpfan.conf
  
  
 -Compile Instructions
++Supported GNU/Linux Distributions
++---------------------------------
++We provide scripts to to load mbpfan daemon at system boot for many distros.
++Please note that the support is provided by volunteers. mbpfan needs test and bug reports.
++
++Supported distributions:
++
++- Ubuntu
++- Debian
++- Fedora
++- RedHat
++- CentOS
++- Gentoo
++
++
++Tested Macbook Models
+ ---------------------
++- MacBook Pro 8.1 13"  (Intel i7 - Linux 3.2)
++- MacBook Pro 6,2 15"  (Intel i7 - Linux 3.2)
++- MacBook Pro 2,2 15"  (Intel Core 2 Duo - Linux 3.4.4)
++
+ 
++Warning
++-------
++Be sure to load the kernel modules **applesmc** and **coretemp**.
++
++
 +Compile Instructions
 +---------------------
  Compile with
--   make
++
++    make
  
  Manually compile with
--   gcc -o bin/mbpfan src/mbpfan.c -lm
+ 
 -Run The Tests (Recommended)
 ----------------------------
++    gcc -o bin/mbpfan src/mbpfan.c -lm
  
 -It is recommended to run the tests before installing the program
 -	sudo ./bin/mbpfan -t
  
  Install Instructions
  --------------------
 -
  Install with
--   sudo make install
+ 
 -It actually copies mbpfan to /usr/sbin.
++    sudo make install
  
 -An init file suitable for /lib/lsb/init-functions (Debian & Ubuntu fur sure)
 -is located in the main folder of the source files. It is called mbpfan.init.debian
 -Rename it to mbpfan, give it execution permissions (chmod +x mbpfan)
 -and move it to /etc/init.d
 -Then, add it to the default runlevels with sudo update-rc.d mbpfan defaults (Ubuntu example)
 +It copies mbpfan to /usr/sbin and mbpfan.conf to /etc
  
 -An init file suitable for Fedora (and probably RedHat) can be found
 -in the file mbpfan.init.fedora
  
 -An init file is available for gentoo users: mbpfan.init.gentoo
 -To install, run # cp mbpfan.init.gentoo /etc/init.d/mbpfan
 -To automatically run mbpfan at boot, run # rc-update add mbpfan default
 +Run The Tests (Recommended)
 +---------------------------
 +It is recommended to run the tests after installing the program
- 	sudo ./bin/mbpfan -t
+ 
 -Run Instructions
 ----------------------
++    sudo ./bin/mbpfan -t
++
 +or
- 	sudo make tests
+ 
++    sudo make tests
 +
 +
 +Run Instructions
 +----------------
  If not installed, run with
--sudo bin/mbpfan
++
++    sudo bin/mbpfan
  
  If installed, manually run with
--sudo mbpfan
++
++    sudo mbpfan
  
  If installed and using the init file, run with (Ubuntu example)
--sudo service mbpfan start
++
++    sudo service mbpfan start
 +
 +
 +Starting at boot
 +----------------
 +**Ubuntu**
 +For upstart based init systems (Ubuntu), an example upstart job has been
 +provided for use in place of the LSB-style init script. 
 +To use, execute:
- 	sudo cp mbpfan.upstart /etc/init/mbpfan.conf
- 	sudo start mbpfan
++
++    sudo cp mbpfan.upstart /etc/init/mbpfan.conf
++    sudo start mbpfan
 +
 +**Debian**
 +An init file suitable for /lib/lsb/init-functions (Debian) 
 +is located in the main folder of the source files, called mbpfan.init.debian
 +Rename it to mbpfan, give it execution permissions (chmod +x mbpfan)
 +and move it to /etc/init.d
- Then, add it to the default runlevels with sudo update-rc.d mbpfan defaults
++Then, add it to the default runlevels with (as root):
++
++    sudo update-rc.d mbpfan defaults
 +
 +**Redhat, CentOS, Fedora**
 +An init file suitable for /etc/rc.d/init.d/functions
 +(RHEL/CentOS & Fedora) is also located at the same place, this file is called
 +mbpfan.init.redhat. Also rename it to mbpfan, give it execution permissions
 +and move it to /etc/init.d
 +To add the script to the default runlevels, run the following as root:
- chkconfig --level 2345 mbpfan on && chkconfig --level 016 mbpfan off
++
++    chkconfig --level 2345 mbpfan on && chkconfig --level 016 mbpfan off
++
++**Gentoo**
++An init file is available for gentoo users: mbpfan.init.gentoo
++To install, run as root:
++
++    cp mbpfan.init.gentoo /etc/init.d/mbpfan
++
++To automatically run mbpfan at boot, run as root:
++
++    rc-update add mbpfan default
++
 +
 +**systemd**
 +As a special bonus, a service file for systemd is also included. To use it,
- execute the following as root:
- sudo cp mbpfan.service /usr/lib/systemd/system
- sudo ln -s /usr/lib/systemd/system/mbpfan.service /etc/systemd/system/mbpfan.service
- sudo systemctl daemon-reload
- sudo systemctl start mbpfan.service
++execute the following (as root):
++
++    sudo cp mbpfan.service /usr/lib/systemd/system
++    sudo ln -s /usr/lib/systemd/system/mbpfan.service /etc/systemd/system/mbpfan.service
++    sudo systemctl daemon-reload
++    sudo systemctl start mbpfan.service
 +
 +To start the service automatically at boot, also execute the following:
- sudo systemctl enable mbpfan.service
++
++    sudo systemctl enable mbpfan.service
 +
  
  Usage
  -------
- Usage: ./mbpfan OPTION(S)
- -h Show the help screen
- -f Run in foreground
- -t Run the tests
- -v Be (a lot) verbose
+ 
 -Usage: ./mbpfan OPTION(S)
 --h Show the help screen
 --f Run in foreground
 --t Run the tests
 --v Be (a lot) verbose
++    Usage: ./mbpfan OPTION(S)
++
++    -h Show the help screen
++    -f Run in foreground
++    -t Run the tests
++    -v Be (a lot) verbose
  
  
  License
@@@ -110,4 -87,4 +165,4 @@@ Based O
  * http://allanmcrae.com/2011/08/mbp-fan-daemon-update/
  * https://launchpad.net/macfanctld
  * http://paste2.org/p/862259
--* http://www.lobotomo.com/products/FanControl/
++* http://www.lobotomo.com/products/FanControl/
diff --cc src/minunit.c
index 0603047,fadaf97..9b43ce9
--- a/src/minunit.c
+++ b/src/minunit.c
@@@ -10,28 -9,30 +10,18 @@@
  int tests_run = 0;
  
  
- struct s_sensors {
-     char* path;
-     char* fan_output_path;
-     char* fan_manual_path;
-     unsigned int temperature;
-     struct s_sensors *next;
 -struct s_sensors
 -{
 -  char* path;
 -  char* fan_output_path;
 -  char* fan_manual_path;
 -  unsigned int temperature;
 -  struct s_sensors *next;
--};
--typedef s_sensors t_sensors;
--
--
  static char *test_sensor_paths()
  {
 -  t_sensors* sensors = retrieve_sensors();
 -  mu_assert("No sensors found", sensors != NULL);
 -  t_sensors* tmp = sensors;
 -  while(tmp != NULL)
 -    {
 -      mu_assert("Sensor does not have a valid path", tmp->path != NULL);
 -      if(tmp->path != NULL)
 -        mu_assert("Sensor does not have valid temperature", tmp->temperature > 0);
 -      tmp = tmp->next;
 +    t_sensors* sensors = retrieve_sensors();
 +    mu_assert("No sensors found", sensors != NULL);
 +    t_sensors* tmp = sensors;
 +    while(tmp != NULL) {
 +        mu_assert("Sensor does not have a valid path", tmp->path != NULL);
 +        if(tmp->path != NULL)
 +            mu_assert("Sensor does not have valid temperature", tmp->temperature > 0);
 +        tmp = tmp->next;
      }
 -  return 0;
 +    return 0;
  }
  
  
diff --cc src/minunit.h
index 0565cdf,d9dc93d..a83e6de
--- a/src/minunit.h
+++ b/src/minunit.h
@@@ -5,6 -5,6 +5,16 @@@
  #define mu_run_test(test) do { char *message = test(); tests_run++; \
                                  if (message) return message; } while (0)
  
++struct s_sensors {
++    char* path;
++    char* fan_output_path;
++    char* fan_manual_path;
++    unsigned int temperature;
++    struct s_sensors *next;
++};
++typedef s_sensors t_sensors;
++
++
  extern int tests_run;
  
  static char *test_sensor_paths();