From ee82719851127200e1278bfe08767085af83863b Mon Sep 17 00:00:00 2001 From: Oliver Gwyther Date: Mon, 15 Apr 2024 22:45:57 +0100 Subject: [PATCH] Minor fixes for netbox install script, addition of docker and portainer install script --- docker-with-portainer/install.sh | 42 ++++++++++++++++++++++++++++++++ docker-with-portainer/readme.md | 0 netbox/install.sh | 4 +-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 docker-with-portainer/install.sh create mode 100644 docker-with-portainer/readme.md diff --git a/docker-with-portainer/install.sh b/docker-with-portainer/install.sh new file mode 100644 index 0000000..72c2720 --- /dev/null +++ b/docker-with-portainer/install.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Update and upgrade the system +sudo apt update +sudo apt upgrade -y + +# Add a new user to run Docker +echo "Adding a new user to run Docker (username 'docker' is recommended)..." +read -p "Enter username for the new Docker user: " USERNAME +sudo useradd -m -s /bin/bash $USERNAME +sudo usermod -aG docker $USERNAME +echo "New user $USERNAME added to the docker group." + +# Install required dependencies +sudo apt install -y apt-transport-https ca-certificates curl software-properties-common + +# Add Docker's official GPG key +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - + +# Add Docker repository +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" + +# Update package index again after adding Docker repository +sudo apt update + +# Install Docker +sudo apt install -y docker-ce + +# Install Docker Compose +sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +sudo chmod +x /usr/local/bin/docker-compose + +# Install Portainer +sudo docker volume create portainer_data +sudo docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data --restart always --name=portainer portainer/portainer-ce + +# Check if Portainer container is running +if sudo docker ps | grep -q portainer; then + echo "Portainer container is running successfully." +else + echo "Failed to start Portainer container." +fi \ No newline at end of file diff --git a/docker-with-portainer/readme.md b/docker-with-portainer/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/netbox/install.sh b/netbox/install.sh index 4f676d6..7a0b3d3 100644 --- a/netbox/install.sh +++ b/netbox/install.sh @@ -75,8 +75,8 @@ echo "Parsing the entered information to configuration.py..." sed -i "s/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \[$ALLOWED_HOSTS\]/g" configuration.py sed -i "s/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py -# Perform initial database migration -echo "Performing initial database migration..." +# Perform initial Netbox database migration +echo "Performing initial Netbox database migration..." sudo -u netbox /opt/netbox/upgrade.sh # Create directory for Netbox reports