fix for git puffing and add date in SA scripts
[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     test_or_die "making directory: $DEFAULT_FEISTYMEOW_ORG_DIR"
23   fi
24
25   # iterate across the list of dirs we want fred to own and change their ownership.
26   for dirname in /home/fred $DEFAULT_FEISTYMEOW_ORG_DIR /usr/local/fred /home/games $arch_addin; do
27     if [ -d "$dirname" ]; then
28       echo "refred on '$dirname'"
29       sudo chown -R fred:fred "$dirname"
30       test_or_die "chowning for fred: $dirname"
31     fi
32   done
33
34   # special case for archives directory.
35   if [ -d /z/stuffing -o -L /z/stuffing ]; then
36     sudo chown fred:fred /z
37     test_or_die "chowning /z for fred"
38     sudo chmod g+rx,o+rx /z
39     test_or_die "chmodding /z/ for fred"
40     sudo chown fred:fred /z/stuffing
41     test_or_die "chowning /z/stuffing for fred"
42     sudo chmod g+rx,o-rwx /z/stuffing
43     test_or_die "chmodding /z/stuffing for fred"
44     pushd /z/stuffing &>/dev/null
45     if [ -d archives -o -L archives ]; then
46       sudo chown fred:fred archives
47       test_or_die "chowning /z/stuffing/archives for fred"
48       sudo chmod -R g+rwx archives
49       test_or_die "chmodding /z/stuffing/archives for fred"
50     fi
51     popd &>/dev/null
52   fi
53
54   # make the logs readable by normal humans.
55   sudo bash $FEISTY_MEOW_SCRIPTS/security/normal_perm.sh /var/log
56   test_or_die "setting normal perms on /var/log"
57 }
58
59 # this block should execute when the script is actually run, rather
60 # than when it's just being sourced.
61 if [[ $0 =~ .*refred\.sh.* ]]; then
62   THISDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"
63   source "$THISDIR/../../core/launch_feisty_meow.sh"
64   test_or_die "sourcing the feisty meow launcher"
65   refred
66   test_or_die "refredding process"
67 fi
68