Ticket #1365: patchphptmp.txt

File patchphptmp.txt, 1.8 kB (added by sci2tech, 5 months ago)

session files for master domain are not removed

Line 
1 --- ispcpphptemp.sh     2008-06-28 10:04:31.000000000 +0300
2 +++ /var/www/ispcp/engine/tools/ispcpphptemp.sh 2008-06-29 23:47:20.000000000 +0300
3 @@ -3,11 +3,11 @@
4  # read needed entries from ispcp.conf
5  if [ -f /usr/local/etc/ispcp/ispcp.conf ]
6  then
7 -       for a in `cat /usr/local/etc/ispcp/ispcp.conf  | grep -E '(^APACHE_WWW_DIR|^PHP_STARTER_DIR)' | sed -e 's/ //g'`; do
8 +       for a in `cat /usr/local/etc/ispcp/ispcp.conf  | grep -E '(^ROOT_DIR|^APACHE_WWW_DIR|^PHP_STARTER_DIR)' | sed -e 's/ //g'`; do
9                 export $a
10         done
11  else
12 -       for a in `cat /etc/ispcp/ispcp.conf | grep -E '(^APACHE_WWW_DIR|^PHP_STARTER_DIR)' | sed -e 's/ //g'`; do
13 +       for a in `cat /etc/ispcp/ispcp.conf | grep -E '(^ROOT_DIR|^APACHE_WWW_DIR|^PHP_STARTER_DIR)' | sed -e 's/ //g'`; do
14                 export $a
15         done
16  fi
17 @@ -19,7 +19,7 @@
18         tmpdir="${wdir}/phptmp"
19         fcgidir=${PHP_STARTER_DIR}`echo ${wdir} | awk "-F${APACHE_WWW_DIR}" '{print $2}'`
20  
21 -       if [ ! -f "${fcgidir}/php4/php.ini" ] && [ ! -f "${fcgidir}/php4/php.ini" ]; then
22 +       if [ ! -f "${fcgidir}/php4/php.ini" ] && [ ! -f "${fcgidir}/php5/php.ini" ]; then
23                 continue;
24         fi
25  
26 @@ -52,4 +52,25 @@
27         #else
28         #       nice -n 19 find ${tmpdir} -type f -cmin +24 -print0 | xargs -r -0 rm
29         #fi
30 -done
31 \ No newline at end of file
32 +done
33 +
34 +tmpdir="${ROOT_DIR}/gui/phptmp"
35 +fcgidir=${PHP_STARTER_DIR}/master
36 +if [ -f "${fcgidir}/php4/php.ini" ] || [ -f "${fcgidir}/php5/php.ini" ];then
37 +       cur=0
38 +       max=1440
39 +       for ini in "${fcgidir}/php4/php.ini ${fcgidir}/php5/php.ini"; do
40 +               if [ ! -f "$ini" ]; then
41 +                       continue;
42 +               fi
43 +               cur=$(sed -n -e 's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:space:]]*\([0-9]\+\).*$/\1/p' ${ini} 2>/dev/null || true);
44 +               if [ -z "$cur" ]; then
45 +                       cur=0
46 +               fi
47 +               if [ "$cur" -gt "$max" ]; then
48 +                       max=$cur
49 +               fi
50 +       done
51 +       max=$(($max/60))
52 +       nice -n 19 find ${tmpdir} -type f -cmin +${max} -print0 | xargs -r -0 rm
53 +fi