path: rear_2.9+dfsg-3/usr/share/rear/restore/NFS4SERVER/default/500_stop_nfs_server.sh rpc.nfsd 0 || : kill $(pidof rpc.mountd) || : path: rear_2.9+dfsg-3/usr/share/rear/lib/linux-functions.sh # as first fallback do what start_udev does on RHEL 4 if has_binary udevstart ; then local udevd_pid=$( pidof -x udevd ) test "$udevd_pid" && kill $udevd_pid udevstart /dev/null && return 0 path: rear_2.9+dfsg-3/usr/sbin/rear # cf. https://github.com/rear/rear/issues/2826#issuecomment-1172138188 # This check is not meant to detect any possible way how another rear instance might have been called. for pid in $( pidof -x "$SCRIPT_FILE" "/usr/sbin/$PROGRAM" "usr/sbin/$PROGRAM" "./usr/sbin/$PROGRAM" "./sbin/$PROGRAM" "./$PROGRAM" ) ; do if test "$pid" != $$ ; then echo "ERROR: $PROGRAM is already running with PID $pid, not starting again" >&2 path: rear_2.9+dfsg-3/usr/sbin/rear # ... 3132 ... /usr/sbin/sshd -o PidFile=/var/run/sshd.init.pid # ... 3622 ... sshd: root@pts/1 # # pidof -x sshd # 3622 3132 # # pidof -x /usr/sbin/sshd path: rear_2.9+dfsg-3/usr/sbin/rear # # pidof -x in/sshd # 3622 3132 # In contrast pidof in openSUSE Leap 15.3 checks exactly what was specified when it contains a path: # # ps auxw | grep ssh # ... 2991 ... /usr/bin/ssh-agent /usr/bin/gpg-agent --sh --daemon --keep-display /etc/X11/xinit/xinitrc path: rear_2.9+dfsg-3/usr/sbin/rear # In this case pidof is needed to test what running instances are there: if ! type pidof 1>/dev/null ; then echo "ERROR: Required program 'pidof' missing" >&2 exit 1 fi path: rear_2.9+dfsg-3/usr/sbin/rear # # pidof -x sshd # 3622 3132 # # pidof -x /usr/sbin/sshd # 3622 3132 # # pidof -x in/sshd path: rear_2.9+dfsg-3/usr/sbin/rear if ! test "$can_run_simultaneously" ; then # In this case pidof is needed to test what running instances are there: if ! type pidof 1>/dev/null ; then echo "ERROR: Required program 'pidof' missing" >&2 exit 1 path: rear_2.9+dfsg-3/usr/sbin/rear # # pidof -x "/usr/bin/ssh-agent" # 18219 2991 # # pidof -x "usr/bin/ssh-agent" # [no output] # We do not want to use only the basename 'rear' to avoid that pidof accidentally also shows path: rear_2.9+dfsg-3/usr/sbin/rear # so that a manual test is done to find out if another pid != $$ is running. # This test is only some best effort attempt to find what running instances are there # because what pidof finds depends how 'rear' is called and what pidof version is used. # For example pidof in SLES10 SP4 seems to only consider the basename: # # ps auxw | grep ssh path: rear_2.9+dfsg-3/usr/sbin/rear # # pidof -x /usr/sbin/sshd # 3622 3132 # # pidof -x in/sshd # 3622 3132 # In contrast pidof in openSUSE Leap 15.3 checks exactly what was specified when it contains a path: path: rear_2.9+dfsg-3/usr/sbin/rear # ... 2991 ... /usr/bin/ssh-agent /usr/bin/gpg-agent --sh --daemon --keep-display /etc/X11/xinit/xinitrc # ... 18219 ... /usr/bin/ssh-agent -D -a /run/user/1000/keyring/.ssh # # pidof -x "ssh-agent" # 18219 2991 # # pidof -x "/usr/bin/ssh-agent" path: rear_2.9+dfsg-3/usr/sbin/rear # # pidof -x "ssh-agent" # 18219 2991 # # pidof -x "/usr/bin/ssh-agent" # 18219 2991 # # pidof -x "usr/bin/ssh-agent" path: rear_2.9+dfsg-3/usr/sbin/rear # This test is only some best effort attempt to find what running instances are there # because what pidof finds depends how 'rear' is called and what pidof version is used. # For example pidof in SLES10 SP4 seems to only consider the basename: # # ps auxw | grep ssh # ... 3132 ... /usr/sbin/sshd -o PidFile=/var/run/sshd.init.pid path: rear_2.9+dfsg-3/usr/sbin/rear exit 1 fi # For unknown reasons '-o %PPID' does not work for pidof at least in SLES11 # so that a manual test is done to find out if another pid != $$ is running. # This test is only some best effort attempt to find what running instances are there path: rear_2.9+dfsg-3/usr/sbin/rear # test that this currently running instance does not run simultaneously with another instance: if ! test "$can_run_simultaneously" ; then # In this case pidof is needed to test what running instances are there: if ! type pidof 1>/dev/null ; then echo "ERROR: Required program 'pidof' missing" >&2 path: rear_2.9+dfsg-3/usr/sbin/rear # # pidof -x "usr/bin/ssh-agent" # [no output] # We do not want to use only the basename 'rear' to avoid that pidof accidentally also shows # other 'rear' programs which are not Relax-and-Recover but some different software. # Examples how 'rear' looks in the 'ps' output: path: rear_2.9+dfsg-3/usr/share/rear/conf/default.conf mountpoint mv pidof ps pwd path: rear_2.9+dfsg-3/usr/share/rear/skel/default/etc/scripts/system-setup.d/40-start-udev-or-load-modules.sh # when 'pidof' test for it so that usually there is no "Waiting for systemd-udevd" message: sleep 1 pidof systemd-udevd &>/dev/null && break echo "Waiting for systemd-udevd ($countdown) ... " # The second sleep results a total wait of two seconds for each for loop run: path: rear_2.9+dfsg-3/usr/share/rear/skel/default/etc/scripts/system-setup.d/40-start-udev-or-load-modules.sh for countdown in 4 3 2 1 0 ; do # The first sleep waits one second in any case so that systemd-udevd should be usually there # when 'pidof' test for it so that usually there is no "Waiting for systemd-udevd" message: sleep 1 pidof systemd-udevd &>/dev/null && break path: rear_2.9+dfsg-3/usr/share/rear/skel/default/etc/scripts/system-setup.d/40-start-udev-or-load-modules.sh sleep 1 done if pidof -s systemd-udevd &>/dev/null ; then # check if daemon is actually running my_udevtrigger path: rear_2.9+dfsg-3/usr/share/rear/restore/NFS4SERVER/default/300_start_nfs_server.sh Debug "nfsd started with $nfs_threads threads." if [ -z "$(pidof rpc.mountd)" ]; then rpc.mountd --debug all "${nfsd_opts[@]}" || Error "rpc.mountd failed!" fi