
Ich muss ein nicht-root-eigenes Verzeichnis in /var/run erstellen, das ein Startskript in /etc/init.d verwenden wird. Wie erreiche ich das richtig? Ich verwende Ubuntu 14.04.
Antwort1
Sie müssen dies im laufenden Betrieb tun. /var/run/
ist ein tmpfs, wird also bei jedem Booten neu erstellt.
Aus dem Init-Skript:
- Erstellen Sie darin ein Verzeichnis
/var/run/
und ändern Sie die Berechtigungen für diesen Benutzer. - Geben Sie dann an, dass
/var/run/mydaemon
anstelle von verwendet werden soll/var/run
.
Wenn Sie Beispiele zur Durchführung dieser Prüfung wünschen (es gibt noch mehr):
/etc/init.d/ssh
/etc/init.d/bind9
/etc/init/dbus.conf
/etc/init/ssh.conf
/etc/init/cups.conf
Alle haben eine Art von mkdir
darin. cups.conf:
mkdir -p /var/run/cups/certs
/etc/init/cups.conf
pre-start script
[ -x /usr/sbin/cupsd ]
# load modules for parallel port support
if [ -r /etc/default/cups ]; then
. /etc/default/cups
fi
if [ "$LOAD_LP_MODULE" = "yes" -a -f /usr/lib/cups/backend/parallel \
-a -f /proc/modules -a -x /sbin/modprobe ]; then
modprobe -q -b lp || true
modprobe -q -b ppdev || true
modprobe -q -b parport_pc || true
fi
mkdir -p /var/run/cups/certs
if [ -x /lib/init/apparmor-profile-load ]; then
/lib/init/apparmor-profile-load usr.sbin.cupsd
fi
end script