Merge pull request #54 from fudger/master

Add little script to make pigpiod a system service
This commit is contained in:
joan2937 2016-03-12 22:01:13 +00:00
commit cf62a6ad81
3 changed files with 72 additions and 5 deletions

View File

@ -1,5 +1,5 @@
################################################################################ ################################################################################
### Find the pigpio includes and shared libraries. ### Find the pigpio shared libraries.
################################################################################ ################################################################################
# Find the path to the pigpio includes. # Find the path to the pigpio includes.
@ -7,19 +7,24 @@ find_path(pigpio_INCLUDE_DIR
NAMES pigpio.h pigpiod_if.h pigpiod_if2.h NAMES pigpio.h pigpiod_if.h pigpiod_if2.h
HINTS /usr/local/include) HINTS /usr/local/include)
# Find the path to the pigpio libraries. # Find the pigpio libraries.
find_library(pigpio_LIBRARY find_library(pigpio_LIBRARY
NAMES libpigpio.so libpigpiod_if.so libpigpiod_if2.so NAMES libpigpio.so
HINTS /usr/local/lib)
find_library(pigpiod_if_LIBRARY
NAMES libpigpiod_if.so
HINTS /usr/local/lib)
find_library(pigpiod_if2_LIBRARY
NAMES libpigpiod_if2.so
HINTS /usr/local/lib) HINTS /usr/local/lib)
# Set the pigpio variables to plural form to make them accessible for # Set the pigpio variables to plural form to make them accessible for
# the paramount cmake modules. # the paramount cmake modules.
set(pigpio_INCLUDE_DIRS ${pigpio_INCLUDE_DIR}) set(pigpio_INCLUDE_DIRS ${pigpio_INCLUDE_DIR})
set(pigpio_INCLUDES ${pigpio_INCLUDE_DIR}) set(pigpio_INCLUDES ${pigpio_INCLUDE_DIR})
set(pigpio_LIBRARIES ${pigpio_LIBRARY})
# Handle REQUIRED, QUIET, and version arguments # Handle REQUIRED, QUIET, and version arguments
# and set the <packagename>_FOUND variable. # and set the <packagename>_FOUND variable.
find_package_handle_standard_args(pigpio find_package_handle_standard_args(pigpio
DEFAULT_MSG DEFAULT_MSG
pigpio_INCLUDE_DIR pigpio_LIBRARY) pigpio_INCLUDE_DIR pigpio_LIBRARY pigpiod_if_LIBRARY pigpiod_if2_LIBRARY)

31
util/pigpiod Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: pigpiod
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: pigpio daemon
# Description: pigpio daemon required to control GPIO pins via pigpio $
### END INIT INFO
# Actions
case "$1" in
start)
pigpiod
;;
stop)
pkill pigpiod
;;
restart)
pkill pigpiod
pigpiod
;;
*)
echo "Usage: $0 start" >&2
exit 3
;;
esac
exit 0

31
util/readme.md Normal file
View File

@ -0,0 +1,31 @@
This folder provides utility files for the pigpio library.
### pigpiod
`pigpiod` is a script that allows to run pigpiod as a Linux service with root privileges.
The advantage of running pigpiod as a service is that pigpiod can be automatically launched on system startup.
To automatically start pigpiod as a service, do the following:
+ Copy `pigpiod` from this directory to `/etc/init.d/`.
+ Make it executable:
```
sudo chmod +x /etc/init.d/pigpiod
```
+ Tell update-rc.d to automatically start the pigpiod service on system startup:
```
sudo update-rc.d pigpiod defaults
```
+ Now, you can start, stop, and restart pigpiod using
```
sudo service pigpiod start
sudo service pigpiod stop
sudo service pigpiod restart
```
### Findpigpio.cmake
`Findpigpio.cmake` is a script used by CMake to find out where the pigpio header and library files are located.