~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/dist/util/setfileperm.sh

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Set file permissions of Grid Engine distribution
 
4
#
 
5
#___INFO__MARK_BEGIN__
 
6
##########################################################################
 
7
#
 
8
#  The Contents of this file are made available subject to the terms of
 
9
#  the Sun Industry Standards Source License Version 1.2
 
10
#
 
11
#  Sun Microsystems Inc., March, 2001
 
12
#
 
13
#
 
14
#  Sun Industry Standards Source License Version 1.2
 
15
#  =================================================
 
16
#  The contents of this file are subject to the Sun Industry Standards
 
17
#  Source License Version 1.2 (the "License"); You may not use this file
 
18
#  except in compliance with the License. You may obtain a copy of the
 
19
#  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
20
#
 
21
#  Software provided under this License is provided on an "AS IS" basis,
 
22
#  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
23
#  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
24
#  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
25
#  See the License for the specific provisions governing your rights and
 
26
#  obligations concerning the Software.
 
27
#
 
28
#  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
29
#
 
30
#  Copyright: 2001 by Sun Microsystems, Inc.
 
31
#
 
32
#  All Rights Reserved.
 
33
#
 
34
##########################################################################
 
35
#___INFO__MARK_END__
 
36
#
 
37
#
 
38
# The $OPTFILES are not mandatory for a distribution and will be set only if
 
39
# they exist
 
40
#
 
41
# This script must be called by user root on a machine where user root has
 
42
# permissions to change the ownership of a file
 
43
 
44
# It is not necessary to run this script if the distribtuon has been
 
45
# installed with pkgadd, since pkgadd takes care about the correct
 
46
# permissions.
 
47
#
 
48
 
 
49
PATH=/bin:/usr/bin:/usr/sbin
 
50
 
 
51
FILELIST="3rd_party bin ckpt examples inst_sge install_execd install_qmaster \
 
52
          lib mpi pvm qmon util utilbin"
 
53
 
 
54
OPTFILES="catman doc include man"  
 
55
 
 
56
SUIDFILES="utilbin/*/rsh utilbin/*/rlogin utilbin/*/testsuidroot bin/*/sgepasswd utilbin/*/authuser"
 
57
 
 
58
umask 022
 
59
 
 
60
#---------------------------------------------------
 
61
# SetFilePerm
 
62
#
 
63
SetFilePerm()
 
64
{
 
65
   f="$1"
 
66
   user="0"
 
67
   group="0"
 
68
 
 
69
   $ECHO "Verifying and setting file permissions and owner in >$f<"
 
70
 
 
71
   chmod -R go+r $f
 
72
   find $f -type d -exec chmod 755 {} \;
 
73
   find $f -type f -perm -100 -exec chmod go+x {} \;
 
74
   chown -R $user $f
 
75
   chgrp -R $group $f
 
76
}
 
77
 
 
78
#---------------------------------------------------------------------
 
79
# MAIN MAIN
 
80
#
 
81
 
 
82
instauto=false
 
83
 
 
84
if [ -z "$SGE_ROOT" -o ! -d "$SGE_ROOT" ]; then
 
85
   echo 
 
86
   echo ERROR: Please set your \$SGE_ROOT environment variable
 
87
   echo and start this script again. Exit.
 
88
   echo 
 
89
   exit 1
 
90
fi
 
91
 
 
92
if [ ! -f "$SGE_ROOT/util/arch" ]; then
 
93
   echo 
 
94
   echo ERROR: The shell script \"$SGE_ROOT/util/arch\" does not exist.
 
95
   echo Please verify your distribution and restart this script. Exit.
 
96
   echo
 
97
   exit 1
 
98
fi
 
99
 
 
100
if [ ! -f $SGE_ROOT/util/arch_variables ]; then
 
101
   echo
 
102
   echo ERROR: Missing shell script \"$SGE_ROOT/util/arch_variables\".
 
103
   echo Please verify your distribution and restart this script. Exit.
 
104
   echo
 
105
   exit 1
 
106
fi
 
107
 
 
108
. $SGE_ROOT/util/arch_variables
 
109
 
 
110
if [ $ARCH = "win32-x86" ]; then
 
111
   echo
 
112
   echo "ERROR: Using this script on windows is not supported!"
 
113
   echo "Please execute this script on a unix host"
 
114
   echo
 
115
   exit 1
 
116
fi
 
117
 
 
118
if [ $# -lt 1 ]; then
 
119
   echo
 
120
   echo Set file permissions and owner of Grid Engine distribution in \$SGE_ROOT
 
121
   echo 
 
122
   echo "usage: $0 [-auto] <sge_root>"
 
123
   echo 
 
124
   echo example: $0 \$SGE_ROOT
 
125
   echo
 
126
   exit 1
 
127
fi
 
128
 
 
129
if [ $1 = -auto ]; then
 
130
   instauto=true
 
131
   shift
 
132
fi
 
133
 
 
134
if [ $1 = / -o $1 = /etc ]; then
 
135
   echo
 
136
   echo ERROR: cannot set permissions in \"$1\" directory of your system.
 
137
   echo
 
138
   exit 1
 
139
fi
 
140
 
 
141
if [ `echo $1 | env LC_ALL=C cut -c1` != / ]; then
 
142
   echo
 
143
   echo ERROR: Please give an absolute path for the distribution.
 
144
   echo
 
145
   exit 1
 
146
fi
 
147
 
 
148
 
 
149
if [ $instauto = true ]; then
 
150
   :
 
151
else
 
152
   clear
 
153
   $ECHO "                    WARNING WARNING WARNING"
 
154
   $ECHO "                    -----------------------"
 
155
   $ECHO "We will set the the file ownership and permission to"
 
156
   $ECHO
 
157
   $ECHO "   UserID:         0"
 
158
   $ECHO "   GroupID:        0"
 
159
   $ECHO "   In directory:   $1"
 
160
   $ECHO
 
161
   $ECHO "We will also install the following binaries as SUID-root:"
 
162
   $ECHO
 
163
   $ECHO "   \$SGE_ROOT/utilbin/<arch>/rlogin"
 
164
   $ECHO "   \$SGE_ROOT/utilbin/<arch>/rsh"
 
165
   $ECHO "   \$SGE_ROOT/utilbin/<arch>/testsuidroot"
 
166
   $ECHO "   \$SGE_ROOT/bin/<arch>/sgepasswd"
 
167
   $ECHO "   \$SGE_ROOT/bin/<arch>/authuser"
 
168
   $ECHO
 
169
 
 
170
   TEXT="Do you want to set the file permissions (yes/no) [NO] >> \c"
 
171
 
 
172
   YesNo_done=false
 
173
   while [ $YesNo_done = false ]; do
 
174
      $ECHO "$TEXT" 
 
175
      read YesNo_INP
 
176
      if [ "$YesNo_INP" = "yes" -o "$YesNo_INP" = YES ]; then
 
177
         YesNo_done=true
 
178
      elif [ "$YesNo_INP" = "NO" -o "$YesNo_INP" = no ]; then
 
179
         $ECHO
 
180
         $ECHO "We will NOT set the file permissions. Exiting."
 
181
         exit 1
 
182
      fi
 
183
   done
 
184
fi
 
185
 
 
186
cd $1
 
187
if [ $? != 0 ]; then
 
188
   $ECHO "ERROR: can't change to directory \"$1\". Exiting."
 
189
   exit 1
 
190
fi
 
191
 
 
192
for f in $FILELIST; do
 
193
   if [ ! -f $f -a ! -d $f ]; then
 
194
      $ECHO
 
195
      $ECHO "Obviously this is not a complete Grid Engine distribution or this"
 
196
      $ECHO "is not your \$SGE_ROOT directory."
 
197
      $ECHO
 
198
      $ECHO "Missing file or directory: $f"
 
199
      $ECHO
 
200
      $ECHO "Your file permissions will not be set. Exit."
 
201
      $ECHO
 
202
      exit 1
 
203
   fi
 
204
done
 
205
 
 
206
for f in $FILELIST $OPTFILES; do
 
207
   if [ -d $f -o -f $f ]; then
 
208
      SetFilePerm $f 
 
209
   fi
 
210
done
 
211
 
 
212
for file in $SUIDFILES; do
 
213
   # Windows NFS Server does not like suid files
 
214
   if [ "`echo $file | grep win32-x86`" != "" ]; then
 
215
      chmod 511 $file
 
216
   else
 
217
      chmod 4511 $file
 
218
   fi
 
219
done
 
220
 
 
221
$ECHO
 
222
$ECHO "Your file permissions were set"
 
223
$ECHO