wok-current rev 11906

squid: Improve package
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Wed Feb 29 22:08:35 2012 +0100 (2012-02-29)
parents 38ae68d5e1c0
children 88250b081917
files squid/receipt
line diff
     1.1 --- a/squid/receipt	Wed Feb 29 20:36:46 2012 +0100
     1.2 +++ b/squid/receipt	Wed Feb 29 22:08:35 2012 +0100
     1.3 @@ -40,6 +40,7 @@
     1.4  		--enable-ntlm-auth-helpers="smb_lm,no_check,fakeauth" \
     1.5  		--enable-useragent-log \
     1.6  		--enable-referer-log \
     1.7 +		--enable-icap-client \
     1.8  		--with-pthreads ac_cv_header_linux_netfilter_ipv4_h="yes" \
     1.9  		$CONFIGURE_ARGS &&
    1.10  	make $MAKEFLAGS && make install
    1.11 @@ -53,40 +54,65 @@
    1.12  	
    1.13  	touch $fs/var/log/squid/cache.log
    1.14  	
    1.15 -	cp -a $_pkg/etc $fs
    1.16 +	cp -a $install/etc $fs
    1.17  	rm -rf $fs/etc/squid/*.default
    1.18  	cp -a $stuff/etc $fs
    1.19  	
    1.20 -	cp -a $_pkg/var $fs
    1.21 -	cp -a $_pkg/usr/bin $fs/usr
    1.22 -	cp -a $_pkg/usr/sbin $fs/usr
    1.23 -	cp -a $_pkg/usr/lib/squid/*kd $fs/usr/lib/squid
    1.24 -	cp -a $_pkg/usr/lib/squid/*.cgi $fs/usr/lib/squid
    1.25 +	cp -a $install/var $fs
    1.26 +	cp -a $install/usr/bin $fs/usr
    1.27 +	cp -a $install/usr/sbin $fs/usr
    1.28 +	cp -a $install/usr/lib/squid/*kd $fs/usr/lib/squid
    1.29 +	cp -a $install/usr/lib/squid/*.cgi $fs/usr/lib/squid
    1.30  	
    1.31 -	cp -a $_pkg/usr/share/squid/mib.txt $fs/usr/share/squid
    1.32 -	cp -a $_pkg/usr/share/squid/icons $fs/usr/share/squid
    1.33 -	cp -a $_pkg/usr/share/squid/errors/templates $fs/usr/share/squid/errors
    1.34 -	cp -a $_pkg/usr/share/squid/errors/en* $fs/usr/share/squid/errors
    1.35 -	cp -a $_pkg/usr/share/squid/errors/fr* $fs/usr/share/squid/errors
    1.36 +	cp -a $install/usr/share/squid/mib.txt $fs/usr/share/squid
    1.37 +	cp -a $install/usr/share/squid/icons $fs/usr/share/squid
    1.38 +	cp -a $install/usr/share/squid/errors/templates $fs/usr/share/squid/errors
    1.39 +	cp -a $install/usr/share/squid/errors/en* $fs/usr/share/squid/errors
    1.40 +	cp -a $install/usr/share/squid/errors/fr* $fs/usr/share/squid/errors
    1.41  	
    1.42  	sed -i \
    1.43  		-e 's/TAG: visible_hostname/TAG: visible_hostname\nvisible_hostname slitaz/' \
    1.44  		-e 's|^access_log /var/logs|access_log /var/log/squid|' \
    1.45 -		-e 's|^# cache_store_log /var/logs|cache_store_log /var/cache/squid|' \
    1.46 -		-e 's|^# cache_log /var/logs|cache_log /var/cache/squid|' \
    1.47 -		-e 's|^# cache_dir ufs /var/cache|cache_dir ufs /var/cache/squid|' \
    1.48 -		-e 's|^# pid_filename /var/logs|pid_filename /var/run|' \
    1.49 -		-e 's|^coredump_dir /var/logs|coredump_dir /var/cache/squid|' \
    1.50 +		-e 's|^#cache_store_log /var/logs|cache_store_log /var/cache/squid|' \
    1.51 +		-e 's|^#cache_log /var/logs|cache_log /var/cache/squid|' \
    1.52 +		-e 's|^#cache_dir ufs /var/cache 100|cache_dir ufs /var/cache/squid 256|' \
    1.53 +		-e 's|^#pid_filename /var/logs|pid_filename /var/run/squid.pid|' \
    1.54 +		-e "s|^coredump_dir.*|coredump_dir /var/cache/squid|" \
    1.55 +		-e 's|^# error_directory|error_directory /usr/share/squid/errors/French|' \
    1.56  		-e 's|^# error_directory|error_directory /usr/share/squid/errors/French|' \
    1.57  		$fs/etc/squid/squid.conf
    1.58 +		
    1.59 +	cat <<EOF>>$fs/etc/squid/squid.conf
    1.60 +	
    1.61 +cache_effective_user squid
    1.62 +cache_effective_group squid 
    1.63 +
    1.64 +access_log /var/log/squid
    1.65 +EOF
    1.66  }
    1.67  
    1.68  # Pre and post install commands for Tazpkg.
    1.69  post_install()
    1.70  {
    1.71  	local root
    1.72 -	root=$1
    1.73 -	chown -R nobody.nogroup $root/var/cache/squid $root/var/log/squid
    1.74 +	local user
    1.75 +	local group
    1.76 +	
    1.77 +	user=squid
    1.78 +	group=squid
    1.79 +	
    1.80 +	if ! grep -q $user $1/etc/passwd; then
    1.81 +		echo -n "Adding user/group $user..."
    1.82 +		chroot $1/ addgroup -S $group
    1.83 +		chroot $1/ adduser -S -D -H -G $group $user
    1.84 +		status
    1.85 +	fi
    1.86 +	
    1.87 +
    1.88 +	# Set perms for files and directories
    1.89 +	chroot $1/ chown -R ${user}.${group} /var/log/squid \
    1.90 +		/var/cache/squid 
    1.91 +
    1.92  	cat <<EOF
    1.93  ----
    1.94  To start $PACKAGE server you can run :
    1.95 @@ -98,10 +124,14 @@
    1.96  EOF
    1.97  }
    1.98  
    1.99 +
   1.100  post_remove()
   1.101  {
   1.102  	echo "Removing stalled files..."
   1.103  	test -d /var/cache/squid && rm -rf /var/cache/squid
   1.104  	test -d /var/log/squid && rm -rf /var/log/squid
   1.105 -	test -d /usr/share/squid && rm -rf /usr/share/squid	
   1.106 +	test -d /usr/share/squid && rm -rf /usr/share/squid
   1.107 +	
   1.108 +	echo "Removing user/group squid"
   1.109 +	deluser squid
   1.110  }