Skip to content

Instantly share code, notes, and snippets.

@hilotech
Created May 13, 2015 20:02
Show Gist options
  • Save hilotech/a5d79db50835d6e43ed5 to your computer and use it in GitHub Desktop.
Save hilotech/a5d79db50835d6e43ed5 to your computer and use it in GitHub Desktop.
ConoHa [VPSでコラボ]自分たち専用のGitHub構築スクリプト
#!/bin/bash
set -e
set -u
FQDN='gitlab.example.com'
MY_PORT='8001'
FULL_URL="http://$FQDN:$MY_PORT/"
DIST='https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-ce-7.10.1~omnibus.2-1.x86_64.rpm'
for i in sshd postfix crond;
do
if echo "`service $i status 2>&1`" |& grep -q 'is running' ; then
: # ok
else
pkg=''
case $i in
'sshd' ) pkg='openssh-server' ;;
'postfix' ) pkg='postfix' ;;
'crond' ) pkg='cronie' ;;
esac
if [[ "$pkg" ]]; then
yum -y install $pkg && \
chkconfig $i on && \
service $i start
fi
fi
done
which curl || yum -y install curl
rpm -ivh "$DIST"
sed -i \
-e "s|^\(external_url '\).*$|external_url '$FULL_URL'|" \
/etc/gitlab/gitlab.rb
cat <<_EOF_ > /etc/httpd/vhosts/$FQDN.conf
<VirtualHost *:80>
ServerName $FQDN
ProxyPass / http://$FQDN:$MY_PORT/
ProxyPassReverse / http://$FQDN:$MY_PORT/
</VirtualHost>
_EOF_
service httpd restart
gitlab-ctl reconfigure
cat <<'_EOF_' > /etc/init.d/gitlab
#!/bin/bash
#
# gitlab Start and stop GitLab.
#
# chkconfig: 2345 99 01
# description: Start and stop GitLab.
# derived from https://gitlab.com/gitlab-org/omnibus-gitlab/issues/94
lockfile=/var/lock/subsys/gitlab
gitlabctl=/usr/bin/gitlab-ctl
prog=gitlab
start() {
echo -n $"Starting GitLab: "
$gitlabctl start
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $lockfile
return 0
}
stop() {
echo -n $"Stopping GitLab: "
$gitlabctl stop
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $lockfile
return 0
}
status() {
$gitlabctl status
return 0
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 2
esac
exit ${RETVAL}
_EOF_
chkconfig gitlab on
service gitlab start
cat <<_EOF_
=================================
Visit http://$FQDN with your browser,
and login as
Username: root
Password: 5iveL!fe
then change password A.S.A.P. !!
=================================
_EOF_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment