mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-10-31 22:47:05 +01:00
Added Pre/Post Lock/Unlock Scripts
This commit is contained in:
parent
567b0999f2
commit
520566417e
@ -46,3 +46,11 @@ install(DIRECTORY scripts/ DESTINATION share/doorlockd/
|
||||
PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_WRITE)
|
||||
install(FILES scripts/doorlockd.service DESTINATION /etc/systemd/system/)
|
||||
install(FILES scripts/doorlockd DESTINATION /etc/sysconfig/)
|
||||
|
||||
install(DIRECTORY scripts/ DESTINATION etc/doorlockd/
|
||||
FILES_MATCHING PATTERN "scripts/pre_*lock"
|
||||
PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_WRITE)
|
||||
|
||||
install(DIRECTORY scripts/ DESTINATION etc/doorlockd/
|
||||
FILES_MATCHING PATTERN "scripts/post_*lock"
|
||||
PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_WRITE)
|
||||
|
@ -19,4 +19,9 @@
|
||||
|
||||
#define TEMPLATE_LOCATION "@CMAKE_INSTALL_PREFIX@/share/doorlockd/template.png"
|
||||
|
||||
#define PRE_LOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/pre_lock &"
|
||||
#define POST_LOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/post_lock &"
|
||||
#define PRE_UNLOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/pre_unlock &"
|
||||
#define POST_UNLOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/post_unlock &"
|
||||
|
||||
#endif
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <wiringPi.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "logger.h"
|
||||
#include "door.h"
|
||||
|
||||
@ -31,6 +32,9 @@ Door &Door::get()
|
||||
|
||||
void Door::lock()
|
||||
{
|
||||
_l(LogLevel::notice, "Executing Pre Lock Script");
|
||||
system(PRE_LOCK_SCRIPT);
|
||||
|
||||
digitalWrite(_SCHNAPPERPIN, HIGH);
|
||||
_l(LogLevel::info, "Door closed");
|
||||
|
||||
@ -41,12 +45,15 @@ void Door::lock()
|
||||
_heartbeat.join();
|
||||
}
|
||||
|
||||
// Turn off all lights
|
||||
system("wget -O /dev/null --timeout 3 \"http://homer.binary.kitchen:8080/set?color=000000\" > /dev/null 2>&1");
|
||||
_l(LogLevel::notice, "Executing Post Lock Script");
|
||||
system(POST_LOCK_SCRIPT);
|
||||
}
|
||||
|
||||
void Door::unlock()
|
||||
{
|
||||
_l(LogLevel::notice, "Executing Pre Unlock Script");
|
||||
system(PRE_UNLOCK_SCRIPT);
|
||||
|
||||
// In any case, klacker the schnapper
|
||||
_schnapper = true;
|
||||
|
||||
@ -103,4 +110,7 @@ void Door::unlock()
|
||||
});
|
||||
|
||||
_l(LogLevel::info, "Door opened");
|
||||
|
||||
_l(LogLevel::notice, "Executing Post Unlock Script");
|
||||
system(POST_UNLOCK_SCRIPT);
|
||||
}
|
||||
|
3
doorlockd/scripts/post_lock
Executable file
3
doorlockd/scripts/post_lock
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
wget -O /dev/null --timeout 3 "http://homer.binary.kitchen:8080/set?color=000000" > /dev/null 2>&1
|
1
doorlockd/scripts/post_unlock
Executable file
1
doorlockd/scripts/post_unlock
Executable file
@ -0,0 +1 @@
|
||||
#!/bin/bash
|
1
doorlockd/scripts/pre_lock
Executable file
1
doorlockd/scripts/pre_lock
Executable file
@ -0,0 +1 @@
|
||||
#!/bin/bash
|
1
doorlockd/scripts/pre_unlock
Executable file
1
doorlockd/scripts/pre_unlock
Executable file
@ -0,0 +1 @@
|
||||
#!/bin/bash
|
Loading…
Reference in New Issue
Block a user