diff options
author | Mattias Andrée <maandree@kth.se> | 2019-10-06 15:42:19 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-10-06 15:42:19 +0200 |
commit | 60f0fced886d2d5afd05cc157bee65f41869ce6d (patch) | |
tree | c6cf516c040002911d2184b6c96a4ba9a05c54ee /extra/restart-radharc | |
parent | typo (diff) | |
download | radharc-60f0fced886d2d5afd05cc157bee65f41869ce6d.tar.gz radharc-60f0fced886d2d5afd05cc157bee65f41869ce6d.tar.bz2 radharc-60f0fced886d2d5afd05cc157bee65f41869ce6d.tar.xz |
Rewrite everything
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rwxr-xr-x | extra/restart-radharc | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/extra/restart-radharc b/extra/restart-radharc deleted file mode 100755 index 96af888..0000000 --- a/extra/restart-radharc +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -# Copyright © 2016 Mattias Andrée <maandree@member.fsf.org> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# DEPENDENCIES: findutils, coreutils, sed, util-linux, linux, sh - -# Frequent international traveller? Set up cron to run this every -# now and then. It will restart all your instances of radharc, and -# if you have a custom script in $PATH named radharc (as your should -# have) that figures out your location and starts radharc, radharc -# will br aware of your no location. - - -# Close all file descriptors (except stderr,) so that radharc does not inherity any. -for fd in $(ls -1 /dev/fd/); do - if [ ! "$fd" = 2 ]; then - eval "exec ${fd}<&-"; - fi -done - -# Get the user's real UID, in a sh-portable way. -uid="$(cat /proc/self/status | grep '^Uid:' | cut -f 2)" - -# Restart all instances of radharc. -for pid in pgrep -x -U $uid radharc; do - # Open environ and cmdline and be sure that they we successfully opened. - # It is possible that the process has exited. - exec 3<proc/"$pid"/environ 2>/dev/null - if [ ! $? = 0 ]; then - continue - fi - exec 4<proc/"$pid"/cmdline 2>/dev/null - if [ ! $? = 0 ]; then - continue - fi - - # Restart radharc - (<&3 cat - printf 'radharc\x00' - <&4 xargs -0 printf '%s\n' | sed 1d | grep -v '^-n$' | xargs printf '%s\x00' - printf '%s\x00' '-n' - exec 3<&- - exec 4<&- - ) | (kill -KILL "$pid" ; exec xargs -0 setsid env -i -- <>/dev/null 2>/dev/null &) -done - |