Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 407d9778e7
Fetching contributors…

Cannot retrieve contributors at this time

executable file 44 lines (34 sloc) 1.106 kb
#!/usr/bin/env bash
#automatically clear dd()'s output and re-run `tail -f` on it.
# [ see: http://api.lullabot.com/dd ]
if [[ $1 = '-h' || $1 = '--help' ]];then
echo "
Automatically empty and re-\`tail -f\` your [log_file], being careful about
file ownership.
Usage: $(basename $0) [log_file]
" >&2
exit 1
fi
httpd_uid() {
local usr env_conf
env_conf="/etc/apache2/envvars"
if [[ -r "$env_conf" && $(type id 2>/dev/null) ]];then
usr="$(grep export\ APACHE_RUN_USER= "$env_conf")"
printf '%s' "$(id -u ${usr/*=/})"
else
printf '33'
fi
}
# default values
def_file="/tmp/drupal_debug.txt"
def_uid="$(httpd_uid)" #uid for apache
# set values
(( $# )) || echo "... no params defaulting to: ${def_file}"
file="${1:-$def_file}" #default param
file_uid="$(stat -c %u "$file" 2>/dev/null)"
(( $file_uid )) || unset file_uid #avoid root owned file
uid="${file_uid:-$def_uid}"
# actual actions
echo "... using owner uid: $uid" #debug info
file "$file" >&/dev/null && sudo rm -v "$file" #empty out _existing_ file
sudo -u#${uid} touch "$file" && tail -f "$file"
Jump to Line
Something went wrong with that request. Please try again.