Common Ubuntu script software + rubyonrails

Source: Internet
Author: User
Tags imagemagick tar xz
I think this script will help you configure Ubuntu for the first time. rubyonrails is my hobby. You can also comment out the last line, only install software #! /Bin/bashRUBY_VERSION = "1.8.6-p287" RUBY_GEM_VERSION = "1.3.1" RAILS_APP_DEPLOYMENT_DIR = "/var/www/rails" MOD_RAILS_VERSION = "2.0.

I think this script will be very convenient for you to configure Ubuntu for the first time. ruby on rails is my hobby. You can also comment out the last line, only install software.

#! /Bin/bash
RUBY_VERSION = "1.8.6-p287"
RUBY_GEM_VERSION = "1.3.1"
RAILS_APP_DEPLOYMENT_DIR = "/var/www/rails"
MOD_RAILS_VERSION = "2.0.3"
Export LANG = C
# Detect distro version
If [-e/etc/RedHat-release]; then
DISTRO = "redhat"
Elif [-e/etc/debian_version]; then
DISTRO = "debian"
Fi
# Set apt-get modifier based on distro
If [$ DISTRO = "redhat"]; then
APTMOD = "-y"
Elif [$ DISTRO = "debian"]; then
APTMOD = "-y -- force-yes"
Fi
# Misc settings based on distro
If [$ DISTRO = "redhat"]; then
RAILS_APP_CONFIG = "/etc/httpd/conf. d/railsapps. conf"
MOD_RAILS_CONFIG = "/etc/httpd/conf. d/mod_rails.conf"
Elif [$ DISTRO = "debian"]; then
RAILS_APP_CONFIG = "/etc/apache2/conf. d/railsapps. conf"
MOD_RAILS_CONFIG = "/etc/apache2/conf. d/mod_rails.conf"
Fi
####################
# Helper functions #
####################
##
# View std out and append to log
Function echolog (){
Echo $ * | tee-a/root/install. log
}
##
# Download file and cd there
Function download (){
Local name = $1
Local version = $2
Local url = $3
Mkdir-p/usr/local/src
Cd/usr/local/src
If [-d/usr/local/src/$ name-$ version]; then
Echolog "$ name directory already exists, skipping the download"
Cd/usr/local/src/$ name-$ version
Return 0
Fi
Echolog "Grabbing $ name from $ url"
Wget-qO-$ url | tar xz
If [$? -Ne 0]; then
Echolog "failed getting $ url"> & 2
Return 1
Fi
Cd/usr/local/src/$ name-$ version
}
##
# Apt-get update
Function aptgetupdate (){
Echolog configurming system update via package manager
Apt-get update
Apt-get $ APTMOD upgrade
}
Function aptgetmysf (){
# Install the software what I want, it works in ubuntu
Apt-get install $ APTMOD nautilus-open-terminal
Apt-get install $ APTMOD compizconfig-settings-manager
Apt-get install $ APTMOD libxine1-ffmpeg libxine1-plugins w32codecs libdvdcss2
Apt-get install $ APTMOD gstreamer0.10-plugins-uugly gstreamer0.10-ffmpeg gstreamer0.10-fluendo-mpegdemux gstreamer0.10-gnonlin
Apt-get remove $ APTMOD totem-gstreamer-y
Apt-get install $ APTMOD totem-xine totem-mozilla-y
Apt-get install $ APTMOD mplayer-fonts mozilla-mplayer smplayer
Apt-get install $ APTMOD publish read
Apt-get install $ APTMOD mozilla-submit read
Apt-get install $ APTMOD implements read-plugins
# Apt-get install $ APTMOD gnochm
Apt-get install $ APTMOD flashplugin-nonfree
Apt-get install $ APTMOD rar unrar
Apt-get install $ APTMOD sun-java6-jre
Apt-get install $ APTMOD sun-java6-jdk
Apt-get install $ APTMOD sun-java6-plugin
Apt-get install $ APTMOD libgtk2.0-dev xorg-dev ncurses-dev build-essential # need by vim
Apt-get install $ APTMOD build-essential gcc make autoconf automake libtool gdb g ++
}
##
# Install prerequisites
Function installprereqpackages (){
Echolog Installing prerequisite packages via package manager
If [$ DISTRO = "redhat"]; then
Apt-get $ APTMOD install zlib-devel
Apt-get $ APTMOD install readline-devel readline
Apt-get $ APTMOD install mysql-devel
Apt-get $ APTMOD install libmysqlclient15-dev
Apt-get $ APTMOD install pcre-devel
Apt-get $ APTMOD install which
Apt-get $ APTMOD install httpd-devel
Elif [$ DISTRO = "debian"]; then
Apt-get install $ APTMOD zlib1g-dev
Apt-get install $ APTMOD 'G ++-100'
Apt-get install $ APTMOD libmysqlclient14-dev
Apt-get install $ APTMOD libreadline5-dev
Apt-get install $ APTMOD libwmf-bin
Apt-get install $ APTMOD libmysqlclient15-dev
Apt-get install $ APTMOD libssl-dev
Apt-get install $ APTMOD apache2-prefork-dev
Fi
}
##
# Install ImageMagik
Function installimagemagik (){
Download ImageMagick 6.4.3 http://downloads.rimuhosting.com/ImageMagick-6.4.3.tar.gz
Echolog Installing ImageMagick VERSION = 6.4.3
If [$? -Ne 0]; then echolog "failed downloading imagemagick"> & 2; return 1; fi
./Configure & make install
If [$? -Ne 0]; then
Echolog "ImageMagick make install failed"> & 2
Return 1
Fi
}
##
# Install ruby & dev libraries
Function installruby (){
Download ruby $ RUBY_VERSION http://downloads.rimuhosting.com/ruby-#ruby_version.tar.gz
Echolog Installing Ruby VERSION = $ RUBY_VERSION
If [$? -Ne 0]; then echolog "failed downloading ruby"> & 2; return 1; fi
./Configure & make test & make install
If [$? -Ne 0]; then
Echolog "Ruby make install failed"> & 2
Return 1
Fi
# So there'll be a/usr/bin/ruby to use
If [-e/usr/local/bin/ruby-! -E/usr/bin/ruby]; then
Ln-sf/usr/local/bin/ruby/usr/bin/ruby
Fi
# Doing this voodoo to prevent errors like:
#/Usr/local/lib/ruby/1.8/irb/completion. rb: 10: in 'require ': no such file to load-readline (LoadError)
Cd/usr/local/src/ruby-$ RUBY_VERSION/ext/readline
If [$? -Ne 0]; then echolog "no/usr/local/src/ruby-$ VERSION_ACTUAL/ext/readline dir"> & 2; return 1; fi
Ruby extconf. rb
If [$? -Ne 0]; then echolog "readline extconf. rb failed"> & 2; return 1; fi
Make clean & make install
If [$? -Ne 0]; then echolog "readline make failed"> & 2; return 1; fi
}
##
# Install ruby gem
Function installrubygems (){
Download rubygems $ RUBY_GEM_VERSION http://downloads.rimuhosting.com/rubygems-w.ruby_gem_version.tgz
Echolog Installing Ruby Gems VERSION = $ RUBY_GEM_VERSION
If [$? -Ne 0]; then echolog "failed downloading rubygems"> & 2; return 1; fi
Ruby setup. rb
If [$? -Ne 0]; then
Echolog "Rubygems install failed"> & 2
Return 1
Fi
}
##
# Install commonly used gems
Function installcommongems (){
Echolog Installing commonly used Ruby Gems
GEM_LIST = "rails mongrel mongrel_cluster capistrano rmagick ruby-openid sqlite3-ruby mysql icalendar BlueCloth"
For gem in $ GEM_LIST; do
Gem install -- include-dependencies $ gem;
If [$? -Ne 0]; then
Echolog "failed to install gems '$ gems '"
Fi
Done
# Install mysql gem is sometimes trouble (CentOS), installing it individually
If [$ DISTRO = "redhat"]; then
Gem install mysql -- with-mysql-config =/usr/bin/mysql_config
Elif [$ DISTRO = "debian"]; then
Gem install mysql
Fi
# Install mod_rails
Gem install passenger -- include-dependencies-v $ MOD_RAILS_VERSION
# Compile mod_rails apache module
# Passenger-install-apache2-module
}
##
# Create deployment environment
Function createdeployenv (){
Echolog logging ing mod_rails/Apache
# Create app deployment directory w/correct permissions
Mkdir $ RAILS_APP_DEPLOYMENT_DIR
# Remove apache default vhost/welcome screen
If [$ DISTRO = "redhat"]; then
Mv/etc/httpd/conf. d/welcome. conf/etc/httpd/conf. d/welcome. conf. bak
Elif [$ DISTRO = "debian"]; then
Rm/etc/apache2/sites-enabled/000-default
Fi
# Add basic passenger config
Echo "LoadModule passenger_module/usr/local/lib/ruby/gems/1.8/gems/passenger-$ MOD_RAILS_VERSION/ext/apache2/mod_passenger.so
PassengerRoot/usr/local/lib/ruby/gems/1.8/gems/passenger-$ MOD_RAILS_VERSION
PassengerRuby/usr/local/bin/ruby
RailsEnv production
# Tune these to suit your application
PassengerMaxPoolSize 2
PassengerMaxInstancesPerApp 2
PassengerPoolIdleTime 600 "> $ MOD_RAILS_CONFIG
# Create test rails app
Cd $ RAILS_APP_DEPLOYMENT_DIR
Rails testapp
# Create virtual host for test rails app
Echo"
DocumentRoot $ {RAILS_APP_DEPLOYMENT_DIR}/testapp/public
"> $ RAILS_APP_CONFIG
# Restart apache
If [$ DISTRO = "redhat"]; then
/Etc/init. d/httpd restart
Elif [$ DISTRO = "debian"]; then
/Etc/init. d/apache2 restart
Fi
}
####################
# EXECUTION #
####################
Aptgetupdate
Aptgetmysf
Installprereqpackages
Installimagemagik
Installruby
Installrubygems
Installcommongems
# Createdeployenv
Exit 0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.