From: "Ulrich Müller" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/emacs-tools:emacs-daemon commit in: /
Date: Wed, 02 Jul 2025 16:23:04 +0000 (UTC) [thread overview]
Message-ID: <1751472636.15268344aedf48ed8d73f57f7e39882f7d61b4a3.ulm@gentoo> (raw)
commit: 15268344aedf48ed8d73f57f7e39882f7d61b4a3
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 2 16:10:36 2025 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Wed Jul 2 16:10:36 2025 +0000
URL: https://gitweb.gentoo.org/proj/emacs-tools.git/commit/?id=15268344
Use default functions
* emacs.rc (start, stop): Removed; use start-stop-daemon's default
functions instead.
(command, command_args, command_background, command_user)
(directory, pidfile, retry): Define variables expected by them.
(pidfile): Use the standard location. Now that the pid file is
owned by root, we no longer need a user-writable subdirectory.
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
ChangeLog | 9 +++++++++
emacs.conf | 4 ----
emacs.rc | 47 +++++++++++++----------------------------------
3 files changed, 22 insertions(+), 38 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d4c4455..eddac9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-07-02 Ulrich Müller <ulm@gentoo.org>
+
+ * emacs.rc (start, stop): Removed; use start-stop-daemon's default
+ functions instead.
+ (command, command_args, command_background, command_user)
+ (directory, pidfile, retry): Define variables expected by them.
+ (pidfile): Use the standard location. Now that the pid file is
+ owned by root, we no longer need a user-writable subdirectory.
+
2025-06-28 Ulrich Müller <ulm@gentoo.org>
* emacs.rc (start_pre): POSIX shell does not support "local".
diff --git a/emacs.conf b/emacs.conf
index 54a4880..56d8c5b 100644
--- a/emacs.conf
+++ b/emacs.conf
@@ -12,10 +12,6 @@
# in order to read the user's profile. #246460
#EMACS_START="/usr/libexec/emacs/emacs-wrapper.sh"
-# Optionally, you may execute a custom script before stopping the
-# daemon. #246462
-#EMACS_STOP=""
-
# Timeout (in seconds) to wait for termination of the daemon
#EMACS_TIMEOUT="30"
diff --git a/emacs.rc b/emacs.rc
index 16c8524..2c8af7d 100644
--- a/emacs.rc
+++ b/emacs.rc
@@ -7,26 +7,31 @@
: "${EMACS_SHELL=/bin/bash}"
: "${EMACS_START:=/usr/libexec/emacs/emacs-wrapper.sh}"
: "${EMACS_TIMEOUT:=30}"
-USER=${RC_SVCNAME##*.}
-PIDFILE_DIR=/var/run/emacs/${USER}
-PIDFILE=${PIDFILE_DIR}/emacs.pid
description="Start an Emacs server running in the background"
+command=${EMACS_START}
+command_args=${EMACS_OPTS}
+command_background=true
+command_user=${RC_SVCNAME##*.}
+directory="~${command_user}"
+pidfile=/var/run/${RC_SVCNAME}.pid
+retry=TERM/${EMACS_TIMEOUT}/KILL/5
+
depend() {
need localmount
after bootmisc dbus
}
start_pre() {
- if [ "${USER}" = "${RC_SVCNAME}" ]; then
+ if [ "${command_user}" = "${RC_SVCNAME}" ]; then
eerror "You have to create an init script for each user:"
eerror "ln -s emacs /etc/init.d/emacs.<user>"
return 1
fi
- if ! id -u "${USER}" >/dev/null; then
- eerror "${USER}: No such user"
+ if ! id -u "${command_user}" >/dev/null; then
+ eerror "${command_user}: No such user"
return 1
fi
@@ -40,37 +45,11 @@ start_pre() {
return 1
fi
- checkpath -d --owner 0 --mode 0755 "${PIDFILE_DIR%/*}"
- checkpath -d --owner 0 --mode 0755 "${PIDFILE_DIR}"
-}
-
-start() {
- SHELL=${EMACS_SHELL:-$(awk -F: "\$1 == \"${USER}\" { print \$7 }" \
- /etc/passwd)}
+ SHELL=${EMACS_SHELL:-$(awk -F: \
+ "\$1 == \"${command_user}\" { print \$7 }" /etc/passwd)}
export SHELL EMACS
# XDG_RUNTIME_DIR points to /run/user/0 which is not writable for us
# Unset it, otherwise Emacs would try to create its server socket there
unset XDG_RUNTIME_DIR
-
- ebegin "Starting Emacs daemon for user ${USER}"
- start-stop-daemon --start --background --make-pidfile \
- --user "${USER}" --pidfile "${PIDFILE}" --chdir "~${USER}" \
- --exec "${EMACS_START}" -- ${EMACS_OPTS}
- eend $?
-}
-
-stop() {
- # Optionally, call a custom script before stopping.
- if [ "${EMACS_STOP}" ] && [ -x "${EMACS_STOP}" ]; then
- export USER PIDFILE EMACS EMACS_TIMEOUT
- ebegin "Calling Emacs stop script for ${USER}"
- "${EMACS_STOP}"
- eend $? || return
- fi
-
- ebegin "Stopping Emacs daemon for user ${USER}"
- start-stop-daemon --stop --retry "TERM/${EMACS_TIMEOUT}/KILL/5" \
- --user "${USER}" --pidfile "${PIDFILE}" --exec "${EMACS}"
- eend $?
}
next reply other threads:[~2025-07-02 16:23 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 16:23 Ulrich Müller [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-07-02 16:23 [gentoo-commits] proj/emacs-tools:emacs-daemon commit in: / Ulrich Müller
2025-07-02 16:23 Ulrich Müller
2025-06-28 18:41 Ulrich Müller
2025-03-14 22:27 Ulrich Müller
2025-03-14 22:27 Ulrich Müller
2025-03-10 12:03 Ulrich Müller
2025-03-09 20:48 Ulrich Müller
2025-03-07 16:58 Ulrich Müller
2025-03-05 15:56 Ulrich Müller
2025-03-05 13:36 Ulrich Müller
2025-03-05 13:08 Ulrich Müller
2025-03-05 13:08 Ulrich Müller
2018-12-09 22:36 Ulrich Müller
2018-09-16 14:49 Ulrich Müller
2016-06-08 6:43 Ulrich Müller
2016-05-06 13:20 Ulrich Müller
2016-05-06 13:20 Ulrich Müller
2016-05-06 13:20 Ulrich Müller
2014-02-02 11:29 Ulrich Müller
2014-02-02 11:29 Ulrich Müller
2013-08-06 19:09 Ulrich Mueller
2013-08-06 19:09 Ulrich Mueller
2013-03-23 22:08 Ulrich Mueller
2013-03-23 22:08 Ulrich Mueller
2013-03-23 22:08 Ulrich Mueller
2013-03-23 22:08 Ulrich Mueller
2012-07-21 9:01 Ulrich Mueller
2012-07-21 9:01 Ulrich Mueller
2012-05-06 18:47 Ulrich Mueller
2012-05-06 18:14 Ulrich Mueller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1751472636.15268344aedf48ed8d73f57f7e39882f7d61b4a3.ulm@gentoo \
--to=ulm@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox