5 # Purpose : execute all tasks necessary prior to installation of
8 # Copyright : Written by and Copyright (C) 2001-2013 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 iOSPackageBuilder
35 # This preinstall script:
36 # 1. Shuts down Privoxy if it's running
37 # 2. Backs up any existing log & configuration files
39 # create installation log file
40 logfile='/var/privoxy_installation.log'
41 echo 'Privoxy installation on' `/bin/date` > ${logfile}
43 # 1. Stop the Privoxy service if it's running
45 echo 'Stopping Privoxy via LaunchDaemon.' >> ${logfile}
46 /bin/launchctl unload /Library/LaunchDaemons/org.ijbswa.privoxy.plist >> ${logfile} 2>&1
48 # 2. Back up any existing log & configuration files
50 if [ -f /var/log/privoxy/logfile.log ]; then
51 echo 'Backing up existing logfile' >> ${logfile}
52 /bin/cp /var/log/privoxy/logfile.log /var/log/privoxy/logfile.old >> ${logfile} 2>&1
53 /usr/sbin/chown privoxy:privoxy /var/log/privoxy/logfile.old >> ${logfile} 2>&1
55 if [ -d /usr/local/etc/privoxy ]; then
56 for i in config match-all.action trust user.action user.filter; do
57 echo 'Backing up existing config file:' ${i} >> ${logfile}
58 if [ -f /usr/local/etc/privoxy/$i ]; then
59 /bin/cp /usr/local/etc/privoxy/$i /usr/local/etc/privoxy/$i.old >> ${logfile} 2>&1
60 /usr/sbin/chown privoxy:privoxy /usr/local/etc/privoxy/$i.old >> ${logfile} 2>&1
63 echo 'Backing up existing config templates' >> ${logfile}
64 /bin/cp -R /usr/local/etc/privoxy/templates /usr/local/etc/privoxy/templates.old >> ${logfile} 2>&1
65 /usr/sbin/chown -R privoxy:privoxy /usr/local/etc/privoxy/templates.old >> ${logfile} 2>&1