From 732165652a431536e26dc984540c15a222b0378a Mon Sep 17 00:00:00 2001 From: sOckhamSter Date: Thu, 6 May 2021 16:04:49 +0100 Subject: [PATCH 1/9] Add files via upload --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a822ecf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3 +RUN cd / && git clone https://github.com/flobz/psa_car_controller.git +WORKDIR /config +RUN pip3 install -r /psa_car_controller/requirements.txt +#RUN mkdir /config +##### These lines to be removed when merged with main psa_car_controller repo +RUN mkdir /psa_car_controller/docker_files +COPY docker_files/init.sh /psa_car_controller/docker_files +COPY docker_files/dockerconfig.conf /psa_car_controller/docker_files +##### End of temporary lines +EXPOSE 8180 +CMD /psa_car_controller/docker_files/init.sh From b85c5543e03009d87d94cd8db7fecf0c4ecc84f9 Mon Sep 17 00:00:00 2001 From: sOckhamSter Date: Thu, 6 May 2021 16:05:15 +0100 Subject: [PATCH 2/9] Update Dockerfile --- Dockerfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index a822ecf..f5d2d45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,5 @@ FROM python:3 RUN cd / && git clone https://github.com/flobz/psa_car_controller.git WORKDIR /config RUN pip3 install -r /psa_car_controller/requirements.txt -#RUN mkdir /config -##### These lines to be removed when merged with main psa_car_controller repo -RUN mkdir /psa_car_controller/docker_files -COPY docker_files/init.sh /psa_car_controller/docker_files -COPY docker_files/dockerconfig.conf /psa_car_controller/docker_files -##### End of temporary lines EXPOSE 8180 CMD /psa_car_controller/docker_files/init.sh From 0bc41fc8bba76658aff1519524e0f06102289fc3 Mon Sep 17 00:00:00 2001 From: sOckhamSter Date: Thu, 6 May 2021 16:06:29 +0100 Subject: [PATCH 3/9] Create test.txt --- docker_files/test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 docker_files/test.txt diff --git a/docker_files/test.txt b/docker_files/test.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/docker_files/test.txt @@ -0,0 +1 @@ + From 45a2eb8b6bac02ff2afc220b1eebd1d510e68242 Mon Sep 17 00:00:00 2001 From: sOckhamSter Date: Thu, 6 May 2021 16:06:52 +0100 Subject: [PATCH 4/9] Add files via upload --- docker_files/dockerconfig.conf | 1 + docker_files/init.sh | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 docker_files/dockerconfig.conf create mode 100644 docker_files/init.sh diff --git a/docker_files/dockerconfig.conf b/docker_files/dockerconfig.conf new file mode 100644 index 0000000..676c98d --- /dev/null +++ b/docker_files/dockerconfig.conf @@ -0,0 +1 @@ +export SHELL_ONLY="TRUE" diff --git a/docker_files/init.sh b/docker_files/init.sh new file mode 100644 index 0000000..5ef7e75 --- /dev/null +++ b/docker_files/init.sh @@ -0,0 +1,24 @@ +#!/bin/bash +echo "Containerised psa_car_controller loading..." + +echo "Checking for container configuration file /config/dockerconfig.conf" +FILE=/config/dockerconfig.conf +if [ -f "$FILE" ]; then + echo "$FILE exists. Importing file..." + source $FILE +else + echo "$FILE does not exist. Setting default value for SHELL_ONLY=TRUE" + export SHELL_ONLY="TRUE" + echo "Copying default dockerconfig.conf file to /config" + cp /psa_car_controller/docker_files/dockerconfig.conf /config +fi + + +if [ "$SHELL_ONLY" == "TRUE" ] +then + echo "SHELL_ONLY = TRUE. Loading just a bash shell" + /bin/bash +else + echo "SHELL_ONLY = FALSE. Running server.py" + python3 /psa_car_controller/server.py -f /config/test.json -c /config/charge_config1.json -p 8180 -l 0.0.0.0 +fi From 8ca74e27e54c630147733cb7612331e6430b59ba Mon Sep 17 00:00:00 2001 From: sOckhamSter Date: Thu, 6 May 2021 16:07:50 +0100 Subject: [PATCH 5/9] Delete test.txt --- docker_files/test.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 docker_files/test.txt diff --git a/docker_files/test.txt b/docker_files/test.txt deleted file mode 100644 index 8b13789..0000000 --- a/docker_files/test.txt +++ /dev/null @@ -1 +0,0 @@ - From 76c1705feb0e2d23e422e6fcc75ee5b2ef01b1e2 Mon Sep 17 00:00:00 2001 From: sOckhamSter Date: Thu, 6 May 2021 16:15:52 +0100 Subject: [PATCH 6/9] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 7b2f702..dc914e9 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ The official api is documented [here](https://developer.groupe-psa.io/webapi/b2c A video in French was made by vlycop to explain how to use this application : https://youtu.be/XO7-N7G3biU +For information on configuring the psa_car_controller Docker container [see this section](#docker). ## I. Get credentials We need to get credentials from the android app. @@ -150,3 +151,6 @@ If you want to thank me for my work :smile: [![donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/donate?hosted_button_id=SM652WPXFNCXS) +# Docker + + From 0e894502af0e58b1b43b4d73933fe844f7c6444e Mon Sep 17 00:00:00 2001 From: sOckhamSter Date: Thu, 6 May 2021 16:20:15 +0100 Subject: [PATCH 7/9] Update README.md --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/README.md b/README.md index dc914e9..901af93 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,54 @@ If you want to thank me for my work :smile: [![donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/donate?hosted_button_id=SM652WPXFNCXS) +--- # Docker +A containerised version of the psa_car_controller Python scripts by Flobz. +- Docker Hub: https://hub.docker.com/r/sockhamster/psa_car_controller + +### Overview +Once the container is running, the configuration of the psa_car_controller app is near-identical to setup instructions detailed in the app's readme. + +You'll still need to make sure you have an apk for the appropriate Android app that it's attempting to use. The examples in this readme use the MyVauxhall app v1.27.1 from APKPure: +https://m.apkpure.com/myvauxhall-the-official-app-for-vauxhall-drivers/com.psa.mym.myvauxhall/download/2107-APK?from=versions%2Fversion + +On your Docker host, create a config folder which will be mapped to the container and used to store all persistent data. Copy your APK into this folder. + +### Installation +Create the container, detached, exposing port 8180, and mapping the a new config folder on your host to /config inside the container: + +``` +docker run -d -ti --name psa_car_controller1 \ + --publish 8180:8180 \ + -v /host_path/config:/config \ + --restart unless-stopped \ + psa_car_controller +``` + +Connect to the bash shell of the newly created container: +``` +docker exec -it psa_car_controller1 /bin/bash +``` + +Inside the container, run the app_decoder.py script. You'll be prompted for the credentials you use to log into the app on your mobile device usually, plus your country code. If the script gives you a Success! message then move on: +``` +python3 /psa_car_controller/app_decoder.py /config/com.psa.mym.myvauxhall_1.27.1.apk +``` +Start server.py for a first run: +``` +python3 /psa_car_controller/server.py -f /config/test.json -c /config/charge_config1.json -p 8180 -l 0.0.0.0 -r -b /config +``` +You will be prompted to enter a code, sent you you by SMS to your registered mobile number, and the PIN for your account. Sometimes it asks twice (???), but once accepted the service should run. Allow it to run for about a minute before pressing ctrl+c to quit. You should end up back at the bash prompt within the container. + +The final task is to update the container's configuration file to tell it to run the service automatically on next boot. This is done by editing /config/dockerconfig.conf and changing the SHELL_ONLY parameter to FALSE. Alternatively, paste the below command into your shell one by one. These will update the dockerconfig.conf file, exit the container's bash shell, stop the container, then restart the container. + +``` +echo "export SHELL_ONLY=\"FALSE\"" > /config/dockerconfig.conf +exit +docker stop psa_car_controller1 +docker start psa_car_controller1 +``` + + From 84f3afdef2e55b22762c90508d292c17b06984b9 Mon Sep 17 00:00:00 2001 From: sOckhamSter Date: Thu, 6 May 2021 16:36:57 +0100 Subject: [PATCH 8/9] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f5d2d45..6e277bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM python:3 -RUN cd / && git clone https://github.com/flobz/psa_car_controller.git +RUN git clone https://github.com/flobz/psa_car_controller.git /psa_car_controller/ WORKDIR /config RUN pip3 install -r /psa_car_controller/requirements.txt EXPOSE 8180 From a03276dadfbde3bd4b554d94aff7a07e6704c724 Mon Sep 17 00:00:00 2001 From: sOckhamSter Date: Thu, 6 May 2021 16:58:18 +0100 Subject: [PATCH 9/9] Update Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 6e277bc..7dc3590 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,5 @@ RUN git clone https://github.com/flobz/psa_car_controller.git /psa_car_controlle WORKDIR /config RUN pip3 install -r /psa_car_controller/requirements.txt EXPOSE 8180 +RUN chmod +x /psa_car_controller/docker_files/init.sh CMD /psa_car_controller/docker_files/init.sh