server-setup/gitlab/gitlab_install.sh

60 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
## Define admin user account
if [ -z "$ADMIN_ACCOUNT"]
then
ADMIN_ACCOUNT=root
fi
su - ${ADMIN_ACCOUNT}
## Define bulk storage location
if [ -z "$ZFS_DIR" ]
then
ZFS_DIR=/data
fi
echo "Installing GitLab ..."
GITLAB_HOME=${ZFS_DIR}/gitlab
GITLAB_ADDRESS=gitlab.adamhome.dev
GITLAB_EXTERN_HTTPS=14443
GITLAB_EXTERN_HTTP=14080
GITLAB_EXTERN_SSH=22
if [ "${GITLAB_EXTERN_SSH}" -eq 22 ]
then
awk '{sub("#PORT=22","PORT=22")} {print}' /etc/ssh/sshd_config > /tmp/temp.txt && mv /tmp/temp.txt /etc/ssh/sshd_config
awk '{sub("# PORT=22","PORT=22")} {print}' /etc/ssh/sshd_config > /tmp/temp.txt && mv /tmp/temp.txt /etc/ssh/sshd_config
awk -v port=2222 '{sub("PORT=22","PORT="2222)} {print}' /etc/ssh/sshd_config > /tmp/temp.txt && mv /tmp/temp.txt /etc/ssh/sshd_config
sudo systemctl reload sshd
fi
sudo docker run --detach \
--hostname ${GITLAB_ADDRESS} \
--publish ${GITLAB_EXTERN_HTTPS}:443 \
--publish ${GITLAB_EXTERN_HTTP}:80 \
--publish ${GITLAB_EXTERN_SSH}:22 \
--name gitlab \
--restart always \
--volume ${GITLAB_HOME}/config:/etc/gitlab \
--volume ${GITLAB_HOME}/logs:/var/log/gitlab \
--volume ${GITLAB_HOME}/data:/var/opt/gitlab \
--shm-size 512m \
gitlab/gitlab-ce:latest
## Uncomment if you want to monitor boot-up
# sudo docker logs -f gitlab
# sudo docker exec -it gitlab /bin/bash
# edit /etc/gitlab/gitlab.rb so that gitlab_rails['gitlab_shell_ssh_port'] = ${GITLAB_EXTERN_SSH}
# while still in gitlab env, run gitlab-ctl reconfigure
sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
echo "Successfully installed GitLab"