diff --git a/CMakeLists.txt b/CMakeLists.txt index aed4c01..266141a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,5 +26,11 @@ epaper/bsp.c ) add_executable(doorlockd ${SRCS}) - target_link_libraries(doorlockd wiringPi jsoncpp ldap) + +install(TARGETS doorlockd DESTINATION sbin) +install(FILES img/template.png DESTINATION share/doorlockd) +install(DIRECTORY scripts/ DESTINATION share/doorlockd + FILES_MATCHING PATTERN "scripts/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) diff --git a/epaper.cpp b/epaper.cpp index 0cb4279..8fdb79b 100644 --- a/epaper.cpp +++ b/epaper.cpp @@ -38,7 +38,7 @@ void Epaper::draw(const string &uri) snprintf((char*)buffer, ARRAY_SIZE, "qrencode -l M -d 100 -s 5 \"%s\" -o /tmp/qr.png", uri.c_str()); system((char*)buffer); - FILE* f = popen("composite -geometry +90+0 /tmp/qr.png /tmp/template.png -colorspace gray -depth 1 gray:-", "r"); + FILE* f = popen("composite -geometry +90+0 /tmp/qr.png /usr/local/share/doorlockd/template.png -colorspace gray -depth 1 gray:-", "r"); int i = fread(buffer, ARRAY_SIZE, 1, f); if (i != 1) { diff --git a/img/template.png b/img/template.png new file mode 100644 index 0000000..923056a Binary files /dev/null and b/img/template.png differ diff --git a/scripts/doorlockd-start b/scripts/doorlockd-start new file mode 100755 index 0000000..5af044b --- /dev/null +++ b/scripts/doorlockd-start @@ -0,0 +1,12 @@ +#!/bin/bash +PIDFILE=/tmp/doorlockd-pid + +gpio load spi +gpio load i2c + +/home/ralf/doorlockd-build/doorlockd & +PID=$! + +echo $PID > $PIDFILE + +wait $PID diff --git a/scripts/doorlockd-stop b/scripts/doorlockd-stop new file mode 100755 index 0000000..31a6608 --- /dev/null +++ b/scripts/doorlockd-stop @@ -0,0 +1,12 @@ +#!/bin/bash + +PIDFILE=/tmp/doorlockd-pid + +if [ -f $PIDFILE ] +then + kill `cat $PIDFILE` + rm $PIDFILE +else + echo "PID file not existent" +fi + diff --git a/scripts/doorlockd.service b/scripts/doorlockd.service new file mode 100644 index 0000000..f83ed44 --- /dev/null +++ b/scripts/doorlockd.service @@ -0,0 +1,13 @@ +[Unit] +Description=Binary Kitchen doorlockd service +After=network.target + +[Service] +User=root +Group=root +ExecStart=/usr/local/share/doorlockd/doorlockd-start +ExecStop=/usr/local/share/doorlockd/doorlockd-stop + +[Install] +WantedBy=multi-user.target +