Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2023-10-31 16:14:38 +01:00
parent 9eddb44919
commit a5ee37cfe1

View File

@ -147,491 +147,495 @@
ARCHFLAGS: "-arch aarch64" ARCHFLAGS: "-arch aarch64"
tasks: tasks:
- name: Create pi user - name: get ansible facts
copy: debug:
dest: /boot/userconf var: ansible_facts
content: |
pi:$6$3jNr0GA9KIyt4hmM$efeVIopdMQ8DGgEPCWWlbx3mJJNAYci1lEXGdlky0xPyjqwKNbwTL5SrCcpb4144C4IvzWjn7Iv.QjqmU7iyT/ - name: Create pi user
copy:
- name: change hostname dest: /boot/userconf
lineinfile: content: |
dest: /etc/hostname pi:$6$3jNr0GA9KIyt4hmM$efeVIopdMQ8DGgEPCWWlbx3mJJNAYci1lEXGdlky0xPyjqwKNbwTL5SrCcpb4144C4IvzWjn7Iv.QjqmU7iyT/
regexp: '^raspberrypi'
line: "{{pwnagotchi.hostname}}" - name: change hostname
state: present lineinfile:
when: lookup('file', '/etc/hostname') == "raspberrypi" dest: /etc/hostname
register: hostname regexp: '^raspberrypi'
line: "{{pwnagotchi.hostname}}"
- name: add hostname to /etc/hosts state: present
lineinfile: when: lookup('file', '/etc/hostname') == "raspberrypi"
dest: /etc/hosts register: hostname
regexp: '^127\.0\.1\.1[ \t]+raspberrypi'
line: "127.0.1.1\t{{pwnagotchi.hostname}}" - name: add hostname to /etc/hosts
state: present lineinfile:
when: hostname.changed dest: /etc/hosts
regexp: '^127\.0\.1\.1[ \t]+raspberrypi'
- name: disable sap plugin for bluetooth.service line: "127.0.1.1\t{{pwnagotchi.hostname}}"
lineinfile: state: present
dest: /lib/systemd/system/bluetooth.service when: hostname.changed
regexp: '^ExecStart=/usr/lib/bluetooth/bluetoothd$'
line: 'ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap' - name: disable sap plugin for bluetooth.service
state: present lineinfile:
dest: /lib/systemd/system/bluetooth.service
- name: configure dphys-swapfile regexp: '^ExecStart=/usr/lib/bluetooth/bluetoothd$'
lineinfile: line: 'ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap'
path: /etc/dphys-swapfile state: present
regexp: "^CONF_SWAPSIZE=.*$"
line: "CONF_SWAPSIZE=2048" - name: configure dphys-swapfile
lineinfile:
- name: install packages path: /etc/dphys-swapfile
apt: regexp: "^CONF_SWAPSIZE=.*$"
name: "{{ packages.apt.install }}" line: "CONF_SWAPSIZE=2048"
state: present
update_cache: yes - name: install packages
install_recommends: false apt:
name: "{{ packages.apt.install }}"
# Install nexmon to fix wireless scanning (takes 2.5G of space) state: present
- name: clone nexmon repository update_cache: yes
git: install_recommends: false
repo: https://github.com/DrSchottky/nexmon.git
dest: /usr/local/src/nexmon # Install nexmon to fix wireless scanning (takes 2.5G of space)
- name: clone nexmon repository
- name: make firmware git:
shell: "source ./setup_env.sh && make" repo: https://github.com/DrSchottky/nexmon.git
args: dest: /usr/local/src/nexmon
executable: /bin/bash
chdir: /usr/local/src/nexmon/ - name: make firmware
shell: "source ./setup_env.sh && make"
- name: choose the right kernel version (bcm43436b0) args:
replace: executable: /bin/bash
dest: /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/Makefile chdir: /usr/local/src/nexmon/
backup: no
regexp: "KERNEL_VERSION = .*$" - name: choose the right kernel version (bcm43436b0)
replace: "KERNEL_VERSION = {{ kernel.min }}" replace:
dest: /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/Makefile
- name: choose the right kernel release (variable) (bcm43436b0) backup: no
lineinfile: regexp: "KERNEL_VERSION = .*$"
dest: /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/Makefile replace: "KERNEL_VERSION = {{ kernel.min }}"
insertafter: "DRIVER_FOLDER_NAME = .*$"
line: "KERNEL_RELEASE = {{ kernel.full }}" - name: choose the right kernel release (variable) (bcm43436b0)
lineinfile:
- name: choose the right kernel release (replace string) (bcm43436b0) dest: /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/Makefile
replace: insertafter: "DRIVER_FOLDER_NAME = .*$"
dest: /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/Makefile line: "KERNEL_RELEASE = {{ kernel.full }}"
backup: no
regexp: "shell uname -r" - name: choose the right kernel release (replace string) (bcm43436b0)
replace: "KERNEL_RELEASE" replace:
dest: /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/Makefile
- name: make firmware patch (bcm43455c0) backup: no
shell: "source ./setup_env.sh && cd /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/ && make" regexp: "shell uname -r"
args: replace: "KERNEL_RELEASE"
executable: /bin/bash
chdir: /usr/local/src/nexmon/ - name: make firmware patch (bcm43455c0)
shell: "source ./setup_env.sh && cd /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/ && make"
- name: install new firmware (bcm43455c0) args:
copy: executable: /bin/bash
src: /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/brcmfmac43455-sdio.bin chdir: /usr/local/src/nexmon/
dest: /usr/lib/firmware/brcm/brcmfmac43455-sdio.bin
follow: true - name: install new firmware (bcm43455c0)
copy:
- name: choose the right kernel version (bcm43436b0) src: /usr/local/src/nexmon/patches/bcm43455c0/7_45_206/nexmon/brcmfmac43455-sdio.bin
replace: dest: /usr/lib/firmware/brcm/brcmfmac43455-sdio.bin
dest: /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/Makefile follow: true
backup: no
regexp: "KERNEL_VERSION = .*$" - name: choose the right kernel version (bcm43436b0)
replace: "KERNEL_VERSION = {{ kernel.min }}" replace:
dest: /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/Makefile
- name: choose the right kernel release (variable) (bcm43436b0) backup: no
lineinfile: regexp: "KERNEL_VERSION = .*$"
dest: /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/Makefile replace: "KERNEL_VERSION = {{ kernel.min }}"
insertafter: "DRIVER_FOLDER_NAME = .*$"
line: "KERNEL_RELEASE = {{ kernel.full }}" - name: choose the right kernel release (variable) (bcm43436b0)
lineinfile:
- name: choose the right kernel release (replace string) (bcm43436b0) dest: /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/Makefile
replace: insertafter: "DRIVER_FOLDER_NAME = .*$"
dest: /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/Makefile line: "KERNEL_RELEASE = {{ kernel.full }}"
backup: no
regexp: "shell uname -r" - name: choose the right kernel release (replace string) (bcm43436b0)
replace: "KERNEL_RELEASE" replace:
dest: /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/Makefile
- name: make firmware patch (bcm43436b0) backup: no
shell: "source ./setup_env.sh && cd /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/ && make" regexp: "shell uname -r"
args: replace: "KERNEL_RELEASE"
executable: /bin/bash
chdir: /usr/local/src/nexmon/ - name: make firmware patch (bcm43436b0)
shell: "source ./setup_env.sh && cd /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/ && make"
- name: install new firmware (bcm43436b0) args:
copy: executable: /bin/bash
src: /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/brcmfmac43436-sdio.bin chdir: /usr/local/src/nexmon/
dest: /usr/lib/firmware/brcm/brcmfmac43436-sdio.bin
follow: true - name: install new firmware (bcm43436b0)
copy:
- name: choose the right kernel version (bcm43436b0) src: /usr/local/src/nexmon/patches/bcm43436b0/9_88_4_65/nexmon/brcmfmac43436-sdio.bin
replace: dest: /usr/lib/firmware/brcm/brcmfmac43436-sdio.bin
dest: /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/Makefile follow: true
backup: no
regexp: "KERNEL_VERSION = .*$" - name: choose the right kernel version (bcm43436b0)
replace: "KERNEL_VERSION = {{ kernel.min }}" replace:
dest: /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/Makefile
- name: choose the right kernel release (variable) (bcm43436b0) backup: no
lineinfile: regexp: "KERNEL_VERSION = .*$"
dest: /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/Makefile replace: "KERNEL_VERSION = {{ kernel.min }}"
insertafter: "DRIVER_FOLDER_NAME = .*$"
line: "KERNEL_RELEASE = {{ kernel.full }}" - name: choose the right kernel release (variable) (bcm43436b0)
lineinfile:
- name: choose the right kernel release (replace string) (bcm43436b0) dest: /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/Makefile
replace: insertafter: "DRIVER_FOLDER_NAME = .*$"
dest: /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/Makefile line: "KERNEL_RELEASE = {{ kernel.full }}"
backup: no
regexp: "shell uname -r" - name: choose the right kernel release (replace string) (bcm43436b0)
replace: "KERNEL_RELEASE" replace:
dest: /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/Makefile
- name: make firmware patch (bcm43430a1) backup: no
shell: "source ./setup_env.sh && cd /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/ && make" regexp: "shell uname -r"
args: replace: "KERNEL_RELEASE"
executable: /bin/bash
chdir: /usr/local/src/nexmon/ - name: make firmware patch (bcm43430a1)
shell: "source ./setup_env.sh && cd /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/ && make"
- name: install new firmware (bcm43430a1) args:
copy: executable: /bin/bash
src: /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin chdir: /usr/local/src/nexmon/
dest: /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin
follow: true - name: install new firmware (bcm43430a1)
copy:
- name: copy 43430-sdio as 43436s-sdio for the special 43430/1 /2 src: /usr/local/src/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin
copy: dest: /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin
src: /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin follow: true
dest: /usr/lib/firmware/brcm/brcmfmac43436s-sdio.bin
follow: true - name: copy 43430-sdio as 43436s-sdio for the special 43430/1 /2
copy:
- name: Delete the firmware blob to avoid it crashing src: /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin
file: dest: /usr/lib/firmware/brcm/brcmfmac43436s-sdio.bin
state: absent follow: true
path: /usr/lib/firmware/brcm/brcmfmac43430-sdio.clm_blob
- name: Delete the firmware blob to avoid it crashing
- name: Delete the RPiZW firmware blob to avoid it crashing file:
file: state: absent
state: absent path: /usr/lib/firmware/brcm/brcmfmac43430-sdio.clm_blob
path: /usr/lib/firmware/brcm/brcmfmac43430-sdio.raspberrypi,model-zero-w.clm_blob
- name: Delete the RPiZW firmware blob to avoid it crashing
- name: Delete the RPi3 firmware blob to avoid it crashing file:
file: state: absent
state: absent path: /usr/lib/firmware/brcm/brcmfmac43430-sdio.raspberrypi,model-zero-w.clm_blob
path: /usr/lib/firmware/brcm/brcmfmac43430-sdio.raspberrypi,3-model-b.clm_blob
- name: Delete the RPi3 firmware blob to avoid it crashing
- name: Delete the RPi02w firmware blob to avoid it crashing file:
file: state: absent
state: absent path: /usr/lib/firmware/brcm/brcmfmac43430-sdio.raspberrypi,3-model-b.clm_blob
path: /usr/lib/firmware/brcm/brcmfmac43430b0-sdio.raspberrypi,model-zero-2-w.clm_blob
- name: Delete the RPi02w firmware blob to avoid it crashing
- name: Delete the RPi02w firmware blob to avoid it crashing file:
file: state: absent
state: absent path: /usr/lib/firmware/brcm/brcmfmac43430b0-sdio.raspberrypi,model-zero-2-w.clm_blob
path: /usr/lib/firmware/brcm/brcmfmac43436-sdio.clm_blob
- name: Delete the RPi02w firmware blob to avoid it crashing
- name: Delete the RPi302w firmware blob to avoid it crashing file:
file: state: absent
state: absent path: /usr/lib/firmware/brcm/brcmfmac43436-sdio.clm_blob
path: /usr/lib/firmware/brcm/brcmfmac43436-sdio.raspberrypi,model-zero-2-w.clm_blob
- name: Delete the RPi302w firmware blob to avoid it crashing
- name: Delete the RPi02w firmware blob to avoid it crashing file:
file: state: absent
state: absent path: /usr/lib/firmware/brcm/brcmfmac43436-sdio.raspberrypi,model-zero-2-w.clm_blob
path: /usr/lib/firmware/brcm/brcmfmac43455-sdio.clm_blo
- name: Delete the RPi02w firmware blob to avoid it crashing
- name: backup original driver file:
command: "mv /usr/lib/modules/{{ kernel.full }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko.xz /usr/lib/modules/{{ kernel.full }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko.xz.orig" state: absent
path: /usr/lib/firmware/brcm/brcmfmac43455-sdio.clm_blo
- name: copy modified driver
copy: - name: backup original driver
src: "/usr/local/src/nexmon/patches/driver/brcmfmac_{{ kernel.min }}.y-nexmon/brcmfmac.ko" command: "mv /usr/lib/modules/{{ kernel.full }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko.xz /usr/lib/modules/{{ kernel.full }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko.xz.orig"
dest: "/usr/lib/modules/{{ kernel.full }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko"
- name: copy modified driver
- name : load brcmfmac drivers copy:
command: "/sbin/depmod -a {{ kernel.full }}" src: "/usr/local/src/nexmon/patches/driver/brcmfmac_{{ kernel.min }}.y-nexmon/brcmfmac.ko"
dest: "/usr/lib/modules/{{ kernel.full }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko"
# To shrink the final image, remove the nexmon directory (takes 2.5G of space) post build and installation
- name: Delete nexmon content & directory - name : load brcmfmac drivers
file: command: "/sbin/depmod -a {{ kernel.full }}"
state: absent
path: /usr/local/src/nexmon/ # To shrink the final image, remove the nexmon directory (takes 2.5G of space) post build and installation
- name: Delete nexmon content & directory
- name: Create custom plugin directory file:
file: state: absent
path: /usr/local/share/pwnagotchi/custom-plugins/ path: /usr/local/src/nexmon/
state: directory
- name: Create custom plugin directory
- name: Create custom config directory file:
file: path: /usr/local/share/pwnagotchi/custom-plugins/
path: /etc/pwnagotchi/conf.d/ state: directory
state: directory
- name: Create custom config directory
- name: clone pwnagotchi repository file:
git: path: /etc/pwnagotchi/conf.d/
repo: https://github.com/jayofelony/pwnagotchi.git state: directory
dest: /usr/local/src/pwnagotchi
register: pwnagotchigit - name: clone pwnagotchi repository
git:
- name: build pwnagotchi wheel repo: https://github.com/jayofelony/pwnagotchi.git
command: "python3 setup.py sdist bdist_wheel" dest: /usr/local/src/pwnagotchi
args: register: pwnagotchigit
chdir: /usr/local/src/pwnagotchi
when: (pwnagotchigit.changed) or (pip_packages['pwnagotchi'] is undefined) or (pip_packages['pwnagotchi'] != pwnagotchi_version) - name: build pwnagotchi wheel
command: "python3 setup.py sdist bdist_wheel"
- name: install pwnagotchi wheel and dependencies args:
pip: chdir: /usr/local/src/pwnagotchi
name: "{{ lookup('fileglob', '/usr/local/src/pwnagotchi/dist/pwnagotchi*.whl') }}" when: (pwnagotchigit.changed) or (pip_packages['pwnagotchi'] is undefined) or (pip_packages['pwnagotchi'] != pwnagotchi_version)
extra_args: "--no-cache-dir"
when: (pwnagotchigit.changed) or (pip_packages['pwnagotchi'] is undefined) or (pip_packages['pwnagotchi'] != pwnagotchi_version) - name: install pwnagotchi wheel and dependencies
pip:
- name: remove pwnagotchi folder name: "{{ lookup('fileglob', '/usr/local/src/pwnagotchi/dist/pwnagotchi*.whl') }}"
file: extra_args: "--no-cache-dir"
state: absent when: (pwnagotchigit.changed) or (pip_packages['pwnagotchi'] is undefined) or (pip_packages['pwnagotchi'] != pwnagotchi_version)
path: /usr/local/src/pwnagotchi
- name: remove pwnagotchi folder
- name: create /usr/local/share/pwnagotchi/ folder file:
file: state: absent
path: /usr/local/share/pwnagotchi/ path: /usr/local/src/pwnagotchi
state: directory
- name: create /usr/local/share/pwnagotchi/ folder
#- name: Install go-1.21 file:
# unarchive: path: /usr/local/share/pwnagotchi/
# src: https://go.dev/dl/go1.21.3.linux-arm64.tar.gz state: directory
# dest: /usr/local
# remote_src: yes #- name: Install go-1.21
# register: golang # unarchive:
# src: https://go.dev/dl/go1.21.3.linux-arm64.tar.gz
#- name: Update .bashrc for go-1.21 # dest: /usr/local
# blockinfile: # remote_src: yes
# dest: /home/pi/.bashrc # register: golang
# state: present
# block: | #- name: Update .bashrc for go-1.21
# export GOPATH=$HOME/go # blockinfile:
# export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin # dest: /home/pi/.bashrc
# when: golang.changed # state: present
# block: |
#- name: download pwngrid 1.10.4 # export GOPATH=$HOME/go
# git: # export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
# repo: https://github.com/jayofelony/pwngrid.git # when: golang.changed
# dest: /usr/local/src/pwngrid
# register: pwngrid #- name: download pwngrid 1.10.4
# git:
#- name: install pwngrid 1.10.4 # repo: https://github.com/jayofelony/pwngrid.git
# shell: "export GOPATH=$HOME/go && export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin && go mod tidy && make && make install" # dest: /usr/local/src/pwngrid
# args: # register: pwngrid
# executable: /bin/bash
# chdir: /usr/local/src/pwngrid #- name: install pwngrid 1.10.4
# when: pwngrid.changed # shell: "export GOPATH=$HOME/go && export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin && go mod tidy && make && make install"
# args:
#- name: remove pwngrid folder # executable: /bin/bash
# file: # chdir: /usr/local/src/pwngrid
# state: absent # when: pwngrid.changed
# path: /usr/local/src/pwngrid
#- name: remove pwngrid folder
#- name: download bettercap v2.32.1 # file:
# git: # state: absent
# repo: https://github.com/jayofelony/bettercap.git # path: /usr/local/src/pwngrid
# dest: /usr/local/src/bettercap
# register: bettercap #- name: download bettercap v2.32.1
# git:
#- name: Install bettercap v2.32.1 # repo: https://github.com/jayofelony/bettercap.git
# shell: "export GOPATH=$HOME/go && export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin && go mod tidy && make && make install" # dest: /usr/local/src/bettercap
# args: # register: bettercap
# executable: /bin/bash
# chdir: /usr/local/src/bettercap #- name: Install bettercap v2.32.1
# when: bettercap.changed # shell: "export GOPATH=$HOME/go && export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin && go mod tidy && make && make install"
# args:
#- name: remove bettercap folder # executable: /bin/bash
# file: # chdir: /usr/local/src/bettercap
# state: absent # when: bettercap.changed
# path: /usr/local/src/bettercap
#- name: remove bettercap folder
- name: clone bettercap caplets # file:
git: # state: absent
repo: https://github.com/jayofelony/caplets.git # path: /usr/local/src/bettercap
dest: /tmp/caplets
register: capletsgit - name: clone bettercap caplets
git:
- name: install bettercap caplets repo: https://github.com/jayofelony/caplets.git
make: dest: /tmp/caplets
chdir: /tmp/caplets register: capletsgit
target: install
when: capletsgit.changed - name: install bettercap caplets
make:
- name: download and install bettercap ui chdir: /tmp/caplets
unarchive: target: install
src: "{{ packages.bettercap.ui }}" when: capletsgit.changed
dest: /usr/local/share/bettercap/
remote_src: yes - name: download and install bettercap ui
mode: 0755 unarchive:
src: "{{ packages.bettercap.ui }}"
- name: add HDMI powersave to rc.local dest: /usr/local/share/bettercap/
blockinfile: remote_src: yes
path: /etc/rc.local mode: 0755
insertbefore: "exit 0"
block: | - name: add HDMI powersave to rc.local
if ! /opt/vc/bin/tvservice -s | egrep 'HDMI|DVI'; then blockinfile:
/opt/vc/bin/tvservice -o path: /etc/rc.local
fi insertbefore: "exit 0"
block: |
- name: create /etc/pwnagotchi folder if ! /opt/vc/bin/tvservice -s | egrep 'HDMI|DVI'; then
file: /opt/vc/bin/tvservice -o
path: /etc/pwnagotchi fi
state: directory
- name: create /etc/pwnagotchi folder
- name: check if user configuration exists file:
stat: path: /etc/pwnagotchi
path: /etc/pwnagotchi/config.toml state: directory
register: user_config
- name: check if user configuration exists
- name: create /etc/pwnagotchi/config.toml stat:
copy: path: /etc/pwnagotchi/config.toml
dest: /etc/pwnagotchi/config.toml register: user_config
content: |
# Add your configuration overrides on this file any configuration changes done to default.toml will be lost! - name: create /etc/pwnagotchi/config.toml
# Example: copy:
# ui.display.enabled = true dest: /etc/pwnagotchi/config.toml
# ui.display.type = "waveshare_2" content: |
when: not user_config.stat.exists # Add your configuration overrides on this file any configuration changes done to default.toml will be lost!
# Example:
- name: Delete motd # ui.display.enabled = true
file: # ui.display.type = "waveshare_2"
state: absent when: not user_config.stat.exists
path: /etc/motd
- name: Delete motd
- name: Delete motd 10-uname file:
file: state: absent
state: absent path: /etc/motd
path: /etc/update-motd.d/10-uname
- name: Delete motd 10-uname
- name: enable ssh on boot file:
file: state: absent
path: /boot/ssh path: /etc/update-motd.d/10-uname
state: touch
- name: enable ssh on boot
- name: adjust /boot/config.txt file:
lineinfile: path: /boot/ssh
dest: /boot/config.txt state: touch
insertafter: EOF
line: '{{ item }}' - name: adjust /boot/config.txt
with_items: "{{system.boot_options}}" lineinfile:
dest: /boot/config.txt
- name: adjust /etc/modules insertafter: EOF
lineinfile: line: '{{ item }}'
dest: /etc/modules with_items: "{{system.boot_options}}"
insertafter: EOF
line: '{{ item }}' - name: adjust /etc/modules
with_items: "{{system.modules}}" lineinfile:
dest: /etc/modules
- name: change root partition insertafter: EOF
replace: line: '{{ item }}'
dest: /boot/cmdline.txt with_items: "{{system.modules}}"
backup: no
regexp: "root=PARTUUID=[a-zA-Z0-9\\-]+" - name: change root partition
replace: "root=/dev/mmcblk0p2" replace:
dest: /boot/cmdline.txt
- name: configure /boot/cmdline.txt backup: no
lineinfile: regexp: "root=PARTUUID=[a-zA-Z0-9\\-]+"
path: /boot/cmdline.txt replace: "root=/dev/mmcblk0p2"
backrefs: True
state: present - name: configure /boot/cmdline.txt
backup: no lineinfile:
regexp: '(.*)$' path: /boot/cmdline.txt
line: '\1 modules-load=dwc2,g_ether' backrefs: True
state: present
- name: Add pwnlog alias backup: no
lineinfile: regexp: '(.*)$'
dest: /home/pi/.bashrc line: '\1 modules-load=dwc2,g_ether'
line: "\nalias pwnlog='tail -f -n300 /var/log/pwn*.log | sed --unbuffered \"s/,[[:digit:]]\\{3\\}\\]//g\" | cut -d \" \" -f 2-'"
insertafter: EOF - name: Add pwnlog alias
lineinfile:
- name: Add pwnver alias dest: /home/pi/.bashrc
lineinfile: line: "\nalias pwnlog='tail -f -n300 /var/log/pwn*.log | sed --unbuffered \"s/,[[:digit:]]\\{3\\}\\]//g\" | cut -d \" \" -f 2-'"
dest: /home/pi/.bashrc insertafter: EOF
line: "\nalias pwnver='python3 -c \"import pwnagotchi as p; print(p.__version__)\"'"
insertafter: EOF - name: Add pwnver alias
lineinfile:
- name: download old libpcap packages dest: /home/pi/.bashrc
get_url: line: "\nalias pwnver='python3 -c \"import pwnagotchi as p; print(p.__version__)\"'"
url: "https://old.kali.org/kali/pool/main/libp/libpcap/{{ item }}" insertafter: EOF
dest: /usr/local/src/
with_items: "{{ packages.apt.downgrade }}" - name: download old libpcap packages
get_url:
- name: install old libpcap packages url: "https://old.kali.org/kali/pool/main/libp/libpcap/{{ item }}"
apt: dest: /usr/local/src/
force: True with_items: "{{ packages.apt.downgrade }}"
state: present
deb: "/usr/local/src/{{ item }}" - name: install old libpcap packages
with_items: "{{ packages.apt.downgrade }}" apt:
register: libpcap force: True
state: present
- name: remove old libpcap files deb: "/usr/local/src/{{ item }}"
file: with_items: "{{ packages.apt.downgrade }}"
path: "/usr/local/src/{{ item }}" register: libpcap
state: absent
with_items: "{{ packages.apt.downgrade }}" - name: remove old libpcap files
file:
- name: add firmware packages to hold path: "/usr/local/src/{{ item }}"
dpkg_selections: state: absent
name: "{{ item }}" with_items: "{{ packages.apt.downgrade }}"
selection: hold
with_items: "{{ packages.apt.hold }}" - name: add firmware packages to hold
when: libpcap.changed dpkg_selections:
name: "{{ item }}"
- name: disable unnecessary services selection: hold
systemd: with_items: "{{ packages.apt.hold }}"
name: "{{ item }}" when: libpcap.changed
state: stopped
enabled: no - name: disable unnecessary services
with_items: "{{ services.disable }}" systemd:
name: "{{ item }}"
- name: enable services state: stopped
systemd: enabled: no
name: "{{ item }}" with_items: "{{ services.disable }}"
enabled: true
state: stopped - name: enable services
with_items: "{{ services.enable }}" systemd:
register: enabled name: "{{ item }}"
enabled: true
- name: remove unnecessary apt packages state: stopped
apt: with_items: "{{ services.enable }}"
name: "{{ packages.apt.remove }}" register: enabled
state: absent
purge: yes - name: remove unnecessary apt packages
register: removed apt:
name: "{{ packages.apt.remove }}"
- name: clean apt cache state: absent
apt: purge: yes
autoclean: true register: removed
when: removed.changed
- name: clean apt cache
- name: apt clean apt:
shell: "apt-get clean" autoclean: true
args: when: removed.changed
executable: /bin/bash
- name: apt clean
- name: remove /root/go folder shell: "apt-get clean"
file: args:
state: absent executable: /bin/bash
path: /root/go
- name: remove /root/go folder
- name: remove /usr/local/go folder file:
file: state: absent
state: absent path: /root/go
path: /usr/local/go
- name: remove /usr/local/go folder
- name: remove pip cache file:
file: state: absent
state: absent path: /usr/local/go
path: /root/.cache/pip
- name: remove pip cache
- name: remove dependencies that are no longer required file:
apt: state: absent
autoremove: yes path: /root/.cache/pip
when: removed.changed
- name: remove dependencies that are no longer required
handlers: apt:
- name: reload systemd services autoremove: yes
systemd: when: removed.changed
daemon_reload: yes
when: enabled.changed handlers:
- name: reload systemd services
systemd:
daemon_reload: yes
when: enabled.changed