Merge branch 'dev' of feistymeow.org:feisty_meow into dev
[feisty_meow.git] / scripts / site_avenger / revamp_cakelampvm.sh
1 #!/bin/bash
2
3 # fixes the cakelampvm permissions according to the way.
4
5 ##############
6
7 if [[ $EUID != 0 ]]; then
8   echo "This script must be run as root or sudo."
9   exit 1
10 fi
11
12 ##############
13
14 export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
15 export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
16
17 export NO_HELLO=right
18 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
19 source "$FEISTY_MEOW_SCRIPTS/system/common_sysadmin.sh"
20
21 ##############
22
23 # fix up the main web storage.
24 chown -R www-data:www-data /var/www 
25 test_or_die "chown www-data"
26 group_perm /var/www 
27 test_or_die "group_perm www-data"
28
29 ##############
30
31 # set up access on some important folders for the developer user.
32 chown -R developer:developer /home/developer
33 test_or_die "chown developer home"
34 harsh_perm /home/developer/.ssh
35 test_or_die "harsh_perm setting on developer .ssh"
36 chown -R developer:developer /etc/apache2 /etc/bind 
37 test_or_die "chown apache2 and bind to developer"
38 group_perm /etc/apache2 /etc/bind 
39 test_or_die "group perms on apache2 and bind"
40
41 ##############
42
43 # fix perms for fred user.
44 chown -R fred:fred /home/fred /home/archives/stuffing 
45 test_or_die "chown fred home"
46 harsh_perm /home/fred/.ssh
47 test_or_die "harsh_perm setting on fred .ssh"
48 chown -R fred:fred /opt/feistymeow.org 
49 test_or_die "chown feisty meow to fred"
50 group_perm /opt/feistymeow.org 
51 test_or_die "group perms on feisty meow"
52
53 ##############
54 #
55 # some slightly tricky bits start here.  we want to massage the vm into the
56 # best possible shape without needing to re-release it.
57 #
58 ##############
59
60 # only update hello if they've still got the file there.  we don't want to
61 # keep forcing our hellos at people.
62 if [ -f "$HOME/hello.txt" ]; then
63   # copy the most recent hello file into place for the user.
64   \cp -f "$FEISTY_MEOW_APEX/production/sites/cakelampvm.com/hello.txt" "$HOME"
65   test_or_continue "copying hello file for user"
66 fi
67
68 ##############
69
70 # install a better editor app.
71
72 echo "
73 The script is about to install the bluefish editor and some dependencies.
74 If the app is not already installed, then this process takes only about a
75 minute on a slower home DSL internet connection...
76
77 "
78
79 apt-get install -y bluefish &> "/tmp/install_bluefish-$(logname).log"
80 test_or_continue "installing bluefish editor"
81
82 ##############
83
84 # we want to upgrade the default apache site to the latest, since the new
85 # version mirrors the one on the internet (but with green checks instead
86 # of red X's) and since we also support https on the new default version.
87 # we can do this again later if needed, by upping the numbers on the apache
88 # site config files.
89 if [ -l /etc/apache2/sites-enabled/000-default.conf ]; then
90   # the old site is in place still, so let's update that.
91   a2dissite 000-default
92   test_or_die "disabling old apache site"
93
94   rm -f /etc/apache2/sites-available/000-default.conf 
95   test_or_die "removing old apache site"
96
97   cp $FEISTY_MEOW_APEX/production/sites/cakelampvm/
98 uhhh
99 two files for new config
100   test_or_die "installing new apache default sites"
101
102   a2ensite
103 thos two configs
104   test_or_die "enabling new apache default sites"
105
106   restart_apache
107
108
109 fi
110
111 #hmmm: todo
112 # deploy the site updater here to fix the local cakelampvm.com site...
113
114
115 ##############
116
117 # sequel--tell them they're great and show the hello again also.
118
119 regenerate
120
121 echo "
122
123
124 Thanks for revamping your cakelampvm.  :-)
125 "
126
127 ##############
128
129