summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2015-12-16 16:05:52 -0500
committerBryan McLellan <btm@loftninjas.org>2015-12-16 16:05:52 -0500
commit83a0e3f00e8530bb0b9d0736847be0b429434d76 (patch)
tree71f9474c1ccca62a1d3979f6ba0de201e87f8825
parent98dfbd031c8d641e5125c37434bfb162adbbc923 (diff)
parent287068733929d43052873d5bfde69ce85a967891 (diff)
downloadchef-83a0e3f00e8530bb0b9d0736847be0b429434d76.tar.gz
Merge pull request #563 from chef/btm/fix-postinst
Fix regression with postinst script
-rw-r--r--config/projects/angrychef.rb1
-rw-r--r--config/projects/chef-fips.rb1
-rwxr-xr-xjenkins/verify-chef.sh29
-rwxr-xr-xpackage-scripts/angrychef/postinst115
-rwxr-xr-xpackage-scripts/angrychef/postrm42
-rwxr-xr-xpackage-scripts/chef-fips/postinst115
-rwxr-xr-xpackage-scripts/chef-fips/postrm42
-rwxr-xr-xpackage-scripts/chef/postinst2
8 files changed, 325 insertions, 22 deletions
diff --git a/config/projects/angrychef.rb b/config/projects/angrychef.rb
index 65420c15f5..c585c73040 100644
--- a/config/projects/angrychef.rb
+++ b/config/projects/angrychef.rb
@@ -36,7 +36,6 @@ else
end
resources_path "#{resources_path}/../chef"
-package_scripts_path "#{package_scripts_path}/../chef"
msi_upgrade_code = "D7FDDC1A-7668-404E-AD2F-61F875632A9C"
project_location_dir = "angrychef"
diff --git a/config/projects/chef-fips.rb b/config/projects/chef-fips.rb
index d61a217b6e..6461a79ae5 100644
--- a/config/projects/chef-fips.rb
+++ b/config/projects/chef-fips.rb
@@ -39,4 +39,3 @@ project_location_dir = "chef-fips"
# Use chef's scripts for everything.
resources_path "#{resources_path}/../chef"
-package_scripts_path "#{package_scripts_path}/../chef"
diff --git a/jenkins/verify-chef.sh b/jenkins/verify-chef.sh
index 0170a3476e..b2c48651c2 100755
--- a/jenkins/verify-chef.sh
+++ b/jenkins/verify-chef.sh
@@ -19,26 +19,17 @@ else
fi
export USR_BIN_DIR
-# sanity check that we're getting symlinks from the pre-install script
-if [ ! -L $USR_BIN_DIR/chef-client ]; then
- echo "$USR_BIN_DIR/chef-client symlink was not installed by pre-install script!"
- exit 1
-fi
-
-if [ ! -L "$USR_BIN_DIR/knife" ]; then
- echo "$USR_BIN_DIR/knife symlink was not installed by pre-install script!"
- exit 1
-fi
-
-if [ ! -L "$USR_BIN_DIR/chef-solo" ]; then
- echo "$USR_BIN_DIR/chef-solo symlink was not installed by pre-install script!"
- exit 1
-fi
+# sanity check that we're getting the correct symlinks from the pre-install script
+linked_binaries=( "chef-client" "knife" "chef-solo" "ohai" )
-if [ ! -L "$USR_BIN_DIR/ohai" ]; then
- echo "$USR_BIN_DIR/ohai symlink was not installed by pre-install script!"
- exit 1
-fi
+for i in "${linked_binaries[@]}"
+do
+ LINK_TARGET=`readlink $USR_BIN_DIR/$i`
+ if [ "$LINK_TARGET" != "$EMBEDDED_BIN_DIR/$i" ]; then
+ echo "$USR_BIN_DIR/$i symlink to $EMBEDDED_BIN_DIR/$i was not correctly created by the pre-install script!"
+ exit 1
+ fi
+done
# Ensure the calling environment (disapproval look Bundler) does not
# infect our Ruby environment created by the `chef-client` cli.
diff --git a/package-scripts/angrychef/postinst b/package-scripts/angrychef/postinst
new file mode 100755
index 0000000000..c0fc3f5525
--- /dev/null
+++ b/package-scripts/angrychef/postinst
@@ -0,0 +1,115 @@
+#!/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.
+#
+# Install a full Opscode Client
+#
+
+PROGNAME=`basename $0`
+INSTALLER_DIR=/opt/angrychef
+CONFIG_DIR=/etc/chef
+USAGE="usage: $0 [-v validation_key] ([-o organization] || [-u url])"
+
+error_exit()
+{
+ echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
+ exit 1
+}
+
+is_darwin()
+{
+ uname -v | grep "^Darwin" 2>&1 >/dev/null
+}
+
+is_smartos()
+{
+ uname -v | grep "^joyent" 2>&1 >/dev/null
+}
+
+if is_smartos; then
+ PREFIX="/opt/local"
+elif is_darwin; then
+ PREFIX="/usr/local"
+ mkdir -p "$PREFIX/bin"
+else
+ PREFIX="/usr"
+fi
+
+validation_key=
+organization=
+chef_url=
+
+while getopts o:u:v: opt
+do
+ case "$opt" in
+ v) validation_key="${OPTARG}";;
+ o) organization="${OPTARG}"; chef_url="https://api.opscode.com/organizations/${OPTARG}";;
+ u) chef_url="${OPTARG}";;
+ \?) # unknown flag
+ echo >&2 ${USAGE}
+ exit 1;;
+ esac
+done
+shift `expr ${OPTIND} - 1`
+
+if [ "" != "$chef_url" ]; then
+ mkdir -p ${CONFIG_DIR} || error_exit "Cannot create ${CONFIG_DIR}!"
+ (
+ cat <<'EOP'
+log_level :info
+log_location STDOUT
+EOP
+ ) > ${CONFIG_DIR}/client.rb
+ if [ "" != "$chef_url" ]; then
+ echo "chef_server_url '${chef_url}'" >> ${CONFIG_DIR}/client.rb
+ fi
+ if [ "" != "$organization" ]; then
+ echo "validation_client_name '${organization}-validator'" >> ${CONFIG_DIR}/client.rb
+ fi
+ chmod 644 ${CONFIG_DIR}/client.rb
+fi
+
+if [ "" != "$validation_key" ]; then
+ cp ${validation_key} ${CONFIG_DIR}/validation.pem || error_exit "Cannot copy the validation key!"
+ chmod 600 ${CONFIG_DIR}/validation.pem
+fi
+
+# rm -f before ln -sf is required for solaris 9
+rm -f $PREFIX/bin/chef-client
+rm -f $PREFIX/bin/chef-solo
+rm -f $PREFIX/bin/chef-apply
+rm -f $PREFIX/bin/chef-shell
+rm -f $PREFIX/bin/knife
+rm -f $PREFIX/bin/shef
+rm -f $PREFIX/bin/ohai
+
+ln -sf $INSTALLER_DIR/bin/chef-solo $PREFIX/bin || error_exit "Cannot link chef-solo to $PREFIX/bin"
+if [ -f "$INSTALLER_DIR/bin/chef-apply" ]; then
+ ln -sf $INSTALLER_DIR/bin/chef-apply $PREFIX/bin || error_exit "Cannot link chef-apply to $PREFIX/bin"
+fi
+if [ -f "$INSTALLER_DIR/bin/chef-shell" ]; then
+ ln -sf $INSTALLER_DIR/bin/chef-shell $PREFIX/bin || error_exit "Cannot link chef-shell to $PREFIX/bin"
+fi
+ln -sf $INSTALLER_DIR/bin/knife $PREFIX/bin || error_exit "Cannot link knife to $PREFIX/bin"
+if [ -f "$INSTALLER_DIR/bin/shef" ]; then
+ ln -sf $INSTALLER_DIR/bin/shef $PREFIX/bin || error_exit "Cannot link shef to $PREFIX/bin"
+fi
+ln -sf $INSTALLER_DIR/bin/ohai $PREFIX/bin || error_exit "Cannot link ohai to $PREFIX/bin"
+
+# We test for the presence of /usr/bin/chef-client to know if this script succeeds, so this
+# must appear as the last real action in the script
+ln -sf $INSTALLER_DIR/bin/chef-client $PREFIX/bin || error_exit "Cannot link chef-client to $PREFIX/bin"
+
+# Ensure all files/directories in $INSTALLER_DIR are owned by root. This
+# has been fixed on new installs but upgrades from old installs need to
+# be manually fixed.
+chown -Rh 0:0 $INSTALLER_DIR
+
+echo "Thank you for installing Chef!"
+
+exit 0
diff --git a/package-scripts/angrychef/postrm b/package-scripts/angrychef/postrm
new file mode 100755
index 0000000000..724c082be7
--- /dev/null
+++ b/package-scripts/angrychef/postrm
@@ -0,0 +1,42 @@
+#!/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.
+
+is_smartos() {
+ uname -v | grep "^joyent" 2>&1 >/dev/null
+}
+
+is_darwin()
+{
+ uname -v | grep "^Darwin" 2>&1 >/dev/null
+}
+
+if is_smartos; then
+ PREFIX="/opt/local"
+elif is_darwin; then
+ PREFIX="/usr/local"
+else
+ PREFIX="/usr"
+fi
+
+cleanup_symlinks() {
+ binaries="chef-client chef-solo chef-apply chef-shell knife shef ohai"
+ for binary in $binaries; do
+ rm -f $PREFIX/bin/$binary
+ done
+}
+
+# Clean up binary symlinks if they exist
+# see: http://tickets.opscode.com/browse/CHEF-3022
+if [ ! -f /etc/redhat-release -a ! -f /etc/fedora-release -a ! -f /etc/system-release -a ! -f /etc/SuSE-release ]; then
+ # not a redhat-ish RPM-based system
+ cleanup_symlinks
+elif [ "x$1" = "x0" ]; then
+ # RPM-based system and we're deinstalling rather than upgrading
+ cleanup_symlinks
+fi
diff --git a/package-scripts/chef-fips/postinst b/package-scripts/chef-fips/postinst
new file mode 100755
index 0000000000..6f13382b61
--- /dev/null
+++ b/package-scripts/chef-fips/postinst
@@ -0,0 +1,115 @@
+#!/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.
+#
+# Install a full Opscode Client
+#
+
+PROGNAME=`basename $0`
+INSTALLER_DIR=/opt/chef-fips
+CONFIG_DIR=/etc/chef
+USAGE="usage: $0 [-v validation_key] ([-o organization] || [-u url])"
+
+error_exit()
+{
+ echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
+ exit 1
+}
+
+is_darwin()
+{
+ uname -v | grep "^Darwin" 2>&1 >/dev/null
+}
+
+is_smartos()
+{
+ uname -v | grep "^joyent" 2>&1 >/dev/null
+}
+
+if is_smartos; then
+ PREFIX="/opt/local"
+elif is_darwin; then
+ PREFIX="/usr/local"
+ mkdir -p "$PREFIX/bin"
+else
+ PREFIX="/usr"
+fi
+
+validation_key=
+organization=
+chef_url=
+
+while getopts o:u:v: opt
+do
+ case "$opt" in
+ v) validation_key="${OPTARG}";;
+ o) organization="${OPTARG}"; chef_url="https://api.opscode.com/organizations/${OPTARG}";;
+ u) chef_url="${OPTARG}";;
+ \?) # unknown flag
+ echo >&2 ${USAGE}
+ exit 1;;
+ esac
+done
+shift `expr ${OPTIND} - 1`
+
+if [ "" != "$chef_url" ]; then
+ mkdir -p ${CONFIG_DIR} || error_exit "Cannot create ${CONFIG_DIR}!"
+ (
+ cat <<'EOP'
+log_level :info
+log_location STDOUT
+EOP
+ ) > ${CONFIG_DIR}/client.rb
+ if [ "" != "$chef_url" ]; then
+ echo "chef_server_url '${chef_url}'" >> ${CONFIG_DIR}/client.rb
+ fi
+ if [ "" != "$organization" ]; then
+ echo "validation_client_name '${organization}-validator'" >> ${CONFIG_DIR}/client.rb
+ fi
+ chmod 644 ${CONFIG_DIR}/client.rb
+fi
+
+if [ "" != "$validation_key" ]; then
+ cp ${validation_key} ${CONFIG_DIR}/validation.pem || error_exit "Cannot copy the validation key!"
+ chmod 600 ${CONFIG_DIR}/validation.pem
+fi
+
+# rm -f before ln -sf is required for solaris 9
+rm -f $PREFIX/bin/chef-client
+rm -f $PREFIX/bin/chef-solo
+rm -f $PREFIX/bin/chef-apply
+rm -f $PREFIX/bin/chef-shell
+rm -f $PREFIX/bin/knife
+rm -f $PREFIX/bin/shef
+rm -f $PREFIX/bin/ohai
+
+ln -sf $INSTALLER_DIR/bin/chef-solo $PREFIX/bin || error_exit "Cannot link chef-solo to $PREFIX/bin"
+if [ -f "$INSTALLER_DIR/bin/chef-apply" ]; then
+ ln -sf $INSTALLER_DIR/bin/chef-apply $PREFIX/bin || error_exit "Cannot link chef-apply to $PREFIX/bin"
+fi
+if [ -f "$INSTALLER_DIR/bin/chef-shell" ]; then
+ ln -sf $INSTALLER_DIR/bin/chef-shell $PREFIX/bin || error_exit "Cannot link chef-shell to $PREFIX/bin"
+fi
+ln -sf $INSTALLER_DIR/bin/knife $PREFIX/bin || error_exit "Cannot link knife to $PREFIX/bin"
+if [ -f "$INSTALLER_DIR/bin/shef" ]; then
+ ln -sf $INSTALLER_DIR/bin/shef $PREFIX/bin || error_exit "Cannot link shef to $PREFIX/bin"
+fi
+ln -sf $INSTALLER_DIR/bin/ohai $PREFIX/bin || error_exit "Cannot link ohai to $PREFIX/bin"
+
+# We test for the presence of /usr/bin/chef-client to know if this script succeeds, so this
+# must appear as the last real action in the script
+ln -sf $INSTALLER_DIR/bin/chef-client $PREFIX/bin || error_exit "Cannot link chef-client to $PREFIX/bin"
+
+# Ensure all files/directories in $INSTALLER_DIR are owned by root. This
+# has been fixed on new installs but upgrades from old installs need to
+# be manually fixed.
+chown -Rh 0:0 $INSTALLER_DIR
+
+echo "Thank you for installing Chef!"
+
+exit 0
diff --git a/package-scripts/chef-fips/postrm b/package-scripts/chef-fips/postrm
new file mode 100755
index 0000000000..724c082be7
--- /dev/null
+++ b/package-scripts/chef-fips/postrm
@@ -0,0 +1,42 @@
+#!/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.
+
+is_smartos() {
+ uname -v | grep "^joyent" 2>&1 >/dev/null
+}
+
+is_darwin()
+{
+ uname -v | grep "^Darwin" 2>&1 >/dev/null
+}
+
+if is_smartos; then
+ PREFIX="/opt/local"
+elif is_darwin; then
+ PREFIX="/usr/local"
+else
+ PREFIX="/usr"
+fi
+
+cleanup_symlinks() {
+ binaries="chef-client chef-solo chef-apply chef-shell knife shef ohai"
+ for binary in $binaries; do
+ rm -f $PREFIX/bin/$binary
+ done
+}
+
+# Clean up binary symlinks if they exist
+# see: http://tickets.opscode.com/browse/CHEF-3022
+if [ ! -f /etc/redhat-release -a ! -f /etc/fedora-release -a ! -f /etc/system-release -a ! -f /etc/SuSE-release ]; then
+ # not a redhat-ish RPM-based system
+ cleanup_symlinks
+elif [ "x$1" = "x0" ]; then
+ # RPM-based system and we're deinstalling rather than upgrading
+ cleanup_symlinks
+fi
diff --git a/package-scripts/chef/postinst b/package-scripts/chef/postinst
index a941f3a884..88016f6c03 100755
--- a/package-scripts/chef/postinst
+++ b/package-scripts/chef/postinst
@@ -11,7 +11,7 @@
#
PROGNAME=`basename $0`
-INSTALLER_DIR="/opt/$PROGNAME"
+INSTALLER_DIR=/opt/chef
CONFIG_DIR=/etc/chef
USAGE="usage: $0 [-v validation_key] ([-o organization] || [-u url])"