diff --git a/addons/hw_posbox_homepage/controllers/main.py b/addons/hw_posbox_homepage/controllers/main.py index 26509d8d58a..09095fe2adc 100644 --- a/addons/hw_posbox_homepage/controllers/main.py +++ b/addons/hw_posbox_homepage/controllers/main.py @@ -13,20 +13,26 @@ from openerp.tools.translate import _ _logger = logging.getLogger(__name__) +index_style = """ + +""" index_template = """ Odoo's PosBox - +""" + index_style + """

Your PosBox is up and running

@@ -73,15 +79,7 @@ class PosboxHomepage(openerp.addons.web.controllers.main.Home): Wifi configuration - +""" + index_style + """

Configure wifi

@@ -162,3 +160,79 @@ class PosboxHomepage(openerp.addons.web.controllers.main.Home): def clear_wifi_configuration(self): os.system('/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/clear_wifi_configuration.sh') return "configuration cleared" + + @http.route('/remote_connect', type='http', auth='none', cors='*') + def remote_connect(self): + ngrok_template = """ + + + + Remote debugging + + +""" + index_style + """ + + + +

Remote debugging

+

+ This allows someone to gain remote access to your Posbox, and + thus your entire local network. Only enable this for someone + you trust. +

+
+
+ Enable remote debugging +
+ + +""" + return ngrok_template + + @http.route('/enable_ngrok', type='http', auth='none', cors='*') + def enable_ngrok(self, auth_token): + if subprocess.call(['pgrep', 'ngrok']) == 1: + subprocess.Popen(['ngrok', 'tcp', '-authtoken', auth_token, '-log', '/tmp/ngrok.log', '22']) + return 'starting with ' + auth_token + else: + return 'already running' diff --git a/addons/point_of_sale/tools/posbox/configuration/connect_to_wifi.sh b/addons/point_of_sale/tools/posbox/configuration/connect_to_wifi.sh index 1f847104dbb..11f6d18eae4 100755 --- a/addons/point_of_sale/tools/posbox/configuration/connect_to_wifi.sh +++ b/addons/point_of_sale/tools/posbox/configuration/connect_to_wifi.sh @@ -10,6 +10,7 @@ function connect () { ESSID="${1}" PASSWORD="${2}" PERSIST="${3}" + NO_AP="${4}" sleep 3 @@ -54,7 +55,7 @@ function connect () { # give dhcp some time timeout 30 sh -c 'until ifconfig wlan0 | grep "inet addr:" ; do sleep 0.1 ; done' - if [ $? -eq 124 ] ; then + if [ $? -eq 124 ] && [ -z "${NO_AP}" ] ; then logger -t posbox_connect_to_wifi "Failed to connect, forcing Posbox AP" sudo /home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/wireless_ap.sh "force" & else @@ -66,4 +67,4 @@ function connect () { fi } -connect "${1}" "${2}" "${3}" & +connect "${1}" "${2}" "${3}" "${4}" & diff --git a/addons/point_of_sale/tools/posbox/configuration/keep_wifi_alive.sh b/addons/point_of_sale/tools/posbox/configuration/keep_wifi_alive.sh index 5f69451feff..a04aba620d4 100755 --- a/addons/point_of_sale/tools/posbox/configuration/keep_wifi_alive.sh +++ b/addons/point_of_sale/tools/posbox/configuration/keep_wifi_alive.sh @@ -8,7 +8,7 @@ while true ; do logger -t posbox_keep_wifi_alive "Lost wifi, trying to reconnect to ${ESSID}" - sudo /home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/connect_to_wifi.sh "${ESSID}" "${PASSWORD}" + sudo /home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/connect_to_wifi.sh "${ESSID}" "${PASSWORD}" "" "NO_AP" sleep 30 fi diff --git a/addons/point_of_sale/tools/posbox/posbox_create_image.sh b/addons/point_of_sale/tools/posbox/posbox_create_image.sh index 111f6797f4c..5e3d464ef2b 100755 --- a/addons/point_of_sale/tools/posbox/posbox_create_image.sh +++ b/addons/point_of_sale/tools/posbox/posbox_create_image.sh @@ -41,6 +41,15 @@ odoo.py" | tee --append .git/info/sparse-checkout > /dev/null git read-tree -mu HEAD cd "${__dir}" +USR_BIN="${OVERWRITE_FILES_BEFORE_INIT_DIR}/usr/bin/" +mkdir -p "${USR_BIN}" +cd "/tmp" +curl 'https://dl.ngrok.com/ngrok_2.0.19_linux_arm.zip' > ngrok.zip +unzip ngrok.zip +rm ngrok.zip +cd "${__dir}" +mv /tmp/ngrok "${USR_BIN}" + LOOP_MAPPER_PATH=$(kpartx -av posbox.img | tail -n 1 | cut -d ' ' -f 3) LOOP_MAPPER_PATH="/dev/mapper/${LOOP_MAPPER_PATH}" mkdir "${MOUNT_POINT}" @@ -51,6 +60,8 @@ cp -a "${OVERWRITE_FILES_BEFORE_INIT_DIR}"/* "${MOUNT_POINT}" # get rid of the git clone rm -rf "${CLONE_DIR}" +# and the ngrok usr/bin +rm -rf "${OVERWRITE_FILES_BEFORE_INIT_DIR}/usr" # get rid of the mount, we have to remount it anyway because we have # to "refresh" the filesystem after qemu modified it