Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ bin_PROGRAMS = time_daemon
time_daemon_SOURCES = time_daemon.c time_service_v01.c
time_daemon_LDADD = $(requiredlibs)
time_daemon_LDFLAGS = -lpthread @GLIB_LIBS@

# Systemd service file installation
if HAVE_SYSTEMD
systemdsystemunit_DATA = time-daemon.service
endif
7 changes: 6 additions & 1 deletion build_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ echo "Running configure.."
echo "Running make.."
make || { echo "make failed"; exit 1; }

make install || { echo "make install failed"; exit 1; }
# Use sudo only if not running as root
if [ "$(id -u)" -eq 0 ]; then
make install || { echo "make install failed"; exit 1; }
else
sudo make install || { echo "make install failed"; exit 1; }
fi

FILES_TO_CLEAN=(
aclocal.m4 configure ar-lib config.h config.h.in config.log config.status libtool
Expand Down
24 changes: 22 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

# Requires autoconf tool later than 2.61
AC_PREREQ(2.61)
# Initialize the qmi-framework package version 1.0.0
AC_INIT([time-services],1.0.0)
# Initialize the qmi-framework package version 0.1.1
AC_INIT([time-services],0.1.1)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign])
# Disables auto rebuilding of configure, Makefile.ins
Expand Down Expand Up @@ -41,6 +41,26 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes, AC_MSG_ERROR(GLib >= 2.16 i
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
AC_SUBST(GLIB_LIBS)

# Check for systemd
AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
[],
[with_systemdsystemunitdir=auto])

AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)

AS_IF([test "x$def_systemdsystemunitdir" = "x"],
[AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemdsystemunitdir=no],
[with_systemdsystemunitdir="$def_systemdsystemunitdir"])])

AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
[AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])

AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])

AC_CONFIG_FILES([ \
Makefile \
])
Expand Down
15 changes: 15 additions & 0 deletions time-daemon.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Time Services Daemon

[Service]
Type=simple
ExecStart=/usr/bin/time_daemon
Restart=on-failure
StateDirectory=time

# Device access for RTC (read-only)
DeviceAllow=/dev/rtc0 r
DevicePolicy=closed

[Install]
WantedBy=multi-user.target
Loading