Minor fixes for netbox install script, addition of docker and portainer install script

This commit is contained in:
Oliver Gwyther 2024-04-15 22:45:57 +01:00
parent ec354fb93e
commit ee82719851
3 changed files with 44 additions and 2 deletions

View File

@ -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

View File

View File

@ -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/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \[$ALLOWED_HOSTS\]/g" configuration.py
sed -i "s/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py sed -i "s/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py
# Perform initial database migration # Perform initial Netbox database migration
echo "Performing initial database migration..." echo "Performing initial Netbox database migration..."
sudo -u netbox /opt/netbox/upgrade.sh sudo -u netbox /opt/netbox/upgrade.sh
# Create directory for Netbox reports # Create directory for Netbox reports