-
Notifications
You must be signed in to change notification settings - Fork 6
/
install-canvas.sh
executable file
·117 lines (96 loc) · 2.98 KB
/
install-canvas.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
#!/bin/bash
#####################################################
# Created by
# Neal Ogg Lawson <[email protected]>
#
# This script is to help with the bootstrap process of
# installing canvas.
######################################################
export DEBIAN_FRONTEND=noninteractive
shopt -s -o nounset
declare -rx SCRIPT=${0##*/}
CHEF_SOLO_CONFIG="chef-solo-config.rb"
RUN_LIST="node-canvas.json"
REQURIED_PACKAGES="rubygems joe chef"
if [ $# -eq 0 ] ; then
printf "%s\n" "Type -h for help."
exit 192
fi
function ihascrashed() {
echo
echo "Hmm, Somthing seems to have gone wrong, you need to find out what happend."
echo "Before proceeding. Sorry Dude!"
echo
exit 1
}
function help() {
echo
echo "Welcome to help!, if your reading this you may need Help!"
echo "This script requires root privlieges and will exit with out root!"
echo "options:"
echo -e "\t-h Display this help"
echo -e "\t-i Install Canvas"
echo
}
function display_finishup_directions() {
echo ""
echo "Alright, we are almost done, but we need to do some intial tasks!"
echo "Fist we need to populate the database with some inital data"
echo "in /opt/canvas/lms (unless you have altered your canvas home)"
echo ""
echo "RUN: sudo -u canvas /bin/bash -c \"( cd /opt/canvas/lms && RAILS_ENV=production bundle exec rake db:initial_setup ) \""
echo ""
echo "Now, we need to restart nginx and canvas_init...."
echo ""
echo "RUN: sudo /etc/init.d/nginx restart"
echo "RUN: sudo /etc/init.d/canvas_init restart"
echo ""
echo "you should now have a working canvas install (At least i hope so!)"
}
function setup_apt_opscode() {
echo "Checking if we need to setup an Apt repo for OPSCODE"
if test -f /etc/apt/sources.list.d/opscode.list; then
echo "opscode Repo has already been configured"
else
echo "Setting up opscode repo"
echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | sudo tee /etc/apt/sources.list.d/opscode.list
gpg --keyserver keys.gnupg.net --recv-keys 83EF826A
gpg --export [email protected] | sudo tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null
DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade
fi
}
function run_chef_solo() {
echo "Running Chef:"
chef-solo -c $CHEF_SOLO_CONFIG -j $RUN_LIST
if [ $? -eq 0 ];then
echo "Chef has run Sucessfully!"
else
ihascrashed
fi
}
function install() {
echo -n "Are we running as root? "
if [ $USER != "root" ]; then
echo "NO!"
echo "I need to run as root!, hint: sudo $0"
exit 192
else
echo "Yah!, lets install!"
fi
setup_apt_opscode
echo "Instailling required packages! (${REQURIED_PACKAGES})"
DEBIAN_FRONTEND=noninteractive apt-get install -q -y --force-yes $REQURIED_PACKAGES
run_chef_solo
display_finishup_directions
}
while getopts "hi" SWITCH ; do
case $SWITCH in
h) help;exit 0;;
i) install;exit 0;;
\?) exit 192;;
*) printf "$SCRIPT:$LINENO: %s\n" "script error: unhandled argument"
exit 192
;;
esac
done