postinstall.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. # ngIRCd Mac OS X postinstall/postupgrade script
  3. LDPLIST="/Library/LaunchDaemons/de.barton.ngircd.plist"
  4. if [ ! -e /etc/ngircd ]; then
  5. echo "Creating symlink: /opt/ngircd/etc -> /etc/ngircd"
  6. ln -s /opt/ngircd/etc /etc/ngircd || exit 1
  7. else
  8. echo "/etc/ngircd already exists. Don't create symlink."
  9. fi
  10. if [ ! -e /opt/ngircd/etc/ngircd.conf ]; then
  11. echo "Creating default configuration: /opt/ngircd/etc/ngircd.conf"
  12. cp /opt/ngircd/share/doc/ngircd/sample-ngircd.conf \
  13. /opt/ngircd/etc/ngircd.conf || exit 1
  14. else
  15. echo "/opt/ngircd/etc/ngircd.conf exists. Don't copy sample file."
  16. fi
  17. chmod o-rwx /opt/ngircd/etc/ngircd.conf
  18. if [ ! -e /opt/ngircd/etc/ngircd.pam ]; then
  19. echo "Creating default PAM configuration: /opt/ngircd/etc/ngircd.pam"
  20. echo "# PAM configuration for ngIRCd" >/opt/ngircd/etc/ngircd.pam
  21. echo "" >>/opt/ngircd/etc/ngircd.pam
  22. echo "auth required pam_permit.so" >>/opt/ngircd/etc/ngircd.pam
  23. echo "#auth required pam_opendirectory.so" >>/opt/ngircd/etc/ngircd.pam
  24. fi
  25. chmod 644 /opt/ngircd/etc/ngircd.pam
  26. if [ ! -e /etc/pam.d/ngircd ]; then
  27. echo "Linkint /opt/ngircd/etc/ngircd.pam to /etc/pam.d/ngircd"
  28. ln -s /opt/ngircd/etc/ngircd.pam /etc/pam.d/ngircd || exit 1
  29. fi
  30. if [ -f "$LDPLIST" ]; then
  31. echo "Fixing ownership and permissions of LaunchDaemon script ..."
  32. chown root:wheel "$LDPLIST" || exit 1
  33. chmod 644 "$LDPLIST" || exit 1
  34. fi
  35. if [ -f /tmp/ngircd_needs_restart ]; then
  36. echo "ngIRCd should be (re-)started ..."
  37. if [ -r "$LDPLIST" ]; then
  38. echo "LaunchDaemon script found, starting daemon ..."
  39. launchctl load -w "$LDPLIST" || exit 1
  40. echo "OK, LaunchDaemon script loaded successfully."
  41. else
  42. echo "LaunchDaemon script not installed. Can't start daemon."
  43. fi
  44. else
  45. echo "Not loading LaunchDaemon script."
  46. fi
  47. rm -f /tmp/ngircd_needs_restart
  48. # -eof-