tavinus / opkg-upgrade

List and install OpenWRT / LEDE opkg upgradable packages
336 stars 62 forks source link

Script ends with cancelled by user #2

Closed sml156 closed 7 years ago

sml156 commented 7 years ago

I tried your script but it does not ask me if I want to install updates it just say's cancelled by user, Any guidence would be appreciated.

This is the command I used: curl -k -sSL https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh | sh

A little bit about my install and my router:

LEDE/OpenWRT Model | TP-Link TL-WDR4300 v1 Firmware Version | LEDE Reboot 17.01.2 r3435-65eec8bd5f / LuCI lede-17.01 branch (git-17.152.82987-7f6fc16) Kernel Version | 4.4.71

Running your script using curl:

root@LEDE:~# curl -k -sSL  https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh | sh

Simple OPKG Updater v0.2.3

Done | Updating package lists
Done | Getting upgradable packages list

Packages available for upgrade: 13

luci-lib-ip - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1
luci-theme-bootstrap - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1
dnsmasq - 2.77-1 - 2.77-2
luci-app-firewall - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1
odhcp6c - 2017-01-30-c13b6a05-1 - 2017-01-30-c13b6a05-2
dropbear - 2017.75-1 - 2017.75-2
luci-proto-ppp - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1
luci-mod-admin-full - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1
luci-base - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1
luci-proto-ipv6 - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1
luci-lib-nixio - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1
luci-lib-jsonc - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1
luci - git-17.152.82987-7f6fc16-1 - git-17.194.52964-580f012-1

Cancelled by user!

root@LEDE:~#
tavinus commented 7 years ago

Hi! sorry for the late response!

Humm...
I never really tried to run it "directly from the internet".
Does the same thing happen if u try to run it locally?
I mean if u download first and then try to run it locally?

You should be asked if you want to install the updates at that point.
I will try to reproduce it here soon.

tavinus commented 7 years ago

Hi again! Just made a test piping it to sh and I got the same problem.
I am not sure why it does not ask when piping the script.
I am also not sure how to pass a parameter when running like that (you could tell it to install without asking with that).

I would ask you to just download the script and then run it locally instead of directly piping it from curl or wget. So, you can use curl or wget to download as described on the readme, or even use git to clone the repo. Then you can just call it with or without parameters.

If you still want to download and run at once, I would recommend using something like this:

curl -k -sSL https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh -o ./opkg-upgrade.sh && chmod +x ./opkg-upgrade.sh && ./opkg-upgrade.sh

This will download, set to executable and run (on the current directory).
Tested and working!
Hope this helps!

Cheers!
Gus

tavinus commented 7 years ago

Ok, so this seems to be normal to happen in this case.
References:

Because there is not stdin for read to process the response when run like that.
Tell me what you think.

sml156 commented 7 years ago

Thanks for your response, I have not tried to run it locally but I will try the script you just posted thank you.

Update: I tried the command you posted above and it worked perfectly Thank you

tavinus commented 7 years ago

Sweet!
Thanks for posting, good to know it does not work like that anyways.
Cheers!

sml156 commented 7 years ago

I will read the links you posted soon.

I was hoping it would work the same as it does in Ubuntu, I use a DNS server called Pihole and that's how it's installed.

https://github.com/pi-hole/pi-hole

sml156 commented 7 years ago

You should also put that command on your Readme page as long as people have curl installed it works great.

opkg update

opkg install curl

curl -k -sSL https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh -o ./opkg-upgrade.sh && chmod +x ./opkg-upgrade.sh && ./opkg-upgrade.sh

DONE

tavinus commented 7 years ago

As far as I can tell the problem is only with read, which is used to ask for permission to install the updates. When you pipe it to sh another shell is created and stdin is not "redirected" so there is no response (or at least no Y/y response) on which case the script thinks something other than Y was the response.

The download call is basically the same I have on the readme, but without using variables and this one runs the script after downloading. I think it is less intrusive that way, but who knows. The better way is always to use git in any case, but not really needed.

I also have an explanation for the curl -k option to ignore SSL certificates and all there. I believe this should not be default as many people may not realize there is a security risk there.

Cheers!
Gus

tavinus commented 7 years ago

Just a side note. This would also happen in any other linux distro (including ubuntu). Pihole works because it does not ask anything for the user (or he would have the same problem with read not receiving the answer I think). I would need a separate installer script for you to run like that.

Same approach is used by get.acme.sh (LetsEncrypt SH script). He has an installer on http://get.acme.sh which install the acme.sh script itself.

So, in any case, running the installer like that would not run the script itself.

tavinus commented 7 years ago

Also, he uses a variable to pass a parameter, as in:

curl https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh | INSTALLONLINE=1  sh

That INSTALLONLINE=1 there.
But note that he has to do it after the pipe.