2

So this error occurs when installing Prey Anti-theft software:

Installing init scripts.
dpkg: error processing package prey (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 prey

You can use this link to understand the error message.

So this error message tells us there is an error with the post-installation script...which does not help us very much.

Has anybody encountered such a problem before and know how to remedy it? (Similar questions have been posted on the forum at https://help.preyproject.com/topics but without any useful answers)

-- Edit --

This is the prey.postinst script:

    #!/bin/bash -x
####################################################################
# Prey Debian Postinst Script
# Written by Tomás Pollak <tomas@forkhq.com> - (c) 2011 Fork Ltd.
# License: GPLv3
####################################################################

set -e

VERSION='1.3.8'
BASE_PATH="/usr/lib/prey"
INSTALL_PATH="${BASE_PATH}/versions/${VERSION}"
PREY_BIN="bin/prey"
PREY_USER="prey"
TEMP_OLD_CONFIG="/tmp/prey-config.old"

get_current_user() {
  export PS_FORMAT=user:16,command
  ps ax | grep ssh-agent | grep -v grep | cut -d' ' -f1 | head -1
}

case "$1" in
  configure)

    if [ -d /usr/share/prey ]; then
      echo "Previous installation found. Removing..."

      if [ -f /usr/share/prey/config.backup ]; then
        cp /usr/share/prey/config.backup "$TEMP_OLD_CONFIG"
      else
        cp /usr/share/prey/config "$TEMP_OLD_CONFIG" || true
      fi

      if [ -f "$TEMP_OLD_CONFIG" ]; then
        chmod 666 "$TEMP_OLD_CONFIG"
      fi

      # remove from root crontab
      (crontab -l 2> /dev/null | grep -v prey || true) | crontab -

      # remove from prey crontab, if present
      if test "$(id ${PREY_USER} 2> /dev/null)"; then
        (crontab -u $PREY_USER -l 2> /dev/null | grep -v prey || true) | crontab -u $PREY_USER -
      fi

      # wipe out old folder
      rm -Rf /usr/share/prey
    fi

    cd "$INSTALL_PATH"

    # as root, set up init script and activate current installation
    "$PREY_BIN" config hooks post_install

    # check if API_KEY env var was passed
    if [ -n "$API_KEY" ]; then 

      echo "API Key detected! Verifying..."
      "$PREY_BIN" config account authorize -a "$API_KEY"

    else # no API key, so let's show up the GUI

      # before firing gui, allow prey user to access current X screen
      if [ -n "$(which xhost)" ]; then
        CURRENT_USER=$(get_current_user)
        if [ -n "$CURRENT_USER" ]; then
          su $CURRENT_USER -c "DISPLAY=:0.0 xhost +si:localuser:${PREY_USER}" || true
        fi
      fi

      # run config gui as prey user, previously checking for old config keys
      DISPLAY=:0.0 su $PREY_USER -c "$PREY_BIN config gui --check-file $TEMP_OLD_CONFIG"

    fi

    rm -f "$TEMP_OLD_CONFIG"
  ;;

  abort-upgrade|abort-remove|abort-deconfigure)
  ;;

  *)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 1
  ;;

esac

exit 0
7
  • I assume you attemted to install using APT. So you could have a look at the DEBIAN/postinst script in /var/cache/apt/packages/prey_something.deb – s3lph Apr 20 '15 at 19:32
  • Yes, I used APT, however, there is not a single .deb file with 'prey' in it in my /var/ path. Do you know of another place where to find DEBIAN/postinst scripts? – MichaelDeSanta Apr 20 '15 at 20:49
  • Sorry, there is a prey.postinst file. What should I look for in this file? – MichaelDeSanta Apr 20 '15 at 20:51
  • What version and where did you get this package? The one in ubuntu 14.04's postinst looks nothing like what you show. – psusi Apr 22 '15 at 2:16
  • This is available from the Prey website. Prey for Ubuntu 64 bit. Inside DEBIAN/postinst – MichaelDeSanta Apr 22 '15 at 7:40
4

I looked into the prey.postinst script, found in /var/lib/dpkg/info, and used set -x to locate the error. There seemed to be something wrong with Line 72 :

DISPLAY=:0.0 su $PREY_USER -c "$PREY_BIN config gui --check-file $TEMP_OLD_CONFIG"

After commenting this line I was able to finish the installation (sudo apt-get install -f).

I also deleted the prey-config-XXXXXXXXXXXXXXX.log files that were located in my /temp/ folder (if available)

-- EDIT --

So with the_Seppi's help I have changed the line as follows:

env DISPLAY=:0.0 gksu $PREY_USER "$PREY_BIN config gui --check-file $TEMP_OLD_CONFIG"

The installation can then be completed using sudo dpkg --configure -a

6
  • "There seemed to be something wrong with Line 72" Did you receive any error? Btw. this line should never be executed in the way it is written there. If a GUI application (I assume it is one because of the display var) needs elevated privileges, it should always use gksu instead of su. – s3lph Apr 21 '15 at 12:04
  • Try adding the command env in front of the DISPLAY=, and replace su by gksu (you may have to install gksu beforehand), then rerun the script by installing the modified Debian package over the currently installed version. – s3lph Apr 21 '15 at 12:06
  • I will try to implement your suggestions. However, I don't know how I would have to "rerun the script by installing the modified Debian package over the currently installed version". Using sudo dpkg --configure -a? – MichaelDeSanta Apr 21 '15 at 12:46
  • Oh, I just now saw that you found the script in /var/lib/dpkg/info... My bad. Yes, this should run run the script. – s3lph Apr 21 '15 at 12:49
  • Btw, is su [user] -c the correct order? gksu is correct in this order, but it doesn't take the -c command – MichaelDeSanta Apr 21 '15 at 12:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.