3 # install - installer for the DTraceToolkit
5 # This is a fairly simple script, most of it is error checking.
6 # All the script does is copy the DTraceToolkit files to another directory,
7 # with various checks. The user could have copied the files themselves, this
8 # script doesn't do anything special to them. It's really here in case
9 # people extrace the toolkit and go looking for an installer.
11 # 15-May-2005 Brendan Gregg Created this.
13 DEBUG=0 # print debug data
14 TEETH=1 # does this script have teeth
15 SLEEP=1 # pause on messages
18 ### Ensure we know where we are,
21 (( DEBUG )) && print "DEBUG: dir $dir"
24 print "DTraceToolkit Installation\n---------------------------"
26 print "\nhit Ctrl-C any time you wish to quit.\n\n"
29 print -n "Enter target directory for installation [/opt/DTT]: "
31 if [[ "$loc" == "" ]]; then loc="/opt/DTT"; fi
33 (( DEBUG )) && print "DEBUG: loc $loc"
36 if print "$loc" | grep '^[./]*$' > /dev/null; then
37 print "ERROR1: Location \"$loc\" is ambiguous.\n."
38 (( SLEEP )) && sleep 1
39 print ".\tTry a full path, like \"/opt/DTT\"\n."
45 if print "$loc" | grep '[^a-zA-Z0-9_.-/]' > /dev/null; then
46 print "ERROR2: Sorry, location \"$loc\" contains bad characters.\n."
47 (( SLEEP )) && sleep 1
48 print ".\tTry a path like \"/opt/DTT\"\n."
56 if [[ "$basename" == "" ]]; then basename="/"; fi
57 (( DEBUG )) && print "DEBUG: basename $basename"
58 (( DEBUG )) && print "DEBUG: nodename $nodename"
60 ### Check parent dir exists,
61 if [[ ! -d "$basename" ]]; then
62 print "ERROR3: Parent directory \"$basename\" does not exist!\n."
63 (( SLEEP )) && sleep 1
64 print ".\tI'm not sure what you want me to do here, if you were"
65 print ".\tserious about the above parent directory - then run"
66 print ".\ta \"mkdir -p $basename\" first, then rerun this script.\n."
71 ### Check parent dir perms,
72 if [[ ! -w "$basename" ]]; then
73 print "ERROR4: Can't write to parent directory \"$basename\"!\n."
74 (( SLEEP )) && sleep 1
75 print ".\tSince I can't write to this directory, I can't install the"
76 print ".\tDTraceToolkit. You are currently logged in as,\n."
78 print ".\n.\tand the directory has permissions,\n."
79 ls -ld "$basename" | awk '{ print ".\t\t",$1,$2,$3,$4,"..." }'
80 owner=`ls -ld "$basename" | awk '{ print $3 }'`
81 print ".\n.\tMaybe you need to run \"su - $owner\" first?\n."
86 ### Check if toolkit is already installed,
87 if [[ -d "$loc" ]]; then
88 print "Warning: Possible old version of the DTraceToolkit found."
89 print "\tThis will DELETE the files in $loc, then install the toolkit."
90 (( SLEEP )) && sleep 1
91 if [[ ! -f "$loc/Version" ]]; then
92 print "\nWARNING: $loc doesn't look like an old DTraceToolkit!"
93 (( SLEEP )) && sleep 1
95 print -n "\nContinue (will run \"rm -rf $loc\"). Are you sure (y/N)?: "
97 if [[ "$ans" != "y" ]]; then
104 print COMMAND: rm -rf \"$loc\"
108 ### Make new toolkit dir,
109 print "\nMaking directory \"$loc\"...\n"
113 print COMMAND: mkdir -p \"$loc\"
115 if [[ ! -d "$loc" || ! -w "$loc" ]]; then
116 print "ERROR6: Creation of \"$loc\" failed.\n."
117 (( SLEEP )) && sleep 1
118 print ".\tCheck directory location and try again.\n."
123 ### Copy files across,
124 print "\nCopying DTraceToolkit files...\n"
126 tar cf - . | (cd "$loc"; tar xvf -)
128 print COMMAND: "tar cf - . | (cd \"$loc\"; tar xvf -)"
131 if [[ ! -f "$loc/install" ]]; then error=1; fi
133 print "ERROR7: Failure during copy.\n."
134 (( SLEEP )) && sleep 1
135 print ".\tCheck source \"$dir\" and destination \"$loc\", then"
136 print ".\ttry again.\n."
141 ### Delete installer,
145 print COMMAND: rm \"$loc/install\"
149 print "\nFinished.\n"
150 print "Installed to \"$loc\". See $loc/Guide for how to get started.\n"