vprocunhide (2711B)
1 #!/bin/bash 2 # $Id$ 3 # 4 # Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; version 2 of the License. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 20 : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars} 21 test -e "$UTIL_VSERVER_VARS" || { 22 echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2 23 exit 1 24 } 25 . "$UTIL_VSERVER_VARS" 26 . "$_LIB_FUNCTIONS" 27 28 function showHelp() 29 { 30 echo $\ 31 "Usage: vprocunhide 32 33 Return values: 34 0 ... no errors 35 1 ... configuration error 36 2 ... some files were changed but errors occured on other ones 37 3 ... operation failed on every file 38 39 Report bugs to <$PACKAGE_BUGREPORT>." 40 exit 0 41 } 42 43 function showVersion() 44 { 45 echo \ 46 $"vprocunhide $PACKAGE_VERSION -- unhides /proc entries 47 This program is part of $PACKAGE_STRING 48 49 Copyright (C) 2004 Enrico Scholz 50 This program is free software; you may redistribute it under the terms of 51 the GNU General Public License. This program has absolutely no warranty." 52 exit 0 53 } 54 55 56 while test -n "$1"; do 57 case "$1" in 58 --help) showHelp;; 59 --version) showVersion;; 60 esac 61 done 62 63 findFile UNHIDEFILE \ 64 "$__CONFDIR"/.defaults/apps/vprocunhide/files \ 65 "$__PKGLIBDEFAULTDIR"/vprocunhide-files 66 67 ok=1 68 passed= 69 while read filename; do 70 params=() 71 72 case "$filename" in 73 (\#*) continue;; 74 (\~*) params=( --admin --watch --hide ); filename=${filename#\~};; 75 (-*) params=( --admin --hide ); filename=${filename#-};; 76 (:*) params=( --watch --hide ); filename=${filename#:};; 77 (!*) params=( --hide ); filename=${filename#!};; 78 (+*) params=( --!hide ); filename=${filename#+};; 79 (\>*) params=( --write ); filename=${filename#>};; 80 (*) params=( --!hide );; 81 esac 82 83 case "$filename" in 84 (*/) params=( "${params[@]}" -R );; 85 (*) ;; 86 esac 87 88 set -- $filename 89 test -e "$1" || continue 90 91 $_SETATTR -x "${params[@]}" "$@" && passed=1 || ok= 92 done <"$UNHIDEFILE" 93 94 test -n "$ok" && exit 0 || \ 95 test -n "$passed" && exit 2 || \ 96 exit 3