summaryrefslogtreecommitdiff
path: root/omnibus/package-scripts/chef/preinst
blob: e38c3f7a3e6414c4cea14e9056d2eb8f477dec0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# WARNING: REQUIRES /bin/sh
#
# - must run on /bin/sh on solaris 9
# - must run on /bin/sh on AIX 6.x
# - if you think you are a bash wizard, you probably do not understand
#   this programming language.  do not touch.
# - if you are under 40, get peer review from your elders.

INSTALLER_DIR=/opt/chef
if [ -e $INSTALLER_DIR ]; then
  echo "removing $INSTALLER_DIR..."

  # have to do this dance of moving /opt/chef to a tmp dir since files may be in use
  tmp_dir="/opt/.chef.$$"
  # if we can't create the tmp_dir then fail hard to prevent any possible security hole
  (umask 077 && mkdir $tmp_dir) || exit 1
  # now we can clean up the tmp_dir we created safely
  mv $INSTALLER_DIR $tmp_dir
  # ignore errors which must be EBUSY issues, this may crate some litter, which may
  # be unavoidable
  rm -rf $tmp_dir || true
fi