-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathupdate-system.sh
More file actions
13 lines (12 loc) · 848 Bytes
/
update-system.sh
File metadata and controls
13 lines (12 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env bash
# @title: Update System
# @description: For Updating Packages and Portainer
# Tested on Ubuntu 20.04
LATEST="$(wget -qO- https://hub.docker.com/v1/repositories/portainer/portainer-ce/tags)"
LATEST=$(echo "$LATEST" | sed "s/{//g" | sed "s/}//g" | sed "s/\"//g" | cut -d ' ' -f2)
RUNNING=$(docker inspect "portainer/portainer-ce" | grep Id | sed "s/\"//g" | sed "s/,//g" | tr -s " " | cut -d " " -f3)
if [ "$RUNNING" != "$LATEST" ]; then
docker stop portainer && docker rm portainer && docker rmi portainer/portainer-ce &&
docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -e VIRTUAL_HOST=portainer.home -e VIRTUAL_PORT=9000 -v portainer_data:/data --network net portainer/portainer-ce:latest
fi
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y