]> git.sesse.net Git - plocate/commitdiff
Add a systemd service and timer for updatedb, obsoleting the cron entry.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 28 Nov 2020 22:08:23 +0000 (23:08 +0100)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 28 Nov 2020 22:08:23 +0000 (23:08 +0100)
README
meson.build
meson_options.txt
plocate-updatedb.service.in [new file with mode: 0644]
plocate-updatedb.timer [new file with mode: 0644]

diff --git a/README b/README
index 75da95bf3695f796006756cc787a4ddfba931488..df4b07a45b01e24e32c2f347fbfad66c2b9a6e69 100644 (file)
--- a/README
+++ b/README
@@ -16,10 +16,11 @@ do not have an SSD. Installation is run as:
   cd obj
   ninja
   sudo ninja install
   cd obj
   ninja
   sudo ninja install
+  sudo addgroup plocate
+  sudo systemctl enable plocate-updatedb.timer
 
 To build the database for the first time after install, you can do
 
 
 To build the database for the first time after install, you can do
 
-  sudo addgroup mlocate
   sudo updatedb
 
 The initial run of updatedb needs to scan the entire filesystem.
   sudo updatedb
 
 The initial run of updatedb needs to scan the entire filesystem.
index 31f51d8856b86e95865b58d1b5955d25b2f30d11..b963c03db8209cc28bb6662216faa5ecdd48a714 100644 (file)
@@ -63,6 +63,18 @@ endif
 install_man('plocate.1')
 install_man('plocate-build.8')
 
 install_man('plocate.1')
 install_man('plocate-build.8')
 
+if get_option('install_systemd')
+       systemd = dependency('systemd', required: false)
+       if systemd.found()
+               unitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
+               updatedb_service = configure_file(input: 'plocate-updatedb.service.in',
+                      output: 'plocate-updatedb.service',
+                      configuration: conf_data)
+               install_data(updatedb_service, install_dir: unitdir)
+               install_data('plocate-updatedb.timer', install_dir: unitdir)
+       endif
+endif
+
 # Requires having TurboPFor checked out, so not built by default.
 # Unless you have a recent Meson, there's no apparently good way
 # of calling into that directory to run make, and we're not
 # Requires having TurboPFor checked out, so not built by default.
 # Unless you have a recent Meson, there's no apparently good way
 # of calling into that directory to run make, and we're not
index 3e2f6ccd7b8d1c67e7b751c8949bc0b273f44350..f26115558a39f67cd8e402b39dc97e2711e6a896 100644 (file)
@@ -1,2 +1,3 @@
-option('install_cron', type: 'boolean', value: true, description: 'Install update script into /etc/cron.daily')
+option('install_cron', type: 'boolean', value: false, description: 'Install mlocate conversion script into /etc/cron.daily')
+option('install_systemd', type: 'boolean', value: true, description: 'Install systemd service and timer for updatedb, if systemd is installed')
 option('locategroup', type: 'string', value: 'plocate', description: 'Group that the install script will use for the .db file')
 option('locategroup', type: 'string', value: 'plocate', description: 'Group that the install script will use for the .db file')
diff --git a/plocate-updatedb.service.in b/plocate-updatedb.service.in
new file mode 100644 (file)
index 0000000..8db7dba
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=Update the plocate database
+ConditionACPower=true
+
+[Service]
+Type=oneshot
+ExecStart=@sbindir@/updatedb
+LimitNOFILE=131072
+IOSchedulingClass=idle
+
+PrivateTmp=true
+PrivateDevices=true
+PrivateNetwork=true
+ProtectSystem=full
diff --git a/plocate-updatedb.timer b/plocate-updatedb.timer
new file mode 100644 (file)
index 0000000..1f69330
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Update the plocate database daily
+
+[Timer]
+OnCalendar=daily
+Persistent=true
+
+[Install]
+WantedBy=timers.target