nice fixes
[feisty_meow.git] / scripts / customize / fred / refred.sh
1 #!/bin/bash
2
3 #source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
4
5 # cleans up the ownership for all my files and dirs.
6 function refred()
7 {
8   # first build a list of dirs based on their location in /home/archives.
9   local arch_builder="archons basement codebarn games imaginations musix pooling prewar_toaster stuffing toaster walrus"
10   local ARCHIVE_HOME=/home/archives
11   local dirname
12   local arch_addin
13   for dirname in $arch_builder; do
14     arch_addin+="$ARCHIVE_HOME/$dirname "
15   done
16 #echo arch addin now is: $arch_addin
17
18   # iterate across the list of dirs we want fred to own and change their ownership.
19   for dirname in /home/fred /usr/local/fred /home/games $arch_addin; do
20     if [ -d "$dirname" ]; then
21       echo "refred on '$dirname'"
22       sudo chown -R fred:fred $dirname
23     fi
24   done
25
26   # special case for archives directory.
27   if [ -d /z/stuffing -o -L /z/stuffing ]; then
28     chmod g+rx /z
29     chmod g+rwx /z/stuffing
30     pushd /z/stuffing &>/dev/null
31     if [ -d archives -o -L archives ]; then group_perm archives; fi
32     popd &>/dev/null
33   fi
34
35   # make the logs readable by normal humans.
36   sudo bash $FEISTY_MEOW_SCRIPTS/security/normal_perm.sh /var/log
37 }
38
39 # this block should execute when the script is actually run, rather
40 # than when it's just being sourced.
41 if [[ $0 =~ .*refred\.sh.* ]]; then
42   THISDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"
43   source "$THISDIR/../../core/launch_feisty_meow.sh"
44   refred
45 fi
46