PolipoPostflight 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/man/man1
  38. ln -sf $MAN1/*.1 .
  39. if [ -d /Library/StartupItems/Polipo ]; then
  40. find /Library/StartupItems/Polipo -print0 | xargs -0 chown root:wheel
  41. fi
  42. # Copy Uninstaller
  43. if [ -f $PACKAGE_PATH/Contents/Resources/uninstall_polipo_bundle.sh ]; then
  44. cp $PACKAGE_PATH/Contents/Resources/uninstall_polipo_bundle.sh $TARGET/uninstall_polipo_bundle.sh
  45. chmod 755 $TARGET/uninstall_polipo_bundle.sh
  46. fi