pi-hosted
pi-hosted copied to clipboard
./update_portainer.sh: 3: function: not found
Congrats great work!!!I have an issue with updgrade portainer. I run command "sh ./update_portainer.sh" from your gitHub novaspirit/pi-hole and i get an error: "./update_portainer.sh: 3: function: not found"
Finally I found the solution:
#!/bin/bash
error () { echo -e "\e[91m$1\e[39m" exit 1 }
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}'
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!" 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!"
I am sorry what did you change as this look like the current update_portainer.sh script.
Thanks Robert Middleswarth
The following lines:
In the script: function error I changed: error ()
In the script: function check_internet() I changed: check_internet
@jiimint for me i have to change also the #!/bin/bash to #!/bin/sh i make a pull request to the changes. https://github.com/novaspirit/pi-hosted/pull/386
I see, the issue itself is how the script run by user. The script already define /bin/bash
which is work, but it run with sh install_portainer.sh
that making function error. And after commits to new function name the script still on /bin/bash
causing issues.
@jiimint for me i have to change also the #!/bin/bash to #!/bin/sh i make a pull request to the changes. #386
Thanks for your quick reply and I am happy that resolved the problem.
@jiimint for me i have to change also the #!/bin/bash to #!/bin/sh i make a pull request to the changes. #386
Thanks for your quick reply and I am happy that resolved the problem.
can you close the issue :) ? thanks in advanced!