- #!/bin/sh
- binDir=/usr/bin/
- sleep=2
- pageCacheTables=(
- cache_pages
- cache_pagesection
- )
- sites=(
- /var/www/sites/live/www.somedomain.tld
- /var/www/sites/live/www.someotherdomain.tld
- /var/www/sites/live/www.yetsomeotherdomain.tld
- )
- len=${#sites[*]}
- pageCacheTablesLength=${#pageCacheTables[*]}
- i=0
- while [ $i -lt $len ]; do
- echo updating: ${sites[$i]}
- cd ${sites[$i]}
- rm typo3_src
- ln -s ../../sources/typo3_src-4.2.5 typo3_src
- echo generating new key
- k=0
- key=''
- while [ $k -lt 96 ]; do
- key=$key$(head -100 /dev/urandom | md5sum | cut -c1)
- let k++
- done
- echo key: $key
- sed -i "s/\(\$TYPO3_CONF_VARS\['SYS']\['encryptionKey'] = \).*/\1'$key';/g" typo3conf/localconf.php
- echo removing configuration cache
- rm -f typo3conf/temp_CACHED*
- echo clearing page cache
- # For some insane reason some values are enclosed in double qotes
- database=$(grep "typo_db " typo3conf/localconf.php | tail -1 | sed "s/^[^']*'\([^']*\)'.*/\1/" | grep '$typo_db =')
- if [ -z "$database" ] ; then
- database=$(grep "typo_db " typo3conf/localconf.php | tail -1 | sed "s/^[^']*'\([^']*\)'.*/\1/")
- else
- database=$(grep "typo_db " typo3conf/localconf.php | tail -1 | sed "s/^[^\"]*\"\([^\"]*\)\".*/\1/")
- fi
- username=$(grep "typo_db_username " typo3conf/localconf.php | tail -1 | sed "s/^[^']*'\([^']*\)'.*/\1/" | grep '$typo_db_username =')
- if [ -z "$username" ] ; then
- username=$(grep "typo_db_username " typo3conf/localconf.php | tail -1 | sed "s/^[^']*'\([^']*\)'.*/\1/")
- else
- username=$(grep "typo_db_username " typo3conf/localconf.php | tail -1 | sed "s/^[^\"]*\"\([^\"]*\)\".*/\1/")
- fi
- password=$(grep "typo_db_password " typo3conf/localconf.php | tail -1 | sed "s/^[^']*'\([^']*\)'.*/\1/" | grep '$typo_db_password =')
- if [ -z "$password" ] ; then
- password=$(grep "typo_db_password " typo3conf/localconf.php | tail -1 | sed "s/^[^']*'\([^']*\)'.*/\1/")
- else
- password=$(grep "typo_db_password " typo3conf/localconf.php | tail -1 | sed "s/^[^\"]*\"\([^\"]*\)\".*/\1/")
- fi
- j=0
- while [ $j -lt $pageCacheTablesLength ];
- do
- nice -n 19 ${binDir}mysql --batch -u$username -p"$password" -D$database -e "TRUNCATE ${pageCacheTables[$j]}"
- nice -n 19 ${binDir}mysql --batch -u$username -p"$password" -D$database -e "ALTER TABLE ${pageCacheTables[$j]} auto_increment=1"
- let j++
- done
- echo "done! Sleeping $sleep seconds . . ."
- sleep $sleep
- echo
- let i++
- done