Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for setting proxy #252

Merged
merged 8 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Make sure the application, using TLS, is running, then pull and run the
$ docker --tlsverify --host tcp://<device-ip>:2376 pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
70f5ac315c5a: Pull complete
70f5ac315c5a: Pull complete
Digest: sha256:88ec0acaa3ec199d3b7eaf73588f4518c25f9d34f58ce9a0df68429c5af48e8d
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
Expand Down Expand Up @@ -391,6 +391,35 @@ For more examples and ideas, visit:

```

#### Proxy Setup
Stiv-work marked this conversation as resolved.
Show resolved Hide resolved

> [!NOTE]
> **From AXIS OS 12.0**
>
> To use the shell script provided to set proxy, [developer mode](#developermode) certificate has to be set on camera, to be able use acap-dockerdwrapper ssh user instead of root ssh user.
Stiv-work marked this conversation as resolved.
Show resolved Hide resolved

**Using provided shell script**
- Modify the docker-acap-set-proxy-in-daemon-json.sh at <myproxy\> <port\> <domain\>
- Call the shell script and then restart the docker acap if already running :

```sh
sh docker-acap-set-proxy-in-daemon-json.sh <device-ip> <ssh-user> <ssh-pass>
```

**Setting proxy without developer mode**\
It is possible to set proxy by creating deamon.json file with the settings needed.

```json
{
"proxies": {
"http-proxy": "http://<myproxy>:<port>",
Stiv-work marked this conversation as resolved.
Show resolved Hide resolved
"https-proxy": "http://<myproxy>:<port>",
"no-proxy": "localhost,127.0.0.0/8,10.0.0.0/8,192.168.0.0/16,172.16.0.0/12,.<domain>"
}
}
```
Instead of the creation of empty daemon.json file in post install script, copy in the daemon.json file you have created.

#### Loading images onto a device

If you have images in a local repository that you want to transfer to a device, or
Expand Down Expand Up @@ -460,6 +489,7 @@ Take a look at the [CONTRIBUTING.md](CONTRIBUTING.md) file.
[2.0.0-release]: https://github.com/AxisCommunications/docker-acap/releases/tag/2.0.0
[buildx]: https://docs.docker.com/build/install-buildx/
[devices]: https://axiscommunications.github.io/acap-documentation/docs/axis-devices-and-compatibility#sdk-and-device-compatibility
[developermode]: http://axiscommunications.github.io/acap-documentation/docs/get-started/set-up-developer-environment/set-up-device-advanced
[dockerDesktop]: https://docs.docker.com/desktop/
[docker_protect-access]: https://docs.docker.com/engine/security/protect-access/
[dockerEngine]: https://docs.docker.com/engine/
Expand Down
49 changes: 49 additions & 0 deletions docker-acap-set-proxy-in-daemon-json.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
[ $# -eq 3 ] || {
printf "Error: Missing arguments\n$0"
exit 0
}

HOSTIP=$1
SSHUSER=$2
PASS=$3
scriptfilename=docker-acap-proxy-append.sh

# Log function
logger() { printf "\n# $*\n" ; }

logger "Create temporary local script file to copy to device"
echo '#!/bin/sh

appname=dockerdwrapper
daemonfile=/usr/local/packages/$appname/localdata/daemon.json

if [ "$(grep proxies $daemonfile)" ] ;then
printf "===>> Proxy already set in docker-acap daemon file\n"
else
printf "===>> Set proxy in docker-acap daemon file\n"
cat > $daemonfile <<EOF
{
"proxies": {
"http-proxy": "http://<myproxy>:<port>",
"https-proxy": "http://<myproxy>:<port>",
"no-proxy": "localhost,127.0.0.0/8,10.0.0.0/8,192.168.0.0/16,172.16.0.0/12,.<domain>"
}
}
EOF

echo "Content of $daemonfile:"
cat $daemonfile
fi' > $scriptfilename
chmod +x $scriptfilename

logger "Copy script file to device /tmp folder"
sshpass -v -p $PASS scp -o StrictHostKeyChecking=no $scriptfilename acap-dockerdwrapper@$HOSTIP:/tmp/

logger "Run script file on device to append proxy, if it doesn't exist"
sshpass -v -p $PASS ssh -o StrictHostKeyChecking=no acap-dockerdwrapper@$HOSTIP "/tmp/$scriptfilename && rm /tmp/$scriptfilename"

logger "Remove local script file"
rm -f $scriptfilename

logger "Restart Docker ACAP for changes to take effect"