Add new script for reinstall portainer.
This commit is contained in:
parent
c05f2ddfb3
commit
661f3929df
1 changed files with 32 additions and 0 deletions
32
reinstall_portainer.sh
Executable file
32
reinstall_portainer.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
function error() {
|
||||
echo -e "\\e[91m$1\\e[39m"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function check_internet() {
|
||||
printf "Checking if you are online..."
|
||||
wget -q --spider http://github.com
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Online. Continuing."
|
||||
else
|
||||
error "Offline. Go connect to the internet then run the script again."
|
||||
fi
|
||||
}
|
||||
|
||||
check_internet
|
||||
|
||||
portainer_pid=`docker ps | grep portainer-ce | awk '{print $1}'`
|
||||
portainer_name=`docker ps | grep portainer-ce | awk '{print $2}'`
|
||||
|
||||
echo Removing the old version of Portainer
|
||||
sudo docker stop $portainer_pid || error "Failed to stop portainer!"
|
||||
sudo docker rm $portainer_pid || error "Failed to remove portainer container!"
|
||||
sudo docker rmi $portainer_name || error "Failed to remove/untag images from the container!"
|
||||
|
||||
echo Pruning unused volumes
|
||||
sudo docker volume prune
|
||||
|
||||
echo now doing a fresh install of portainer
|
||||
sudo docker run -d -p 9000:9000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest --logo "https://pi-hosted.com/pi-hosted-logo.png" || error "Failed to execute newer version of Portainer!"
|
Loading…
Add table
Reference in a new issue