pi-hosted icon indicating copy to clipboard operation
pi-hosted copied to clipboard

./update_portainer.sh: 3: function: not found

Open jiimint opened this issue 2 years ago • 6 comments

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"

jiimint avatar Sep 19 '22 06:09 jiimint

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!"

jiimint avatar Sep 19 '22 07:09 jiimint

I am sorry what did you change as this look like the current update_portainer.sh script.

Thanks Robert Middleswarth

rmiddle avatar Sep 19 '22 17:09 rmiddle

The following lines:

In the script: function error I changed: error ()

In the script: function check_internet() I changed: check_internet

jiimint avatar Sep 19 '22 17:09 jiimint

@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

goldjunge91 avatar Sep 21 '22 15:09 goldjunge91

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.

martadinata666 avatar Sep 21 '22 15:09 martadinata666

@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 avatar Sep 21 '22 15:09 jiimint

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

Macleykun avatar Oct 01 '22 19:10 Macleykun