Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 240 lines (191 sloc) 5.397 kb
53f81b7 Sean Hess began new centos library
authored
1 #!/bin/bash
2
b94ab2a Sean Hess comments
authored
3 # Usage: From linode stack script
4 # source <ssinclude StackScriptID=168>
5
6 # Usage: From new system on the command line
c9dc9ea Sean Hess syntax error
authored
7 # rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
b94ab2a Sean Hess comments
authored
8 # yum -y install git
9 # git clone http://github.com/seanhess/centos.git
10 # source centos/centos_library.sh
11
12 # You can then call any function like:
13 # system_update
14 # www_user seanhess somepassword
53f81b7 Sean Hess began new centos library
authored
15
16 # Dependencies - make sure they only run once
97784f2 Sean Hess readly
authored
17 Ran=1
18 New=0
53f81b7 Sean Hess began new centos library
authored
19 ruby19=$New
cc22147 Sean Hess added www group
authored
20 www=$New
0d62338 Sean Hess testing nginx
authored
21 nginx=$New
4d18d69 Sean Hess added sudoers magic
authored
22 admin=$New
53f81b7 Sean Hess began new centos library
authored
23
24 # update packages and install epel repo
25 function system_update {
26 yum -y update
6f6edae Sean Hess added nginx
authored
27 epel_repo
53f81b7 Sean Hess began new centos library
authored
28 echo "System Updated"
29 }
30
6f6edae Sean Hess added nginx
authored
31 function epel_repo {
32 rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
33 }
34
53f81b7 Sean Hess began new centos library
authored
35 # a whole bunch of yum stuff
36 function install_basics {
38bd908 Sean Hess forgot install
authored
37 system_update
6f6edae Sean Hess added nginx
authored
38 epel_repo
cc22147 Sean Hess added www group
authored
39 yum -y install wget curl rsync git sudo vim make which mlocate man vixie-cron readline-devel
38bd908 Sean Hess forgot install
authored
40 yum -y install gcc gcc-c++ gettext-devel expat-devel curl-devel zlib-devel openssl-devel perl cpio
361e2a6 Sean Hess added node
authored
41 yum -y install pinfo
53f81b7 Sean Hess began new centos library
authored
42 echo "Installed Basics"
43 }
44
361e2a6 Sean Hess added node
authored
45 function sources {
46 mkdir ~/sources
47 cd ~/sources
48 }
49
53f81b7 Sean Hess began new centos library
authored
50 function ruby19 {
51 if [ $ruby19 == $Ran ]; then return; fi
52
53 # we need gcc, gcc-c++, wget
54 install_basics
55
56 mkdir ~/sources
57 cd ~/sources
58 wget "ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p378.tar.gz"
59 tar zxvf ruby-1.9.1-p378.tar.gz
60 cd ruby-1.9.1-p378
61 ./configure
62 make
63 make install
64
65 echo "Ruby 1.9 installed"
66 ruby19=$Ran
67 }
68
343481c Sean Hess users and groups
authored
69 function create_user {
70 username=$1
71 password=$2
72
73 useradd $username
74 set_password $username $password
75 }
76
77 function set_password {
78 username=$1
79 password=$2
80
81 echo $password > /tmp/password.txt
82 passwd --stdin $username < /tmp/password.txt
83 rm /tmp/password.txt
84
85 echo "Set password for $username"
86 }
87
88 function set_group {
89 username=$1
90 group=$2
91
92 usermod -aG $group $username
93 echo "Added $username to $group"
94 }
95
0209cb4 Sean Hess fix path
authored
96 function fix_path {
97 username=$1
5d833a3 Sean Hess fixed function
authored
98 path="$(home_directory $username)/.bash_profile"
0209cb4 Sean Hess fix path
authored
99 sed -i .old -e 's/^PATH=.*$/PATH=$HOME\/bin:\/sbin:\/usr\/local\/bin:\/usr\/local\/sbin:\/bin:\/usr\/bin:\/usr\/sbin/' $path
6f15189 Sean Hess changes
authored
100 # echo "alias sudo='sudo -E '"
0209cb4 Sean Hess fix path
authored
101 }
102
6f15189 Sean Hess changes
authored
103
104
0209cb4 Sean Hess fix path
authored
105 # returns a users home directory
106 function home_directory {
107 username=$1
108 if [ $username == "root" ]; then
5d833a3 Sean Hess fixed function
authored
109 echo "/root"
0209cb4 Sean Hess fix path
authored
110 else
5d833a3 Sean Hess fixed function
authored
111 echo "/home/$username"
0209cb4 Sean Hess fix path
authored
112 fi
113 }
114
cc22147 Sean Hess added www group
authored
115 # Create a "www" deploy user with no password
343481c Sean Hess users and groups
authored
116 # this automatically creates a www group as well
cc22147 Sean Hess added www group
authored
117 function www {
118 if [ $www == $Ran ]; then return; fi
119 useradd www
120 mkdir -p /var/www
121 chown -R www:www /var/www
122 echo "User www created"
53f81b7 Sean Hess began new centos library
authored
123 }
124
4d18d69 Sean Hess added sudoers magic
authored
125 function admin_group {
126 if [ $admin == $Ran ]; then return; fi
374bc12 Sean Hess trying again
authored
127
4d18d69 Sean Hess added sudoers magic
authored
128 groupadd admin
374bc12 Sean Hess trying again
authored
129 echo "%admin ALL=(ALL) ALL" >> /etc/sudoers
343481c Sean Hess users and groups
authored
130 echo "created admin group"
4d18d69 Sean Hess added sudoers magic
authored
131 }
132
cc22147 Sean Hess added www group
authored
133 function sudoer {
4d18d69 Sean Hess added sudoers magic
authored
134 admin_group
cc22147 Sean Hess added www group
authored
135 username=$1
4d18d69 Sean Hess added sudoers magic
authored
136 usermod -aG admin $username
343481c Sean Hess users and groups
authored
137 echo "$username has sudo rights"
53f81b7 Sean Hess began new centos library
authored
138 }
139
63c7814 Sean Hess fixed user stuff
authored
140 # Installs from source, but links things back in yum-style
141 # /etc/nginx
142 # /var/log/nginx
143 # /etc/init.d/nginx
144 # /usr/sbin/nginx
53f81b7 Sean Hess began new centos library
authored
145 function nginx {
6f6edae Sean Hess added nginx
authored
146 if [ $nginx == $Ran ]; then return; fi
a490694 Sean Hess added nginx install basics'
authored
147
148 install_basics
6f6edae Sean Hess added nginx
authored
149
38bd908 Sean Hess forgot install
authored
150 yum -y install pcre-devel zlib-devel openssl-devel
53f81b7 Sean Hess began new centos library
authored
151
9f2e166 Sean Hess nginx works!
authored
152 # Installs the service script, puts things in the right places
153 yum -y install nginx
154
155 # Install the full version of nginx
53f81b7 Sean Hess began new centos library
authored
156 mkdir ~/sources
157 cd ~/sources
6f6edae Sean Hess added nginx
authored
158 wget http://nginx.org/download/nginx-0.7.65.tar.gz
159 tar zxvf nginx-0.7.65.tar.gz
160 cd nginx-0.7.65
9003c98 Sean Hess more stuff
authored
161 ./configure --with-http_ssl_module
6f6edae Sean Hess added nginx
authored
162 make
163 make install
164
9f2e166 Sean Hess nginx works!
authored
165 # Now link it in the right place
166 mv /usr/sbin/nginx /usr/sbin/nginx.old
167 ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
168
6f6edae Sean Hess added nginx
authored
169 echo "Nginx installed"
170 nginx=$Ran
53f81b7 Sean Hess began new centos library
authored
171 }
172
bb8f139 Sean Hess curl and couchdb 0.11
authored
173 function curl {
174 sources
175 wget http://curl.haxx.se/download/curl-7.20.0.tar.gz -O curl.tar.gz
176 tar zxvf curl.tar.gz
177 cd curl-7.20.0
178 ./configure
179 make
180 make install
181 }
182
53f81b7 Sean Hess began new centos library
authored
183 # http://sifumoraga.blogspot.com/2009/11/installing-couchdb-on-centos5-system.html
bb8f139 Sean Hess curl and couchdb 0.11
authored
184 # Needs curl > 7.18
185 # http://porteightyeight.com/2009/06/12/installing-couchdb-centos-5-linux/
53f81b7 Sean Hess began new centos library
authored
186 function couchdb {
6f6edae Sean Hess added nginx
authored
187 epel_repo
53f81b7 Sean Hess began new centos library
authored
188 yum -y install ncurses-devel openssl-devel icu libicu-devel js js-devel curl-devel erlang erlang-devel libtool
bb8f139 Sean Hess curl and couchdb 0.11
authored
189
190 sources
191
192 wget http://apache.osuosl.org/couchdb/0.11.0/apache-couchdb-0.11.0.tar.gz -O couchdb.tar.gz
193 tar zxvf couchdb.tar.gz
194
195 cd apache-couchdb-0.11.0
196 ./configure
197 make
198 make install
53f81b7 Sean Hess began new centos library
authored
199 }
361e2a6 Sean Hess added node
authored
200
201 # Doesn't work yet!!!
202 function couchdb_lounge {
203 install_basics
204
205 sources
206
207 git clone http://github.com/tilgovi/couchdb-lounge.git
208
209 wget http://mirrors.igsobe.com/apache/couchdb/0.10.1/apache-couchdb-0.10.1.tar.gz
210 tar zxvf apache-couchdb-0.10.1.tar.gz
211 cd apache-couchdb-0.10.1
212
213 patch -p1 < ~/sources/couchdb-lounge/rpm/couchdb/des
214 }
215
0a80623 Sean Hess added turnon
authored
216 function turnon {
217 name=$1
218 chkconfig $name on
219 service $name start
220 }
361e2a6 Sean Hess added node
authored
221
222 function nodejs {
223 sources
a9c641b Sean Hess updated node.js
authored
224 wget http://nodejs.org/dist/node-v0.1.33.tar.gz
225 tar zxvf node-v0.1.33.tar.gz
226 cd node-v0.1.33
361e2a6 Sean Hess added node
authored
227 ./configure
228 make
229 make install
230 }
0d92111 Sean Hess added coffeescript
authored
231
232 # depends on nodejs
233 function coffeescript {
234 sources
235 git clone http://github.com/jashkenas/coffee-script.git
236 cd coffee-script
237 bin/cake install
238
239 }
Something went wrong with that request. Please try again.