492 lines
12 KiB
HTML
492 lines
12 KiB
HTML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
|
<head>
|
|
<!-- 2020-05-26 mar. 08:40 -->
|
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
|
<title>Systemd services and timers</title>
|
|
<meta name="generator" content="Org mode" />
|
|
<meta name="author" content="Dehaeze Thomas" />
|
|
<link rel="stylesheet" type="text/css" href="./css/htmlize.css"/>
|
|
<link rel="stylesheet" type="text/css" href="./css/readtheorg.css"/>
|
|
<script type="text/javascript" src="./js/jquery.min.js"></script>
|
|
<script type="text/javascript" src="./js/bootstrap.min.js"></script>
|
|
<script type="text/javascript" src="./js/jquery.stickytableheaders.min.js"></script>
|
|
<script type="text/javascript" src="./js/readtheorg.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="org-div-home-and-up">
|
|
<a accesskey="h" href="./index.html"> UP </a>
|
|
|
|
|
<a accesskey="H" href="./index.html"> HOME </a>
|
|
</div><div id="content">
|
|
<h1 class="title">Systemd services and timers</h1>
|
|
<div id="table-of-contents">
|
|
<h2>Table of Contents</h2>
|
|
<div id="text-table-of-contents">
|
|
<ul>
|
|
<li><a href="#org5b65512">Pass Git</a>
|
|
<ul>
|
|
<li><a href="#org206b59c">Service</a></li>
|
|
<li><a href="#orge9865a6">Timer</a></li>
|
|
<li><a href="#org0561aed">Script</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#org79abe94">Buku Git</a>
|
|
<ul>
|
|
<li><a href="#org06e5158">Service</a></li>
|
|
<li><a href="#org48bc751">Timer</a></li>
|
|
<li><a href="#org8552721">Script</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#org1d68bb0">Check mail</a>
|
|
<ul>
|
|
<li><a href="#org6acfd66">Service</a></li>
|
|
<li><a href="#orgc8b73e7">Timer</a></li>
|
|
<li><a href="#orgea90a0b">Script</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#orgefb3320">Sync mail</a>
|
|
<ul>
|
|
<li><a href="#org1f273c6">Service</a></li>
|
|
<li><a href="#org9aa2ba5">Timer</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#org2ff1601">Vdirsyncer</a>
|
|
<ul>
|
|
<li><a href="#orgc941c47">Service</a></li>
|
|
<li><a href="#orgb5a6f5c">Timer</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#orgb34591d">SSH Agent</a>
|
|
<ul>
|
|
<li><a href="#org10e8ec0">Service</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#orge82b3ac">Powertop</a>
|
|
<ul>
|
|
<li><a href="#orgd482b17">Service</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#orgd4b9d58">Mopidy</a>
|
|
<ul>
|
|
<li><a href="#orgb1764a7">Service</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<p>
|
|
<a href="https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units">https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units</a>
|
|
</p>
|
|
|
|
<div id="outline-container-org5b65512" class="outline-2">
|
|
<h2 id="org5b65512">Pass Git</h2>
|
|
<div class="outline-text-2" id="text-org5b65512">
|
|
</div>
|
|
<div id="outline-container-org206b59c" class="outline-3">
|
|
<h3 id="org206b59c">Service</h3>
|
|
<div class="outline-text-3" id="text-org206b59c">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Sync Passwords every day
|
|
RefuseManualStart=no
|
|
RefuseManualStop=yes
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=%h/.local/bin/pass_git_sync
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orge9865a6" class="outline-3">
|
|
<h3 id="orge9865a6">Timer</h3>
|
|
<div class="outline-text-3" id="text-orge9865a6">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Sync Passwords every day
|
|
RefuseManualStart=no
|
|
RefuseManualStop=no
|
|
Wants=network-online.target
|
|
After=network-online.target
|
|
|
|
[Timer]
|
|
OnCalendar=*-*-* 16:00:00
|
|
Persistent=true
|
|
Unit=passgit.service
|
|
|
|
[Install]
|
|
WantedBy=default.target
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org0561aed" class="outline-3">
|
|
<h3 id="org0561aed">Script</h3>
|
|
<div class="outline-text-3" id="text-org0561aed">
|
|
<div class="org-src-container">
|
|
<pre class="src src-bash">cd ~/.local/share/buku/ || exit
|
|
|
|
if [[ ! -z $(git status -s bookmarks.db) ]]
|
|
then
|
|
git add bookmarks.db
|
|
git commit -m "Changed bookmarks - $(date +%F)"
|
|
git push
|
|
exit
|
|
fi
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org79abe94" class="outline-2">
|
|
<h2 id="org79abe94">Buku Git</h2>
|
|
<div class="outline-text-2" id="text-org79abe94">
|
|
</div>
|
|
<div id="outline-container-org06e5158" class="outline-3">
|
|
<h3 id="org06e5158">Service</h3>
|
|
<div class="outline-text-3" id="text-org06e5158">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Sync Bookmarks every day
|
|
RefuseManualStart=no
|
|
RefuseManualStop=yes
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=%h/.local/bin/buku_git_push
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org48bc751" class="outline-3">
|
|
<h3 id="org48bc751">Timer</h3>
|
|
<div class="outline-text-3" id="text-org48bc751">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Sync All Mails every x hours
|
|
RefuseManualStart=no
|
|
RefuseManualStop=no
|
|
Wants=network-online.target
|
|
After=network-online.target
|
|
|
|
[Timer]
|
|
OnCalendar=*-*-* 16:00:00
|
|
Persistent=true
|
|
Unit=bukugit.service
|
|
|
|
[Install]
|
|
WantedBy=default.target
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org8552721" class="outline-3">
|
|
<h3 id="org8552721">Script</h3>
|
|
<div class="outline-text-3" id="text-org8552721">
|
|
<div class="org-src-container">
|
|
<pre class="src src-bash">cd ~/.local/share/buku/
|
|
|
|
if [[ ! -z $(git status -s bookmarks.db) ]]
|
|
then
|
|
git add bookmarks.db
|
|
git commit -m "Changed bookmarks - $(date +%F)"
|
|
git push
|
|
exit
|
|
fi
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org1d68bb0" class="outline-2">
|
|
<h2 id="org1d68bb0">Check mail</h2>
|
|
<div class="outline-text-2" id="text-org1d68bb0">
|
|
</div>
|
|
<div id="outline-container-org6acfd66" class="outline-3">
|
|
<h3 id="org6acfd66">Service</h3>
|
|
<div class="outline-text-3" id="text-org6acfd66">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Check new mails
|
|
RefuseManualStart=no
|
|
RefuseManualStop=yes
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=%h/.local/bin/checkmail -q
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgc8b73e7" class="outline-3">
|
|
<h3 id="orgc8b73e7">Timer</h3>
|
|
<div class="outline-text-3" id="text-orgc8b73e7">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Check Mail every x minutes
|
|
RefuseManualStart=no
|
|
RefuseManualStop=no
|
|
Wants=network-online.target
|
|
After=network-online.target
|
|
Requires=checkmail.service
|
|
|
|
[Timer]
|
|
Persistent=false
|
|
OnBootSec=2min
|
|
OnUnitActiveSec=5min
|
|
AccuracySec=2min
|
|
Unit=checkmail.service
|
|
|
|
[Install]
|
|
WantedBy=default.target
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgea90a0b" class="outline-3">
|
|
<h3 id="orgea90a0b">Script</h3>
|
|
<div class="outline-text-3" id="text-orgea90a0b">
|
|
<div class="org-src-container">
|
|
<pre class="src src-bash">while [ -n "$1" ]; do # while loop starts
|
|
case "$1" in
|
|
-a) opt_all='--all' ;; # Check All inboxes
|
|
-v) opt_verbose='--verbose' ;; # Verbose
|
|
-q) opt_quiet='--quiet' ;; # Quiet
|
|
*) echo "Option $1 not recognized" ;; # In case you typed a different option
|
|
esac
|
|
shift
|
|
done
|
|
|
|
|
|
# =============================================================
|
|
# Count number of mails
|
|
gmail_old="$(ls ~/.mail/gmail/Inbox/new | wc -l)"
|
|
esrf_old="$(ls ~/.mail/esrf/Inbox/new | wc -l)"
|
|
ulg_old="$(ls ~/.mail/ulg/Inbox/new | wc -l)"
|
|
uliege_old="$(ls ~/.mail/uliege/Inbox/new | wc -l)"
|
|
# =============================================================
|
|
|
|
# =============================================================
|
|
# Retreive mails
|
|
mbsync $opt_all $opt_verbose gmail-Home esrf-Home ulg-Home uliege-Home 2>/tmp/mbsync.log
|
|
# =============================================================
|
|
|
|
# =============================================================
|
|
# Count number of mails
|
|
gmail_new="$(ls ~/.mail/gmail/Inbox/new | wc -l)"
|
|
esrf_new="$(ls ~/.mail/esrf/Inbox/new | wc -l)"
|
|
ulg_new="$(ls ~/.mail/ulg/Inbox/new | wc -l)"
|
|
uliege_new="$(ls ~/.mail/uliege/Inbox/new | wc -l)"
|
|
# =============================================================
|
|
|
|
# =============================================================
|
|
# Total Number of new mails since last checking
|
|
new="$(($gmail_new+$esrf_new+$ulg_new+$uliege_new))"
|
|
old="$(($gmail_old+$esrf_old+$ulg_old+$uliege_old))"
|
|
# =============================================================
|
|
|
|
# =============================================================
|
|
# Notification
|
|
if [ "$new" -gt 0 ]; then
|
|
dunstify --replace=98465 'Mails ' "$(($gmail_new+$esrf_new+$ulg_new+$uliege_new)) new mail(s)"
|
|
fi
|
|
# =============================================================
|
|
|
|
# =============================================================
|
|
# Indexation and Tags
|
|
if pgrep -f 'mu server'; then
|
|
emacsclient --eval '(mu4e-update-index)'
|
|
else
|
|
mu index $opt_verbose $opt_quiet
|
|
fi
|
|
# =============================================================
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgefb3320" class="outline-2">
|
|
<h2 id="orgefb3320">Sync mail</h2>
|
|
<div class="outline-text-2" id="text-orgefb3320">
|
|
</div>
|
|
<div id="outline-container-org1f273c6" class="outline-3">
|
|
<h3 id="org1f273c6">Service</h3>
|
|
<div class="outline-text-3" id="text-org1f273c6">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Sync all mails
|
|
RefuseManualStart=no
|
|
RefuseManualStop=yes
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=%h/.local/bin/checkmail -a -q
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org9aa2ba5" class="outline-3">
|
|
<h3 id="org9aa2ba5">Timer</h3>
|
|
<div class="outline-text-3" id="text-org9aa2ba5">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Sync All Mails every x hours
|
|
RefuseManualStart=no
|
|
RefuseManualStop=no
|
|
Wants=network-online.target
|
|
After=network-online.target
|
|
Requires=syncmail.service
|
|
|
|
[Timer]
|
|
Persistent=false
|
|
OnBootSec=30min
|
|
OnUnitActiveSec=300min
|
|
AccuracySec=10min
|
|
Unit=syncmail.service
|
|
|
|
[Install]
|
|
WantedBy=default.target
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org2ff1601" class="outline-2">
|
|
<h2 id="org2ff1601">Vdirsyncer</h2>
|
|
<div class="outline-text-2" id="text-org2ff1601">
|
|
</div>
|
|
<div id="outline-container-orgc941c47" class="outline-3">
|
|
<h3 id="orgc941c47">Service</h3>
|
|
<div class="outline-text-3" id="text-orgc941c47">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Synchronize calendars and contacts
|
|
Documentation=https://vdirsyncer.readthedocs.org/
|
|
Wants=network-online.target
|
|
After=network-online.target
|
|
|
|
[Service]
|
|
ExecStart=/usr/bin/vdirsyncer --verbosity "ERROR" sync
|
|
Type=oneshot
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgb5a6f5c" class="outline-3">
|
|
<h3 id="orgb5a6f5c">Timer</h3>
|
|
<div class="outline-text-3" id="text-orgb5a6f5c">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Synchronize vdirs
|
|
|
|
[Timer]
|
|
OnBootSec=5m
|
|
OnUnitActiveSec=15m
|
|
AccuracySec=5m
|
|
|
|
[Install]
|
|
WantedBy=timers.target
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgb34591d" class="outline-2">
|
|
<h2 id="orgb34591d">SSH Agent</h2>
|
|
<div class="outline-text-2" id="text-orgb34591d">
|
|
</div>
|
|
<div id="outline-container-org10e8ec0" class="outline-3">
|
|
<h3 id="org10e8ec0">Service</h3>
|
|
<div class="outline-text-3" id="text-org10e8ec0">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=SSH key agent
|
|
|
|
[Service]
|
|
Type=simple
|
|
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
|
|
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
|
|
|
|
[Install]
|
|
WantedBy=default.target
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orge82b3ac" class="outline-2">
|
|
<h2 id="orge82b3ac">Powertop</h2>
|
|
<div class="outline-text-2" id="text-orge82b3ac">
|
|
</div>
|
|
<div id="outline-container-orgd482b17" class="outline-3">
|
|
<h3 id="orgd482b17">Service</h3>
|
|
<div class="outline-text-3" id="text-orgd482b17">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Powertop tunings
|
|
|
|
[Service]
|
|
ExecStart=/usr/bin/powertop --auto-tune
|
|
RemainAfterExit=true
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgd4b9d58" class="outline-2">
|
|
<h2 id="orgd4b9d58">Mopidy</h2>
|
|
<div class="outline-text-2" id="text-orgd4b9d58">
|
|
</div>
|
|
<div id="outline-container-orgb1764a7" class="outline-3">
|
|
<h3 id="orgb1764a7">Service</h3>
|
|
<div class="outline-text-3" id="text-orgb1764a7">
|
|
<div class="org-src-container">
|
|
<pre class="src src-conf">[Unit]
|
|
Description=Mopidy music server
|
|
After=avahi-daemon.service
|
|
After=dbus.service
|
|
After=network.target
|
|
After=nss-lookup.target
|
|
After=pulseaudio.service
|
|
After=remote-fs.target
|
|
After=sound.target
|
|
|
|
[Service]
|
|
ExecStart=/usr/bin/mopidy --config ~/.config/mopidy/mopidy.conf
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="postamble" class="status">
|
|
<p class="author">Author: Dehaeze Thomas</p>
|
|
<p class="date">Created: 2020-05-26 mar. 08:40</p>
|
|
</div>
|
|
</body>
|
|
</html>
|