-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
65 lines (51 loc) · 1.51 KB
/
setup.sh
File metadata and controls
65 lines (51 loc) · 1.51 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
59
60
61
62
63
64
#!/usr/bin/bash
ALL_DEPENDS=()
if ! command -v apt &> /dev/null
then
echo "apt is not available. This script is designed for Debian-based systems."
exit 1
fi
# Check if git is installed
if ! command -v git &> /dev/null
then
ALL_DEPENDS+=("git")
fi
if ! command -v rsync &> /dev/null
then
ALL_DEPENDS+=("rsync")
fi
if ! command -v curl &> /dev/null
then
ALL_DEPENDS+=("curl")
fi
if ! command -v sudo &> /dev/null
then
ALL_DEPENDS+=("sudo")
fi
# Trigger apt if ALL_DEPENDS is not empty
if [[ ${#ALL_DEPENDS[@]} -gt 0 ]]; then
echo "The following dependencies are missing: ${ALL_DEPENDS[*]}"
echo "Installing dependencies (you may need to enter sudo password when prompted)..."
# If we don't have sudo we need to not run as sudo...
if [ "$(id -u)" -ne 0 ]; then
echo "Running as non-root user, using sudo for installation."
SUDO_CMD="sudo"
else
echo "Running as root, installing dependencies directly."
SUDO_CMD=""
fi
$SUDO_CMD apt-get update
$SUDO_CMD apt-get install -y "${ALL_DEPENDS[@]}"
else
echo "All dependencies are already installed."
fi
# This should not _really_ be necessary, but it's always good to ensure
git submodule update --init --recursive
# Check if docker is installed
if ! command -v docker &> /dev/null
then
echo "Docker is not installed. Installing Docker (you may need to enter sudo password when prompted)..."
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
fi