4 if [ "$user" != "www-data" ];
 
   6                 echo 'Error: run as www-data'
 
  10 if [ -f /tmp/repack-archive-logs.lock ]; then
 
  11         if [ "$(ps -p `cat /tmp/repack-archive-logs.lock` | wc -l)" -gt 1 ]; then
 
  12                 echo repack-archive-logs process is still running
 
  15                 # process not running, but lock file not deleted?
 
  16                 rm /tmp/repack-archive-logs.lock
 
  19 echo $$ >/tmp/repack-archive-logs.lock
 
  21 function signalExitCaught() {
 
  22  #Clean up in-process repack
 
  23  if [ "${file}" ]; then
 
  24    if [ -f "${file}" -a -f "${file%gz}xz" ]; then
 
  25      echo cleaning up in-process repack ${file%gz}xz
 
  32 trap signalExitCaught INT QUIT TERM
 
  34 for file in $(find /store/logs/ -mtime +60 -type f -name '*.gz'); do
 
  35     (gzip -dc "${file}" | xz -9e > "${file%gz}xz") && (touch --no-create --reference="${file}" "${file%gz}xz" && rm "${file}") || (rm "${file%gz}xz")
 
  38 rm /tmp/repack-archive-logs.lock