Michael C. Toren on 6 Jan 2004 22:03:02 -0000 |
On Tue, Jan 06, 2004 at 03:11:11PM -0500, Stephen Gran wrote: > > I don't see how testing to see if your parent process is init will give > > you any insight into weather or not your script is being executed at boot > > time or not, unfortunately. What if a user types "exec > > /etc/init.d/whatever" from a console login shell? > > Well, that would actually be fine. The only thing I am trying to do is > have the script run at boot, but not be rerun on upgrade. If you don't mind being dependent on /proc and bash, perhaps: #!/bin/bash set -e pid=$$ while [ $pid -gt 1 ] do ppid=$(awk '/^PPid:/ {print $2}' /proc/$pid/status) tr '\0' ' ' < /proc/$pid/cmdline | awk '{print $1}' | \ awk -F/ '{print $NF}' | grep -q ^dpkg && exit 1 pid=$ppid done The above script traces it's lineage back to init, and if it finds an ancestor named "dpkg*", it dies with an exit status of 1. Otherwise, it exits cleanly. -mct ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|