diff --git a/config/inventory b/config/inventory index c12ab59d292bcfd698062eebe51ab8d708e8f92d..c4e50cf956c32822dd57903ea8f68727ee92a3d9 100644 --- a/config/inventory +++ b/config/inventory @@ -12,7 +12,7 @@ ss2 [ss2] ss2-s6 ansible_host=192.168.1.244 -ss2-s5 ansible_host=192.168.1.100 +; ss2-s5 ansible_host=192.168.1.100 # rp4 ansible_host=192.168.1.248 diff --git a/files/positionGetter.sh b/files/positionGetter.sh index e2ff58d113e9ea7c250e667d5e685e4e1e896425..503cd379677cf31ac2dfcf73e59dc5540c298a48 100755 --- a/files/positionGetter.sh +++ b/files/positionGetter.sh @@ -9,17 +9,18 @@ fi # files in /temp will get deleted on reboot gpsLocations=$(mktemp /tmp/locations-XXXXXX.gps) -gpsPresenceTest=$(mktemp /tmp/test-XXXXXX.gps) -timeout 1s sudo gpiomon 4 15 > $gpsPresenceTest -if [ $(cat $gpsPresenceTest | wc -l) -eq 0 ]; then -echo "no gps found !" -exit 1 -fi - -while echo $(pgrep -a "sniffer.py" >/dev/null; echo $?); do - - data=$(gpspipe --nmea -n 10 | awk -F, '$1 == "$GPGGA"' | awk -F, '{print $3, $5, $10}') - # $GPGGA,124226.00,4842.8648,N,00212.3549,E,1,07,1.30,160.28,M,46.512,M,,*63 +# gpsPresenceTest=$(mktemp /tmp/test-XXXXXX.gps) +# timeout 1s sudo gpiomon 4 15 > $gpsPresenceTest +# if [ $(cat $gpsPresenceTest | wc -l) -eq 0 ]; then +# echo "no gps found !" +# exit 1 +# fi +# this test prevents any further connection + +while [ $(pgrep -a "sniffer.py" >/dev/null; echo $?) == 0 ]; do + + data=$(gpspipe -w -n 10 |grep -om1 "[-]\?[[:digit:]]\{1,3\}\.[[:digit:]]\{9\}.*[[:digit:]]\{1,3\}\.[[:digit:]]\{9\}" | sed 's/"lon"://g') + # 48.714318200,2.206028200 # │ Latitude: 48.71441340 N │ # │ Longitude: 2.20591520 E │ # │ Alt (HAE, MSL): 206.490, 160.283 m @@ -40,6 +41,6 @@ awk -F',' ' alt += $3; } END { - print lat/NR/100,lon/NR/100,alt/NR; -}' $gpsLocations > $3"/location-"$4".log" + print lat/NR,lon/NR,alt/NR; +}' $gpsLocations > "$(echo $3"/location-"$4".log")" # will write eg as ~/mitik-sens/location-MM-DD-HH-MM-wifiX-chan6.log diff --git a/playbooks/data_transfer.yml b/playbooks/data_transfer.yml index 3f861211f904796387b16baf59223e7e0ba9c283..15175ef1b3af14f3a9f23b08ba9e4fae939c731f 100644 --- a/playbooks/data_transfer.yml +++ b/playbooks/data_transfer.yml @@ -8,7 +8,7 @@ ansible.builtin.find: paths: "~/mitik-sens/" # top folder to search from/in recurse: false # yes|no recursive file search ? - patterns: "*.pcap, *.gps" # what your target files look like + patterns: "mitik_exp*.pcap, *.gps" # what your target files look like register: files_to_copy - name: Get local time diff --git a/playbooks/microstask_GPS_setup.yml b/playbooks/microstask_GPS_setup.yml index fcb98f12774bec82f41c71a593acc40cd03c9cda..c8248574e5121273814a615e922646e65e08d475 100644 --- a/playbooks/microstask_GPS_setup.yml +++ b/playbooks/microstask_GPS_setup.yml @@ -4,36 +4,37 @@ become_user: root tasks: - - name: Timezone config - ansible.builtin.command: sudo timedatectl set-timezone Europe/Paris - changed_when: false + - name: Timezone config + ansible.builtin.command: sudo timedatectl set-timezone Europe/Paris + changed_when: false - - name: Raspi-config serial_hw - ansible.builtin.command: sudo raspi-config nonint do_serial_hw 0 - changed_when: false + - name: Raspi-config serial_hw + ansible.builtin.command: sudo raspi-config nonint do_serial_hw 0 + changed_when: false - - name: Install required packages - tags: sniffer-setup config nodes - ansible.builtin.apt: + - name: Install required packages + tags: sniffer-setup config nodes + ansible.builtin.apt: update_cache: true pkg: - gpsd # - gpsd-clients - pps-tools - chrony + - - name: Systemctl enable gpsd - ansible.builtin.shell: | + - name: Systemctl enable gpsd + ansible.builtin.shell: | sudo systemctl enable gpsd.socket sudo systemctl enable gpsd sudo systemctl restart gpsd sudo systemctl enable chrony sudo systemctl restart chrony - - name: Copy a new config gpsd device functionality - become: true - become_user: root - ansible.builtin.blockinfile: + - name: Copy a new config gpsd device functionality + become: true + become_user: root + ansible.builtin.blockinfile: dest: /boot/firmware/config.txt block: | [all] @@ -44,42 +45,42 @@ # it is possible to set cnoditional parameters depending on device: https://www.raspberrypi.com/documentation/computers/config_txt.html#model-filters - # - name: Copy a new pps GPIO device in modules - # blockinfile: | - # dest=/etc/modules - # content="pps-gpio" - # dtoverlay loads the module already + # - name: Copy a new pps GPIO device in modules + # blockinfile: | + # dest=/etc/modules + # content="pps-gpio" + # dtoverlay loads the module already - - name: gpsd port pointer - ansible.builtin.command: sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock + - name: gpsd port pointer + ansible.builtin.command: sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock - - name: Copy a new config gpsd device functionality - ansible.builtin.copy: + - name: Copy a new config gpsd device functionality + ansible.builtin.copy: src: ../files/gpsd dest: /etc/default/gpsd - - name: Reconfigure gpsd - ansible.builtin.command: sudo dpkg-reconfigure gpsd + - name: Reconfigure gpsd + ansible.builtin.command: sudo dpkg-reconfigure gpsd - - name: Remove IPv6 bind - ansible.builtin.copy: + - name: Remove IPv6 bind + ansible.builtin.copy: src: ../files/gpsd.socket dest: /lib/systemd/system/gpsd.socket - # - name: ntp uninstall - # command: sudo apt remove ntp -y - # Network Time Protocol daemon/utilities (transitional package) - # This is a dummy transitional package to transition to NTPsec. - # It can be safely removed. + # - name: ntp uninstall + # command: sudo apt remove ntp -y +# Network Time Protocol daemon/utilities (transitional package) +# This is a dummy transitional package to transition to NTPsec. +# It can be safely removed. - - name: chrony config file GPS time synchronization - ansible.builtin.copy: + - name: chrony config file GPS time synchronization + ansible.builtin.copy: src: ../files/chrony.conf dest: /etc/chrony/chrony.conf - - name: transfer location finder - become: true - ansible.builtin.copy: + - name: transfer location finder + become: true + ansible.builtin.copy: src: ../files/positionGetter.sh dest: "/home/{{ ansible_ssh_user }}/positionGetter.sh" mode: 0755 diff --git a/playbooks/start_sens_sniffer.yml b/playbooks/start_sens_sniffer.yml index a5a6a898e529d569abc0c69c1f4c0e293e6ff1cd..1d3adc10a273e9cb127659c809029341947099c9 100644 --- a/playbooks/start_sens_sniffer.yml +++ b/playbooks/start_sens_sniffer.yml @@ -7,7 +7,7 @@ - name: _workdir prompt: Enter the folder where the script is and results will be - default: "/home/tribe/mitik-sens/" + default: "/home/tribe/mitik-sens-mod/" private: false # This will always be the mitik-sens folder @@ -18,22 +18,22 @@ - name: _hour prompt: Enter an hour to start the experiment - default: "{{ lookup('pipe', 'date -d \"+15 minutes\" +%H') }}" + default: "{{ lookup('pipe', 'date -d \"+2 minutes\" +%H') }}" private: false - name: _minute prompt: Enter minutes to start the experiment - default: "{{ lookup('pipe', 'date -d \"+15 minutes\" +%M') }}" + default: "{{ lookup('pipe', 'date -d \"+2 minutes\" +%M') }}" private: false - name: _pcap_name - prompt: "Name of the PCAP file. %post will get replaced by a bunch of context info (date and params) and .pcap" - default: "mitik_experiment-%post" + prompt: "Name of the PCAP file. ?post will get replaced by a bunch of context info (date and params) and .pcap" + default: "mitik_experiment-?post" private: false - name: _timeout prompt: Please specify the runtime duration in sec - default: 3600 + default: 300 private: false - name: _interfaces_csv @@ -70,20 +70,25 @@ - name: _gps_poll_timeout prompt: time in seconds between each location polling - default: 900 + default: 60 private: false tasks: - ansible.builtin.set_fact: - _interfaces: " {{ _interfaces_csv.split(',') }} " + _interfaces: "{{ _interfaces_csv.split(',')}}" _channels: "{{ _channels_csv.split(',') }}" - _location_prefix: "{{ _pcap_name | replace('%post', '') }}" + _location_prefix: "{{ _pcap_name | replace('?post', '') }}" delegate_to: 127.0.0.1 run_once: true - + - debug: + var: _interfaces_csv + - debug: + var: _interfaces + - debug: + var: _interfaces - name: Double-check input variables ansible.builtin.assert: - that: "{{ _interfaces | length }} == {{ _channels | length }}" + that: "{{_interfaces | length}} == {{_channels | length}}" delegate_to: 127.0.0.1 run_once: true any_errors_fatal: true @@ -94,7 +99,7 @@ name: "ansible_sens_sniffer {{ _hour }} {{ _minute }} {{ item }}" minute: "{{ _minute }}" hour: "{{ _hour }}" - job: "cd {{_workdir}}; sudo python ./sniffer.py -s {{_timeout}} -i {{item}} -c {{_channels[my_idx]}} -j {{_channel_hopping}} -sf {{_filter}} -p {{_hash_pattern}} -e {{_hash_function}} -w {{_pcap_name}}" + job: "cd {{_workdir}}; sudo python ./sniffer.py -t {{_timeout}} -i {{item}} -c {{_channels[my_idx]}} -j {{_channel_hopping}} -sf {{_filter}} -p {{_hash_pattern}} -e {{_hash_function}} -w '{{_pcap_name}}'" loop: "{{ _interfaces }}" loop_control: index_var: my_idx @@ -104,4 +109,4 @@ name: "ansible_sens_gps {{ _hour }} {{ _minute }}" minute: "{{ _minute }}" hour: "{{ _hour }}" - job: "/home/{{ansible_ssh_user}}/positionGetter.sh {{_gps_poll_timeout}} 10 '{{_workdir}}' '{{_location_prefix}}-location$(date +%Y%m%d_%H%M%S).gps'" + job: "/home/{{ansible_ssh_user}}/positionGetter.sh {{_gps_poll_timeout}} 10 '{{_workdir}}' '{{_location_prefix}}location$(date +%Y%m%d_%H%M%S).gps'"