--- /dev/null
+#!/bin/bash
+
+# Abort if any command returns an error value
+set -e
+
+# This script is called as the last step of the installation of the
+# package. All the package's files are in place, dpkg has already
+# done its automatic conffile handling, and all the packages we depend
+# of are already fully installed and configured.
+
+# The following idempotent stuff doesn't generally need protecting
+# against being run in the abort-* cases.
+
+# Use debconf. (installs templates)
+. /usr/share/debconf/confmodule
+# all done with debconf here.
+db_stop
+
+case "$1" in
+ triggered)
+ # We don't print a status message here, as dpkg already said
+ # "Processing triggers for ...".
+ exit 0;;
+
+ configure)
+
+ # remove the systemd watchdog mux socket service
+ # as watchdog-mux should handle this on it's own
+ rm -f /etc/systemd/system/sockets.target.wants/watchdog-mux.socket
+ rm -f /var/lib/systemd/deb-systemd-helper-enabled/sockets.target.wants/watchdog-mux.socket
+ rm -f /var/lib/systemd/deb-systemd-helper-enabled/watchdog-mux.socket.dsh-also
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ exit 0
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+
+esac
+
+
+exit 0
#include <linux/types.h>
#include <linux/watchdog.h>
-#include <systemd/sd-daemon.h>
-
#define WD_SOCK_PATH "/run/watchdog-mux.sock"
#define WD_ACTIVE_MARKER "/run/watchdog-mux.active"
struct sockaddr_un my_addr, peer_addr;
socklen_t peer_addr_size;
struct epoll_event ev, events[MAX_EVENTS];
- int socket_count, listen_sock, nfds, epollfd, sigfd;
+ int listen_sock, nfds, epollfd, sigfd;
int unlink_socket = 0;
struct stat fs;
fprintf(stderr, "Watchdog driver '%s', version %x\n",
wdinfo.identity, wdinfo.firmware_version);
- socket_count = sd_listen_fds(0);
-
- if (socket_count > 1) {
-
- perror("too many file descriptors received.\n");
- goto err;
-
- } else if (socket_count == 1) {
-
- listen_sock = SD_LISTEN_FDS_START + 0;
-
- } else {
-
- unlink_socket = 1;
-
- unlink(WD_SOCK_PATH);
+ /* always unlink socket path then create socket */
+ unlink(WD_SOCK_PATH);
+ unlink_socket = 1;
- listen_sock = socket(AF_UNIX, SOCK_STREAM, 0);
- if (listen_sock == -1) {
- perror("socket create");
- exit(EXIT_FAILURE);
- }
+ listen_sock = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (listen_sock == -1) {
+ perror("socket create");
+ exit(EXIT_FAILURE);
+ }
+ memset(&my_addr, 0, sizeof(struct sockaddr_un));
+ my_addr.sun_family = AF_UNIX;
+ strncpy(my_addr.sun_path, WD_SOCK_PATH, sizeof(my_addr.sun_path) - 1);
+
+ if (bind(listen_sock, (struct sockaddr *) &my_addr,
+ sizeof(struct sockaddr_un)) == -1) {
+ perror("socket bind");
+ exit(EXIT_FAILURE);
+ }
- memset(&my_addr, 0, sizeof(struct sockaddr_un));
- my_addr.sun_family = AF_UNIX;
- strncpy(my_addr.sun_path, WD_SOCK_PATH, sizeof(my_addr.sun_path) - 1);
-
- if (bind(listen_sock, (struct sockaddr *) &my_addr,
- sizeof(struct sockaddr_un)) == -1) {
- perror("socket bind");
- exit(EXIT_FAILURE);
- }
-
- if (listen(listen_sock, LISTEN_BACKLOG) == -1) {
- perror("socket listen");
- goto err;
- }
+ if (listen(listen_sock, LISTEN_BACKLOG) == -1) {
+ perror("socket listen");
+ goto err;
}
-
+
epollfd = epoll_create(10);
if (epollfd == -1) {
perror("epoll_create");