Add install_gitlab.sh
This commit is contained in:
commit
f9d733c637
72
install_gitlab.sh
Normal file
72
install_gitlab.sh
Normal file
@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "Welcome to GitLab Docker Automated Installer"
|
||||
|
||||
read -p "Enter LXC container IP to access GitLab (used only for instructions): " LXC_IP
|
||||
read -p "Enter GitLab admin email: " ADMIN_EMAIL
|
||||
read -p "Enter SMTP email address: " SMTP_EMAIL
|
||||
read -p "Enter SMTP email password: " -s SMTP_PASS
|
||||
echo
|
||||
read -p "Enter SMTP server address (e.g. smtp.gmail.com): " SMTP_SERVER
|
||||
read -p "Enter SMTP port (default 465): " SMTP_PORT
|
||||
SMTP_PORT=${SMTP_PORT:-465}
|
||||
read -p "Enter initial root password for GitLab admin: " -s ROOT_PASS
|
||||
echo
|
||||
|
||||
GITLAB_HOME=/srv/gitlab
|
||||
CONTAINER_NAME=gitlab
|
||||
|
||||
echo "Preparing persistent directories..."
|
||||
mkdir -p $GITLAB_HOME/config $GITLAB_HOME/logs $GITLAB_HOME/data
|
||||
chmod -R 755 $GITLAB_HOME
|
||||
|
||||
echo "Removing any existing GitLab container..."
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
docker stop $CONTAINER_NAME
|
||||
docker rm $CONTAINER_NAME
|
||||
fi
|
||||
|
||||
echo "Updating system and installing Docker dependencies..."
|
||||
apt-get update -y && apt-get upgrade -y
|
||||
apt-get install -y docker.io docker-compose curl sudo
|
||||
systemctl enable docker
|
||||
systemctl start docker
|
||||
|
||||
echo "Pulling GitLab Docker image..."
|
||||
docker pull gitlab/gitlab-ce:latest
|
||||
|
||||
echo "Running GitLab container..."
|
||||
docker run -d \
|
||||
--hostname gitlab.local \
|
||||
--env GITLAB_OMNIBUS_CONFIG="external_url 'http://localhost'; \
|
||||
gitlab_rails['smtp_enable'] = true; \
|
||||
gitlab_rails['smtp_address'] = '$SMTP_SERVER'; \
|
||||
gitlab_rails['smtp_port'] = $SMTP_PORT; \
|
||||
gitlab_rails['smtp_user_name'] = '$SMTP_EMAIL'; \
|
||||
gitlab_rails['smtp_password'] = '$SMTP_PASS'; \
|
||||
gitlab_rails['smtp_domain'] = 'localhost'; \
|
||||
gitlab_rails['smtp_authentication'] = 'login'; \
|
||||
gitlab_rails['smtp_enable_starttls_auto'] = false; \
|
||||
gitlab_rails['smtp_tls'] = true; \
|
||||
gitlab_rails['gitlab_email_from'] = '$SMTP_EMAIL'; \
|
||||
gitlab_rails['gitlab_email_reply_to'] = '$SMTP_EMAIL'; \
|
||||
gitlab_rails['gitlab_admin_email'] = '$ADMIN_EMAIL'; \
|
||||
gitlab_rails['initial_root_password'] = '$ROOT_PASS';" \
|
||||
-p 443:443 -p 80:80 -p 2222:22 \
|
||||
--name $CONTAINER_NAME \
|
||||
--restart always \
|
||||
-v $GITLAB_HOME/config:/etc/gitlab \
|
||||
-v $GITLAB_HOME/logs:/var/log/gitlab \
|
||||
-v $GITLAB_HOME/data:/var/opt/gitlab \
|
||||
--shm-size 256m \
|
||||
gitlab/gitlab-ce:latest
|
||||
|
||||
echo "GitLab container is launching. It may take a few minutes to initialize."
|
||||
|
||||
echo "Your GitLab admin login:"
|
||||
echo " Username: root"
|
||||
echo " Password: $ROOT_PASS"
|
||||
echo "Access GitLab at http://$LXC_IP"
|
||||
|
||||
echo "To watch logs: sudo docker logs -f $CONTAINER_NAME"
|
||||
Loading…
x
Reference in New Issue
Block a user