[SOLVED] Running SH Script

Trying to run a shell script to install AdGuard VPN CLI for linux

Installed nano and saved adguardvpn.sh

I cannot seem to execute the script? I am trying to install AdGuard VPN CLI.

AdGuard VPN CLI

root@OpenWrt:~# ls
adguardvpn.sh
root@OpenWrt:~# . /adguardvpn.sh
-ash: .: can't open '/adguardvpn.sh': No such file or directory
root@OpenWrt:~#

Router is a client
Extroot to USB
AdGuard Home installed

try

chmod +x ~/adguardvpn.sh
./adguardvpn.sh
2 Likes

That worked. Thank you.

Now it does seem I have to change every curl command in the script before I can run it all the way through!

You can also try installing curl

1 Like

I'm not familiar with the script itself, but I was pretty confident that the initial error was related to the lack of execute permissions.

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.
Thanks! :slight_smile:

1 Like

I was considering installing curl, but there were a few warnings about installing it.

Is it an opkg?

Yes, it is an opkg.

I have installed it and run the instructions from:
AdGuard VPN

Now the error is:

root@OpenWrt:~# curl -fsSL https://raw.githubusercontent.com/AdguardTeam/AdGuard
VPNCLI/master/scripts/release/install.sh | sh -s -- -v
Installing AdGuard VPN...
Update channel: release
CPU type: aarch64
Operating system: linux
AdGuard VPN will be installed to '/opt/adguardvpn_cli'
'/opt/adguardvpn_cli' directory exists
sh: stat: not found
'/opt/adguardvpn_cli' exists but is not owned by 'root'
Would you like to change the ownership of /opt/adguardvpn_cli to root? [y/N] y
sh: sudo: not found
Failed to change ownership of '/opt/adguardvpn_cli'
opkg update
opkg install curl

OpenWrt only has root user - no sudo installed (not needed).

So should I delete every reference to "sudo" in the SH?

1 Like

Yes. sudo doesn't apply in OpenWrt (unless you have added multi-user functionality which is uncommon and usually unnecessary)

2 Likes

By both installing curl and adding permissions (with removing all instances of sudo in the script) everything seems to have installed succesfully!

root@OpenWrt:~# nano
root@OpenWrt:~# ./adguardvpn.sh
Installing AdGuard VPN...
Update channel: release
CPU type: aarch64
Operating system: linux
AdGuard VPN will be installed to '/opt/adguardvpn_cli'
'/opt/adguardvpn_cli' directory exists
./adguardvpn.sh: line 177: stat: not found
'/opt/adguardvpn_cli' exists but is not owned by 'root'
Would you like to change the ownership of /opt/adguardvpn_cli to root? [y/N] y  Ownership of /opt/adguardvpn_cli has been changed to 'root'
Package name: 'adguardvpn-cli-1.0.0-linux-aarch64.tar.gz'
AdGuard VPN will be installed to '/opt/adguardvpn_cli'
Downloading AdGuard VPN package: https://github.com/AdguardTeam/AdGuardVPNCLI/releases/download/v1.0.0-release/adguardvpn-cli-1.0.0-linux-aarch64.tar.gz
AdGuard VPN package has been downloaded successfully
Checking downloaded package 'adguardvpn-cli-1.0.0-linux-aarch64.tar.gz'
Unpacking package from 'adguardvpn-cli-1.0.0-linux-aarch64.tar.gz' into '/opt/adguardvpn_cli'
Package has been unpacked successfully
Would you like to link the binary to /usr/local/bin? [y/N] y
ln: /usr/local/bin: No such file or directory
Failed to link the binary to '/usr/local/bin'

To verify the installation, run the following command to import the public key and verify the signature:
    gpg --keyserver 'keys.openpgp.org' --recv-key '28645AC9776EC4C00BCE2AFC0FE641E7235E2EC6'
    gpg --verify /opt/adguardvpn_cli/adguardvpn-cli.sig /opt/adguardvpn_cli/adguardvpn-cli

AdGuard VPN has been installed successfully!
You can use it by running command:
    /opt/adguardvpn_cli/adguardvpn-cli --help

Much credit to the both of you!

1 Like

Tad unrelated, but the app is saying it cannot run in the background, and to try running with sudo:

16.07.2024 18:59:47.791532 INFO  [3932] VPNCORE vpn_close: [0] ...
16.07.2024 18:59:47.791637 INFO  [3932] VPNCORE vpn_close: [0] Done
16.07.2024 18:59:47.791772 ERROR [3932] CLI_APP ~CliApp:

        > Please try running the command with `sudo -E`
Failed to start the VPN service in the background

Try running with ampersand at the end.

&

Not really OpenWrt-specific - this disconnects the executed command from the console.

Same issue with & at the end

Help file:

CLI for controlling AdGuard VPN
Usage: /opt/adguardvpn_cli/adguardvpn-cli [OPTIONS] SUBCOMMAND

Options:
  -h,--help                   Print this help message and exit
  --help-all                  Show all available commands, subcommands and options
  -v,--version                Display program version information and exit

Subcommands:
  login                       Log in to AdGuard VPN
  logout                      Log out from AdGuard VPN
  list-locations              List all available VPN locations
  connect                     Connect to AdGuard VPN
  disconnect                  Stop the VPN service
  status                      Display the current status of the VPN service
  config                      Configure VPN service
  check-update                Check for updates
  update                      Install new version if available

Are you saying that's the output you received?

Can you show the command you entered and full output?

Output with &

root@OpenWrt:~# /opt/adguardvpn_cli/adguardvpn-cli connect -f &
                16.07.2024 19:12:42.289826 INFO  [4021] STANDALONE_CLIENT set_ou16.07.2024 19:12:42.322561 INFO  [4021] VPNCORE vpn_stop: [0] ...
16.07.2024 19:12:42.322702 INFO  [4021] VPNCORE vpn_stop: [0] Stopping event lo
16.07.2024 19:12:42.322853 INFO  [4027] VPNCORE raise_state: [0] VPN_SS_DISCONN
16.07.2024 19:12:42.323016 INFO  [4021] VPNCORE vpn_stop: [0] Event loop has be
16.07.2024 19:12:42.323145 INFO  [4021] DNS proxy deinit: Joining event loop
Failed to start the VPN service in the background

[1]+  Done                       /opt/adguardvpn_cli/adguardvpn-cli connect -f
1 Like

Post output of ls -la /opt/adguardvpn_cli

Edit: also there is an official Adguard Home package for OpenWrt - why not use it?
opkg install adguardhome

I have already installed AdGuard Home. I am trying to install AdGuard VPN (IKEv2 Client)

1 Like

I see. Then please

1 Like

Output of: ls -la /opt/adguardvpn_cli

root@OpenWrt:~# ls -la /opt/adguardvpn_cli
drwxr-xr-x    2 root     root          3488 Jul 16 18:49 .
drwxr-xr-x    3 root     root          3488 Jul 16 18:30 ..
-rwxrwxrwx    1 root     root      11327312 May 30 14:59 adguardvpn-cli
-rw-rw-rw-    1 root     root           587 May 30 14:59 adguardvpn-cli.sig
1 Like

Try this:

mkdir -p /usr/local/bin
ln -sf /opt/adguardvpn_cli/adguardvpn-cli /usr/local/bin/adguardvpn-cli
/opt/adguardvpn_cli/adguardvpn-cli connect -f

Not sure this will work but worth a try, I guess.