2f00854a2c675b44ff9738dd50460cae6de3571b
[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   # special case that makes our software hierarchy folder, if it doesn't exist.
19   # everything else is only re-permed if it exists.
20   if [ ! -d "$DEFAULT_FEISTYMEOW_ORG_DIR" ]; then
21     sudo mkdir "$DEFAULT_FEISTYMEOW_ORG_DIR"
22   fi
23
24   # iterate across the list of dirs we want fred to own and change their ownership.
25   for dirname in /home/fred $DEFAULT_FEISTYMEOW_ORG_DIR /usr/local/fred /home/games $arch_addin; do
26     if [ -d "$dirname" ]; then
27       echo "refred on '$dirname'"
28       sudo chown -R fred:fred $dirname
29     fi
30   done
31
32   # special case for archives directory.
33   if [ -d /z/stuffing -o -L /z/stuffing ]; then
34     sudo chown fred:fred /z; sudo chmod g+rx,o+rx /z
35     sudo chown fred:fred /z/stuffing; sudo chmod g+rx,o-rwx /z/stuffing
36     pushd /z/stuffing &>/dev/null
37     if [ -d archives -o -L archives ]; then
38       sudo chown fred:fred archives
39       sudo chmod -R g+rwx archives
40     fi
41     popd &>/dev/null
42   fi
43
44   # make the logs readable by normal humans.
45   sudo bash $FEISTY_MEOW_SCRIPTS/security/normal_perm.sh /var/log
46 }
47
48 # this block should execute when the script is actually run, rather
49 # than when it's just being sourced.
50 if [[ $0 =~ .*refred\.sh.* ]]; then
51   THISDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"
52   source "$THISDIR/../../core/launch_feisty_meow.sh"
53   refred
54 fi
55