#!/bin/sh
# ====================[ chmodown-www                       ]====================
#                     [ Time-stamp: "2008-12-16 22:25:51 leycec" ]

# --------------------( CONFIGURATION                      )--------------------
USER=leycec
GROUP=apache

# ....................{ CONSTANTS                          }....................
SCRIPT_NAME=$(basename "$0")
SCRIPT_VERSION="0.0.1"

# ....................{ I/O HANDLING                       }....................
mutter() {
  echo -n "${SCRIPT_NAME}: $*"
}

utter() {
  if [ -n "$IS_CRON" ]
  then logger -p cron.notice "${SCRIPT_NAME}: $*"
  else echo "${SCRIPT_NAME}: $*"
  fi
}

curse() {
  if [ -n "$IS_CRON" ]
  then logger -p cron.err "${SCRIPT_NAME}! $*"
  else echo "${SCRIPT_NAME}! $*" 1>&2
  fi
}

# --------------------( IMPLEMENTATION                     )--------------------
chmodown_safe() {
  utter "safe chmodowning '$1' to $USER:$GROUP..."
  sudo chown --recursive $USER:$GROUP "$1"
  sudo chmod --recursive u+rwX,g+rX,o-rwX "$1"
}

chmodown_full() {
  utter "full chmodowning '$1' to $USER:$GROUP..."
  sudo chown --recursive $USER:$GROUP "$1"
  sudo chmod --recursive ug+rwX,o-rwX  "$1"
}

# Drupal is not a "permissions fiend." Consequently, we can get away with this.
chmodown_safe /home/leycec/var/www/
chmodown_safe /home/leycec/pub/code/organicmechanics.com/

# Oddmuse is, at the moment, a "permissions fiend." Listing which files and
# paths, precisely, require group-writeable permissions is beyond me at the
# moment. This'll have to do.
chmodown_full /home/leycec/pub/code/raiazome.com/

# --------------------( COPYRIGHT AND LICENSE              )--------------------
# The information below applies to everything in this distribution,
# except where noted.
#              
# Copyleft 2008 by B.w.Curry.
#   
#   http://www.raiazome.com
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
