new script for developer user re-owning
[feisty_meow.git] / scripts / customize / developer / redeveloper.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 redeveloper()
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 developer to own and change their ownership.
26   for dirname in /home/developer $DEFAULT_FEISTYMEOW_ORG_DIR /usr/local/developer /home/games $arch_addin; do
27     if [ -d "$dirname" ]; then
28       echo "redeveloper on '$dirname'"
29       sudo chown -R developer:developer "$dirname"
30       test_or_die "chowning for developer: $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 developer:developer /z
37     test_or_die "chowning /z for developer"
38     sudo chmod g+rx,o+rx /z
39     test_or_die "chmodding /z/ for developer"
40     sudo chown developer:developer /z/stuffing
41     test_or_die "chowning /z/stuffing for developer"
42     sudo chmod g+rx,o-rwx /z/stuffing
43     test_or_die "chmodding /z/stuffing for developer"
44     pushd /z/stuffing &>/dev/null
45     if [ -d archives -o -L archives ]; then
46       sudo chown developer:developer archives
47       test_or_die "chowning /z/stuffing/archives for developer"
48       sudo chmod -R g+rwx archives
49       test_or_die "chmodding /z/stuffing/archives for developer"
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 =~ .*redeveloper\.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   redeveloper
66   test_or_die "redeveloperding process"
67 fi
68