Compatibility with macOS 11 and adding more recent PCRE
[OSXPackageBuilder.git] / pkg resources / single-binary scripts / postinstall
index 215a189..4469c6d 100755 (executable)
 #                USA
 #
 # Modification : If you modify this file please consider whether your 
-#                changes ought to be passed back to the macsetup module.
+#                changes ought to be passed back to the OSXPackageBuilder
+#                module.
 #
 
 #  This postinstall script:
 #
 #  1. Moves config files into place, respecting any existing user config
-#  2. Creates links to documentation in the app folder
-#  3. Detects the version of OS X on which we're installing
-#  4. Creates the logfile if not found and sets its ownership and persmissions
+#  2. Detects the version of OS X on which we're installing
+#  3. Creates the logfile if not found and sets its ownership and persmissions
+#  4. Creates links to documentation and log file in the app folder
 #  5. Disables the startup method not necessary for the host's OS X version and start Privoxy
-#  6. Writes the package name into the uninstall script
-#  7. Opens the readme.rtf file for the user to read
+#  6. Opens the readme.rtf file for the user to read
 
 # preinstall created this file; continue to append to it in this script
 logfile='/var/privoxy_installation.log'
@@ -47,8 +47,8 @@ logfile='/var/privoxy_installation.log'
 #  1. Move config files into place, setting ownership and permissions, respecting any existing user config
 #
 for i in default.action default.filter match-all.action config trust user.action user.filter templates; do
-       if [ "$i" = "default.action" ] || [ "$i" = "default.filter" ] || [ "$i" = "match-all.action" ] ; then
-               # for the files a Mac user is very unlikely to have changed, overwrite existing, older versions
+       if [ "$i" = "default.action" ] || [ "$i" = "default.filter" ] ; then
+               # for the files that the end user should not edit, overwrite existing, older versions
                echo 'Installing config file (overwriting existing file if present):' $i >> ${logfile}
                /bin/rm -f /usr/local/etc/privoxy/$i
                /usr/bin/install -c -m 0664 -o privoxy -g privoxy /usr/local/etc/privoxy/vanilla/$i /usr/local/etc/privoxy || exit 1;
@@ -78,34 +78,36 @@ done
 # delete the vanilla config files
 /bin/rm -rf /usr/local/etc/privoxy/vanilla >> ${logfile} 2>&1
 
-# 2. Create links to documentation and log file in the app folder
-#
-ln /usr/local/share/doc/privoxy/AUTHORS /Applications/Privoxy/
-ln /usr/local/share/doc/privoxy/ChangeLog /Applications/Privoxy/
-ln -s /usr/local/share/doc/privoxy/privoxy-index.html /Applications/Privoxy/Privoxy\ Documentation.html
-ln /usr/local/share/doc/privoxy/LICENSE /Applications/Privoxy/
-ln -s /var/log/privoxy/logfile.log /Applications/Privoxy/logfile.log
-
-# 3. Detect the version of OS X on which we're installing
+# 2. Detect the version of OS X on which we're installing
 #
 darwin_major_rel_num="`/usr/bin/uname -r | /usr/bin/sed 's/\..*//'`"
 
-# 4. Create logfile if not found and set its ownership and persmissions
+# 3. Create logfile if not found and set its ownership and persmissions, including an ACL to allow the _privoxy user to create files therein
 #
 if [ ! -d /var/log/privoxy ]; then
        echo 'Creating Privoxy logfile directory' >> ${logfile}
        /bin/mkdir -m 0755 /var/log/privoxy >> ${logfile} 2>&1
+       chmod +a "_privoxy allow list,add_file,search,read,readattr,readextattr,readsecurity" /var/log/privoxy >> ${logfile} 2>&1
 fi
 echo 'Creating Privoxy logfile and setting owner and permissions' >> ${logfile}
 /usr/bin/touch /var/log/privoxy/logfile.log >> ${logfile} 2>&1
 /usr/sbin/chown privoxy:privoxy /var/log/privoxy/logfile.log >> ${logfile} 2>&1
 /bin/chmod 0644 /var/log/privoxy/logfile.log >> ${logfile} 2>&1
 
+# 4. Create links to documentation and log file in the app folder
+#
+ln /usr/local/share/doc/privoxy/AUTHORS /Applications/Privoxy/
+ln /usr/local/share/doc/privoxy/ChangeLog /Applications/Privoxy/
+ln -s /usr/local/share/doc/privoxy/privoxy-index.html /Applications/Privoxy/Privoxy\ Documentation.html
+ln /usr/local/share/doc/privoxy/LICENSE /Applications/Privoxy/
+ln -s /var/log/privoxy/logfile.log /Applications/Privoxy/logfile.log
+
+
 # 5. Disable the startup method not necessary for the host's OS X version and start Privoxy
 #
 case "${darwin_major_rel_num}" in
   # Mac OS X 10.5 or higher
-  9|1*)
+  9|1*|2*|3*)
                # delete Privoxy StartupItem
                echo 'Delete the Privoxy StartupItem since it is not required for this OS X version' >> ${logfile}
                if [ -d /Library/StartupItems/Disabled/Privoxy ]; then
@@ -130,12 +132,8 @@ case "${darwin_major_rel_num}" in
     ;;
 esac
 
-# 6. Write the package name into the uninstall script
-#
-#TODO
-
-# 7. Open the readme.rtf file for the user to read
-/usr/bin/su $USER -c "/usr/bin/open /Applications/Privoxy/readme.rtfd"
+# 6. Open the readme.pdf file for the user to read
+/usr/bin/su $USER -c "/usr/bin/open /Applications/Privoxy/readme.pdf"
 
 /bin/mv ${logfile} /Applications/Privoxy/install.log