5 # Purpose : execute all tasks necessary following installation of
8 # Copyright : Written by and Copyright (C) 2001-2012 the
9 # Privoxy team. http://www.privoxy.org/
11 # This program is free software; you can redistribute it
12 # and/or modify it under the terms of the GNU General
13 # Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at
15 # your option) any later version.
17 # This program is distributed in the hope that it will
18 # be useful, but WITHOUT ANY WARRANTY; without even the
19 # implied warranty of MERCHANTABILITY or FITNESS FOR A
20 # PARTICULAR PURPOSE. See the GNU General Public
21 # License for more details.
23 # The GNU General Public License should be included with
24 # this file. If not, you can view it at
25 # http://www.gnu.org/copyleft/gpl.html
26 # or write to the Free Software Foundation, Inc.,
27 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
30 # Modification : If you modify this file please consider whether your
31 # changes ought to be passed back to the macsetup module.
34 # This postinstall script:
36 # 1. Moves config files into place, respecting any existing user config
37 # 2. Creates links to documentation in the app folder
38 # 3. Detects the version of OS X on which we're installing
39 # 4. Creates the logfile if not found and sets its ownership and persmissions
40 # 5. Disables the startup method not necessary for the host's OS X version and start Privoxy
41 # 6. Writes the package name into the uninstall script
42 # 7. Opens the readme.rtf file for the user to read
44 # preinstall created this file; continue to append to it in this script
45 logfile='/var/privoxy_installation.log'
47 # 1. Move config files into place, setting ownership and permissions, respecting any existing user config
49 for i in default.action default.filter match-all.action config trust user.action user.filter templates; do
50 if [ "$i" = "default.action" ] || [ "$i" = "default.filter" ] || [ "$i" = "match-all.action" ] ; then
51 # for the files a Mac user is very unlikely to have changed, overwrite existing, older versions
52 echo 'Installing config file (overwriting existing file if present):' $i >> ${logfile}
53 /bin/rm -f /usr/local/etc/privoxy/$i
54 /usr/bin/install -c -m 0664 -o privoxy -g privoxy /usr/local/etc/privoxy/vanilla/$i /usr/local/etc/privoxy || exit 1;
55 elif [ "$i" = "templates" ]; then
56 # for the templates subfolder copy across all the templates as .new if they already exist
57 for j in `ls -A /usr/local/etc/privoxy/vanilla/templates`; do
58 if [ -s "/usr/local/etc/privoxy/templates/"$j ]; then
59 # if the template exists in the destination then copy it in as <filename>.new
60 echo 'Installing template file with .new extension:' $j >> ${logfile}
61 /usr/bin/install -c -m 0664 -o privoxy -g privoxy /usr/local/etc/privoxy/vanilla/templates/$j /usr/local/etc/privoxy/templates/$j.new || exit 1
63 # if the template doesn't exist in the destination then just copy it across
64 echo 'Installing template file:' $j >> ${logfile}
65 /usr/bin/install -c -m 0664 -o privoxy -g privoxy /usr/local/etc/privoxy/vanilla/templates/$j /usr/local/etc/privoxy/templates/$j || exit 1
68 elif [ -s "/usr/local/etc/privoxy/"$i ]; then
69 # for all other files, if they already exist in the destination then copy them in as <filename>.new
70 echo 'Installing config file with .new extension:' $i >> ${logfile}
71 /usr/bin/install -c -m 0664 -o privoxy -g privoxy /usr/local/etc/privoxy/vanilla/$i /usr/local/etc/privoxy/$i.new || exit 1
73 # for all files that don't already exist just copy them across
74 echo 'Installing config file:' $i >> ${logfile}
75 /usr/bin/install -c -m 0664 -o privoxy -g privoxy /usr/local/etc/privoxy/vanilla/$i /usr/local/etc/privoxy || exit 1
78 # delete the vanilla config files
79 /bin/rm -rf /usr/local/etc/privoxy/vanilla >> ${logfile} 2>&1
81 # 2. Create links to documentation and log file in the app folder
83 ln /usr/local/share/doc/privoxy/AUTHORS /Applications/Privoxy/
84 ln /usr/local/share/doc/privoxy/ChangeLog /Applications/Privoxy/
85 ln -s /usr/local/share/doc/privoxy/privoxy-index.html /Applications/Privoxy/Privoxy\ Documentation.html
86 ln /usr/local/share/doc/privoxy/LICENSE /Applications/Privoxy/
87 ln -s /var/log/privoxy/logfile.log /Applications/Privoxy/logfile.log
89 # 3. Detect the version of OS X on which we're installing
91 darwin_major_rel_num="`/usr/bin/uname -r | /usr/bin/sed 's/\..*//'`"
93 # 4. Create logfile if not found and set its ownership and persmissions
95 if [ ! -d /var/log/privoxy ]; then
96 echo 'Creating Privoxy logfile directory' >> ${logfile}
97 /bin/mkdir -m 0755 /var/log/privoxy >> ${logfile} 2>&1
99 echo 'Creating Privoxy logfile and setting owner and permissions' >> ${logfile}
100 /usr/bin/touch /var/log/privoxy/logfile.log >> ${logfile} 2>&1
101 /usr/sbin/chown privoxy:privoxy /var/log/privoxy/logfile.log >> ${logfile} 2>&1
102 /bin/chmod 0644 /var/log/privoxy/logfile.log >> ${logfile} 2>&1
104 # 5. Disable the startup method not necessary for the host's OS X version and start Privoxy
106 case "${darwin_major_rel_num}" in
107 # Mac OS X 10.7, 10.6, 10.5
109 # delete Privoxy StartupItem
110 echo 'Delete the Privoxy StartupItem since it is not required for this OS X version' >> ${logfile}
111 if [ -d /Library/StartupItems/Disabled/Privoxy ]; then
112 /bin/rm -rf /Library/StartupItems/Disabled/Privoxy >> ${logfile} 2>&1
114 /bin/rm -rf /Library/StartupItems/Privoxy >> ${logfile} 2>&1
115 # start Privoxy using launchd
116 echo 'Start Privoxy via the LaunchDaemon' >> ${logfile}
117 /bin/launchctl load /Library/LaunchDaemons/org.ijbswa.privoxy.plist >> ${logfile} 2>&1
119 # Mac OS X 10.4, 10.3
121 # can safely delete this since these older OS X releases do not support launchd anyway
122 echo 'Delete the Privoxy LaunchDaemon since it is not required for this OS X version' >> ${logfile}
123 /bin/rm -f /Library/LaunchDaemons/org.ijbswa.privoxy.plist
124 # start Privoxy using StartupItem
125 echo 'Start Privoxy via the StartupItem' >> ${logfile}
126 /Library/StartupItems/Privoxy/Privoxy start >> ${logfile} 2>&1
133 # 6. Write the package name into the uninstall script
137 # 7. Open the readme.rtf file for the user to read
138 /usr/bin/su $USER -c "/usr/bin/open /Applications/Privoxy/readme.rtfd"
140 /bin/mv ${logfile} /Applications/Privoxy/install.log