-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvm_startup.sh
More file actions
executable file
·58 lines (47 loc) · 1.52 KB
/
vm_startup.sh
File metadata and controls
executable file
·58 lines (47 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
# Exit on errors
set -e
echo "Updating and installing prerequisites..."
sudo apt update
sudo apt install -y \
make \
nmap \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
echo "Adding Docker's official GPG key..."
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo "Updating package index..."
sudo apt update
echo "Installing Docker Engine, CLI, containerd, and Docker Compose plugin..."
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
echo "Enabling Docker service to start on boot..."
sudo systemctl enable docker
echo "Adding current user to the docker group..."
sudo usermod -aG docker $USER
echo "Cleaning up..."
sudo apt autoremove -y
echo
echo "Installation complete!"
echo
echo "Verify Docker:"
docker --version || true
echo
echo "Verify Docker Compose:"
docker compose version || true
echo "Reboot the system now? (y/n)"
read -r REBOOT_ANSWER
if [[ "$REBOOT_ANSWER" == "y" || "$REBOOT_ANSWER" == "Y" ]]; then
echo "Rebooting..."
sudo reboot
else
echo "Please LOG OUT and LOG BACK IN or reboot to activate docker group membership."
echo "Reboot skipped. Please remember to reboot later to apply changes."
fi