-
Notifications
You must be signed in to change notification settings - Fork 1
/
ubuntu_setup.sh
executable file
·82 lines (72 loc) · 2.7 KB
/
ubuntu_setup.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#
# ubuntu_setup.sh - Install all prerequisites on Ubuntu.
# - tested with
# . Windows 11 Pro WSL 2 Ubuntu
# . Ubuntu Desktop (GNOME), Version 1.524OS Ubuntu 22.04
# . https://marketplace.digitalocean.com/apps/ubuntu-desktop-gnome
# . 2 vCPU / 4 GB RAM / regular SSD
# . via ssh
# . passwd user
# . usermod -aG sudo user
# . use RDP for GUI
#
# Distributed under the GNU General Public License version 2 or later, Copyright (c) 2024 Heiko Lübbe
# https://github.com/muhme/joomla-branches-tester
# Run as a non-root user:
# git clone https://github.com/muhme/joomla-branches-tester
# cd joomla-branches-tester
# sudo scripts/ubuntu_setup.sh
# scripts/create
# scripts/test
function help {
echo "*** ubuntu_setup.sh – Installs all prerequisites for Joomla Branches Tester on Ubuntu"
echo "*** The optional argument 'help' displays this page. For full details see https://bit.ly/JBT-README."
}
while [ $# -ge 1 ]; do
if [[ "$1" =~ ^(help|-h|--h|-help|--help|-\?)$ ]]; then
help
exit 0
else
help
echo "*** Error: Argument '$1' is not valid."
exit 1
fi
done
# Running as sudo?
if [ "$(id -u)" -ne 0 ]; then
echo "*** Error: Please run this script as root user with sudo."
exit 1
fi
# Make the hosts entry
HOSTS_FILE="/etc/hosts"
if grep -q host.docker.internal "${HOSTS_FILE}"; then
echo "*** Entry 'host.docker.internal' exists already in '${HOSTS_FILE}' file"
else
echo "*** Adding entry '127.0.0.1 host.docker.internal' to the file '${HOSTS_FILE}'"
echo "127.0.0.1 host.docker.internal" >> "${HOSTS_FILE}"
fi
# Enable SMTP port in Ubuntu Uncomplicated Firewall (UFW)
echo "*** Allow port range 7000:7999/tcp in Ubuntu Uncomplicated Firewall (UFW)"
# This is possible even UFW is disabled or the rules exist already
ufw allow 7000:7999/tcp
# Some basics with git
echo "*** Installing Git and some base packages"
# This can run multiple times
apt-get update
apt-get upgrade -y
apt-get install -y git vim iputils-ping net-tools telnet unzip
# Docker
echo "*** Installing Docker"
# This can run multiple times
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg > /etc/apt/trusted.gpg.d/docker.asc
add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce
# Check if SUDO_USER exists, then use it; otherwise, default to $USER
TARGET_USER=${SUDO_USER:-$USER}
echo "*** Adding '${TARGET_USER}' user to the docker group"
# This can run multiple times
usermod -aG docker "${TARGET_USER}"
echo "*** Finished, please run 'sudo reboot', and after that, you may try 'docker ps'"