Skip to content

Instantly share code, notes, and snippets.

@janbiasi
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janbiasi/ec45f1962c13019fabfe to your computer and use it in GitHub Desktop.
Save janbiasi/ec45f1962c13019fabfe to your computer and use it in GitHub Desktop.
A tiny installer for linux including Apache, MySQL, PHP and GitLab (v5.0)
#!/bin/sh
echo "You have to be the root user to execute this script!"
echo "What is your OS?"
echo "1 OpenSuSE"
echo "2 Ubuntu"
echo "3 RedHat"
echo "4 Debian"
echo "5 Go Back"
echo "6 Quit"
read OSSEL
case OSSEL in
### OpenSuSE Installation -----------------
1)
# Install
zypper in apache2
# Firewall settings for apache webserver
sysconf_addword /etc/sysconfig/SuSEfirewall2 FW_CONFIGURATIONS_EXT apache2
sysconf_addword /etc/sysconfig/SuSEfirewall2 FW_CONFIGURATIONS_EXT apache2-ssl
rcSuSEfirewall2 restart
# Start apache and configure
rcapache2 start
chkconfig -a apache2
# Add apache module PHP and MySQL
zypper install mysql mysql-community-server-client mysql-community-server mysql-workbench
a2enmod php5
a2enmod -l
rcapache2 restart
;;
### Ubuntu Installation -----------------
2)
# Installing and start apache
apt-get install apache2 apache2-doc
service apache2 start
# Install PHP and MySQL and restart
apt-get update && apt-get install php5 libapache2-mod-php5
service apache2 restart
;;
### RedHat Installation -----------------
3)
echo "Not supported yet!"
;;
### Debian Installation -----------------
4)
# Installing MySQL and Apache
apt-get install mysql-server mysql-client
apt-get install apache2
# Installing modules such as PHP and kickstart
apt-get install php5 libapache2-mod-php5
/etc/init.d/apache2 restart
;;
### Go back to the main menu
5)
sh installation.sh
;;
### Force quit the program
6)
return
;;
esac
# Run again the configuration
sh installation.sh
#!/bin/sh
zypper ar http://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/openSUSE_12.3/devel:languages:ruby:extensions.repo
zypper in patterns-openSUSE-devel_basis ca-certificates-cacert nginx rubygem-rb-inotify rubygem-ffi redis mysql-community-server mysql-community-server-client rubygem-bundler ruby19 ruby19-devel libmysqlclient-devel zlib-devel libyaml-devel libgdbm4 libreadline6 libncurses5 libffi47-devel curl git-core postfix checkinstall libxml2-devel libxslt-devel libcurl-devel libicu-devel
python2 --version # make sure to have version > 2.5 but < 3.0
ruby1.9 --version # make sure to have a compatible version
cat /usr/bin/bundle # make sure to have ruby version 1.9
systemctl daemon-reload # reparse config for systemd
systemctl start mysql.service # start mysql
systemctl enable mysql.service # make mysql autostart
cp /etc/redis/default.conf{.example,}
chown redis.redis /etc/redis/default.conf
systemctl enable redis.service
systemctl start redis.service
su git
cd ~
git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
cp config.yml.example config.yml
vim config.yml # change domain
cd ~
ssh-keygen # to be sure, create SSH key with empty passphrase
gem1.9 install charlock_holmes --version '0.6.9' # execute as root
su git
cd
git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
git checkout 5-0-stable # not possible yet, I use master instead
vim config/gitlab.yml
# ^- email_from: gitlab@atech.de, support_email: admin@atech.de, default_projects_limit: 100
# disable username_changing_enabled
chown -R git log/ tmp/
chmod -R u+rwX log/ tmp/
mkdir /home/git/gitlab-satellites
mkdir tmp/pids/
chmod -R u+rwX tmp/pids/
cp config/unicorn.rb.example config/unicorn.rb
cp config/database.yml.mysql config/database.yml
vim config/database.yml # edit password and username
bundle install --deployment --without development test postgres # takes a while
bundle exec rake db:setup RAILS_ENV=production
bundle exec rake db:seed_fu RAILS_ENV=production
bundle exec rake gitlab:setup RAILS_ENV=production # chose yes
bundle exec rake gitlab:shell:setup RAILS_ENV=production # chose yes
git config --global user.name "GitLab"
git config --global user.email "gitlab@atech.de"
#!/bin/sh
read -s -p "> MySQL root pass: " mysqlpass
# Needed to create a unique password non-interactively.
sudo apt-get install -y makepasswd
# Generate a random gitlab MySQL password
gitlabpass=$(makepasswd --char=16)
currentdir=$(pwd)
# Install essentials
sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev
sudo apt-get install -y libreadline-dev libncurses5-dev libffi-dev curl git-core
sudo apt-get install -y openssh-server redis-server postfix checkinstall libxml2-dev
sudo apt-get install -y libxslt-dev libcurl4-openssl-dev libicu-dev
# Install Python
sudo apt-get install -y python python2.7
sudo ln -s /usr/bin/python /usr/bin/python2
# Install Ruby
rm -rf /tmp/ruby
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz | tar xz
cd ruby-1.9.3-p327
./configure
make
sudo make install
# Install Ruby Bundler
sudo gem install bundler
# Create git user
sudo adduser --disabled-login --gecos 'GitLab' git
# Go to home directory
cd /home/git
# Clone gitlab shell
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
# switch to right version for v5.0
sudo -u git -H git checkout v1.1.0
sudo -u git -H git checkout -b v1.1.0
sudo -u git -H cp config.yml.example config.yml
# Edit config and replace gitlab_url
# with something like 'http://domain.com/'
#sudo -u git -H nano config.yml
sudo -u git -H sed -i '5s/.*/gitlab_url: "http:\/\/localhost\/"/' config.yml
# Do setup
sudo -u git -H ./bin/install
# Install the database packages
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
# Create a user for GitLab.
mysql -uroot -p$mysqlpass -e "CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$gitlabpass';"
# Create the GitLab production database
mysql -uroot -p$mysqlpass -e "CREATE DATABASE IF NOT EXISTS \`gitlabhq_production\` DEFAULT CHARACTER SET \`utf8\` COLLATE \`utf8_unicode_ci\`;"
# Grant the GitLab user necessary permissopns on the table.
mysql -uroot -p$mysqlpass -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON \`gitlabhq_production\`.* TO 'gitlab'@'localhost';"
# Quit the database session
mysql -uroot -p$mysqlpass -e "\\q;"
# Try connecting to the new database with the new user
sudo -u git -H mysql -ugitlab -p$gitlabpass -D gitlabhq_production
# We'll install GitLab into home directory of the user "git"
cd /home/git
# Clone GitLab repository
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
# Go to gitlab dir
cd /home/git/gitlab
# Checkout to stable release
sudo -u git -H git checkout 5-0-stable
cd /home/git/gitlab
# Copy the example GitLab config
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
# Make sure to change "localhost" to the fully-qualified domain name of your
# host serving GitLab where necessary
#sudo -u git -H nano config/gitlab.yml
sudo -u git -H sed -i '18s/.*/ host: localhost/' config/gitlab.yml
sudo -u git -H sed -i '19s/.*/ port: 3000/' config/gitlab.yml
# Make sure GitLab can write to the log/ and tmp/ directories
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX log/
sudo chmod -R u+rwX tmp/
# Create directory for satellites
sudo -u git -H mkdir /home/git/gitlab-satellites
# Create directory for pids and make sure GitLab can write to it
sudo -u git -H mkdir tmp/pids/
sudo chmod -R u+rwX tmp/pids/
# Copy the example Unicorn config
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
#sudo nano config/unicorn.rb
sudo -u git -H sed -i '19s/.*/listen "127.0.0.1:3000" # listen to port 8080 on the loopback interface/' config/unicorn.rb
sudo -u git -H sed -i '20s/.*/#listen "#{app_dir}\/tmp\/sockets\/gitlab.socket"/' config/unicorn.rb
# Mysql
sudo -u git cp config/database.yml.mysql config/database.yml
#sudo nano config/database.yml
sudo -u git -H sed -i "10s/.*/ username: gitlab/" config/database.yml
sudo -u git -H sed -i "11s/.*/ password: ${gitlabpass}/" config/database.yml
sudo -u git -H sed -i "24s/.*/ username: gitlab/" config/database.yml
sudo -u git -H sed -i "25s/.*/ password: ${gitlabpass}/" config/database.yml
# Charlock Holmes
cd /home/git/gitlab
sudo gem install charlock_holmes --version '0.6.9'
# First run
sudo -u git -H bundle install --deployment --without development test postgres
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
# Init scripts
sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-0-stable/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab
sudo update-rc.d gitlab defaults 21
#sudo /usr/lib/insserv/insserv gitlab
#echo "sudo service gitlab start" | cat - /etc/rc.local > /tmp/out && sudo mv /tmp/out /etc/rc.local
# Test configuration
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
echo "********************************"
echo "finished, you can configure nginx or apache"
echo "needs to point to 127.0.0.1:3000 with proxy"
echo "********************************"
#!/bin/sh
echo "You have to be the root user to execute this script!"
echo "What is your OS?"
echo "1 OpenSuSE"
echo "2 Ubuntu"
echo "3 RedHat"
echo "4 Debian"
echo "5 Go Back"
echo "6 Quit"
read OSSEL
case OSSEL in
1)
echo "Note: No warranty!"
sh gitlab-opensuse.sh
;;
2)
echo "Note: No warranty!"
sh gitlab-ubuntu.sh
3)
echo "Not supported yet!"
4)
### Go back to the main menu
5)
sh installation.sh
;;
### Force quit the program
6)
return
;;
esac
sh installation.sh
#!/bin/sh
echo "You have to be the root user to execute the script(s)!"
echo "What do you want to install?"
echo "1 Apache Webserver"
echo "2 GitLab Server"
echo "3 Quit Installer"
read ACTSEL
case ACTSEL in
1) sh apache.sh ;;
2) sh gitlab.sh ;;
3) return ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment