Last active
August 29, 2015 13:57
-
-
Save wokamoto/9483827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PUBLIC_HOST_NAME=`/usr/bin/curl http://169.254.169.254/latest/meta-data/public-hostname` | |
yes | crontab -r | |
su - git | |
PUBLIC_HOST_NAME=`/usr/bin/curl http://169.254.169.254/latest/meta-data/public-hostname` | |
INSTANCE_ID=`/usr/bin/curl http://169.254.169.254/latest/meta-data/instance-id` | |
echo "GRANT ALL PRIVILEGES ON *.* TO gitlab@localhost IDENTIFIED BY '$INSTANCE_ID';" | mysql -u root | |
echo 'DROP DATABASE IF EXISTS gitlabhq_production;' | mysql -u root | |
echo 'CREATE DATABASE gitlabhq_production DEFAULT CHARACTER SET utf8;' | mysql -u root | |
echo "[user] | |
name = GitLab | |
email = gitlab@$PUBLIC_HOST_NAME | |
[core] | |
autocrlf = input" > /home/git/.gitconfig | |
cd /home/git/gitlab-shell | |
sed -e "s/http:\/\/localhost/http:\/\/$PUBLIC_HOST_NAME/" /home/git/gitlab-shell/config.yml.example > /home/git/gitlab-shell/config.yml | |
ruby ./bin/install | |
cd /home/git/gitlab | |
sed -e "s/localhost/$PUBLIC_HOST_NAME/" /home/git/gitlab/config/gitlab.yml.example > /home/git/gitlab/config/gitlab.yml | |
sed -e "s/username: git/username: gitlab/" /home/git/gitlab/config/database.yml.mysql | sed -e "s/password: \"secure password\"/password: \"$INSTANCE_ID\"/" > /home/git/gitlab/config/database.yml | |
yes yes | bundle exec rake gitlab:setup RAILS_ENV=production | |
bundle exec rake assets:precompile RAILS_ENV=production | |
if [ ! -f /home/git/gitlab/lib/tasks/amimoto.rake ]; then | |
echo 'namespace :amimoto do | |
desc "AMIMOTO | set instance id to admin password" | |
task :adminpass => :environment do | |
instance_id = `/opt/aws/bin/ec2-metadata -i`.split[1] | |
admin = User.find_by_id 1 | |
admin.update( | |
password: instance_id, | |
password_confirmation: instance_id | |
) | |
admin.save | |
end | |
end' > /home/git/gitlab/lib/tasks/amimoto.rake | |
fi | |
bundle exec rake amimoto:adminpass RAILS_ENV=production | |
exit | |
sed -e "s/YOUR_SERVER_FQDN/$PUBLIC_HOST_NAME/" /home/git/gitlab/lib/support/nginx/gitlab > /etc/nginx/conf.d/gitlab.conf | |
/sbin/service gitlab start | |
/sbin/service nginx start | |
/sbin/chkconfig gitlab on | |
/sbin/chkconfig nginx on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment