PolipoPostflight 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. # PolipoPostflight gets invoked after any install or upgrade.
  3. ADDSYSUSER=$RECEIPT_PATH/addsysuser
  4. if [ ! -x "$ADDSYSUSER" ]; then
  5. echo "Could not find addsysuser script."
  6. exit 1
  7. fi
  8. POLIPOUSER=_polipo
  9. POLIPOGROUP=daemon
  10. TARGET=$2/Library/Polipo
  11. LOGDIR=$TARGET/log
  12. # Check defaults for TARGET
  13. if [ "$TARGET" == "//Library/Polipo" ]; then
  14. TARGET=/Library/Polipo
  15. fi
  16. # Create user $POLIPOUSER in group daemon. If it's already there, great.
  17. $ADDSYSUSER $POLIPOUSER "Polipo System user" $POLIPODIR
  18. # Create the polipo direcpolipoy, if it doesn't exist.
  19. if [ ! -d $POLIPODIR ]; then
  20. mkdir -p $POLIPODIR
  21. fi
  22. if [ ! -d $LOGDIR ]; then
  23. mkdir -p $LOGDIR
  24. fi
  25. # Check its permissions.
  26. chown $POLIPOUSER $POLIPODIR
  27. chgrp daemon $POLIPODIR
  28. chmod 700 $POLIPODIR
  29. chown $POLIPOUSER $LOGDIR
  30. chgrp daemon $LOGDIR
  31. chmod 700 $LOGDIR
  32. # Create the configuration file only if there wasn't one already.
  33. if [ ! -f $TARGET/config]; then
  34. cp $TARGET/config.osx $TARGET/config
  35. fi
  36. cd /usr/share/man/man1
  37. MAN1=$TARGET/share/man/man1
  38. if [ -d /Library/StartupItems/Polipo ]; then
  39. find /Library/StartupItems/Polipo -print0 | xargs -0 chown root:wheel
  40. fi
  41. # Copy Uninstaller
  42. if [ -f $PACKAGE_PATH/Contents/Resources/uninstall_polipo_bundle.sh ]; then
  43. cp $PACKAGE_PATH/Contents/Resources/uninstall_polipo_bundle.sh $TARGET/uninstall_polipo_bundle.sh
  44. chmod 755 $TARGET/uninstall_polipo_bundle.sh
  45. fi