diff --git a/0_nfs.sh b/0_nfs.sh index b19979a..352e45a 100755 --- a/0_nfs.sh +++ b/0_nfs.sh @@ -1,6 +1,11 @@ #!/bin/bash # +if [ "$EUID" -ne 0 ]; then + echo "This script must be run as root." >&2 + exit 1 +fi + export DEBIAN_FRONTEND=noninteractive apt update -qy apt -qy install nfs-common diff --git a/1_setup_docker_apt_repo.sh b/1_setup_docker_apt_repo.sh index 3b1c6a6..1827b8c 100755 --- a/1_setup_docker_apt_repo.sh +++ b/1_setup_docker_apt_repo.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [ "$EUID" -ne 0 ]; then + echo "This script must be run as root." >&2 + exit 1 +fi + # REF:https://docs.docker.com/engine/install/debian/#install-using-the-repository # Add Docker's official GPG key: diff --git a/2_install_docker_pkgs.sh b/2_install_docker_pkgs.sh index 2d3cf35..e43ff75 100755 --- a/2_install_docker_pkgs.sh +++ b/2_install_docker_pkgs.sh @@ -1,3 +1,8 @@ #!/bin/bash +if [ "$EUID" -ne 0 ]; then + echo "This script must be run as root." >&2 + exit 1 +fi + apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin diff --git a/3_users.sh b/3_users.sh index f858d86..685ddb1 100755 --- a/3_users.sh +++ b/3_users.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [ "$EUID" -ne 0 ]; then + echo "This script must be run as root." >&2 + exit 1 +fi + grep jenkins /etc/group >/dev/null 2>&1 || groupadd jenkins && echo 'jenkins group exists' grep jenkins /etc/passwd >/dev/null 2>&1 || useradd jenkins -g jenkins -G docker -m && echo 'jenkins user exists' diff --git a/4_provision_networks.sh b/4_provision_networks.sh index eb2579c..9bcefe8 100755 --- a/4_provision_networks.sh +++ b/4_provision_networks.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +if [ "$EUID" -ne 0 ]; then + echo "This script must be run as root." >&2 + exit 1 +fi + ip link set eth0 promisc on docker network inspect infra_dev_net >/dev/null 2>&1 || \ diff --git a/5_config_docker.sh b/5_config_docker.sh index 3bab2a1..eaa34d0 100755 --- a/5_config_docker.sh +++ b/5_config_docker.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +if [ "$EUID" -ne 0 ]; then + echo "This script must be run as root." >&2 + exit 1 +fi + mkdir -p /etc/docker cat << EOF >> /etc/docker/daemon.json diff --git a/99_upgrade.sh b/99_upgrade.sh index 9cdf312..0b1921e 100755 --- a/99_upgrade.sh +++ b/99_upgrade.sh @@ -1,4 +1,10 @@ #!/bin/bash + +if [ "$EUID" -ne 0 ]; then + echo "This script must be run as root." >&2 + exit 1 +fi + export DEBIAN_FRONTEND=noninteractive apt update -qy