diff --git a/files/platon/i2cspeed.sh b/files/platon/i2cspeed.sh new file mode 100755 index 0000000..5ae50b4 --- /dev/null +++ b/files/platon/i2cspeed.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# https://gist.github.com/ribasco/c22ab6b791e681800df47dd0a46c7c3a + +var="$(xxd -ps /sys/class/i2c-adapter/i2c-1/of_node/clock-frequency)" +var=${var//[[:blank:].\}]/} +printf "%d\n" 0x$var diff --git a/files/platon/reboot.sh b/files/platon/reboot.sh new file mode 100755 index 0000000..f05d0c6 --- /dev/null +++ b/files/platon/reboot.sh @@ -0,0 +1,37 @@ +#!/bin/sh +PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games' +echo 'start i2c-foo' +sudo modprobe i2c_dev +sudo modprobe i2c_bcm2708 +echo 'starting log' +tmux new-session -s status -d 'sudo less /var/log/shuttercontrol.log' +cd /home/pi/netz39_rollladensteuerung/raspberry/shuttercontrol +echo 'switch-on.sh' +../switch-on.sh +cd /home/pi +echo 'start shuttercontrol' +tmux new-window -t status:1 'cd /home/pi/netz39_rollladensteuerung/raspberry/shuttercontrol && ./shuttercontrol.sh' +echo 'start watchdog' +tmux new-window -t status:2 'cd /home/pi/netz39_rollladensteuerung/raspberry/doorcontrol && ./door-with-spacestatus.sh' +#tmux new-window -t status:2 'cd /home/pi/netz39_rollladensteuerung/raspberry/door-watchdog && python3 ./door-watchdog.py' + +echo 'start door-sound.sh' +tmux new-window -t status:3 'cd /home/pi/netz39_rollladensteuerung/raspberry/doorcontrol && ./door-sound.sh' +echo 'start ic3-client' +tmux new-window -t status:4 'cd /home/pi/netz39_xmpp_space_control/i3c_client && build/i3c_client --foreground' +echo 'start asterisk abuse check' +tmux new-window -t status:5 'cd /home/pi/netz39_rollladensteuerung/raspberry/asterisk && sudo ./check-abuse.sh' +echo 'start asterisk console' +tmux new-window -t status:6 'sudo asterisk -vvvr' +echo 'start door service' +tmux new-window -t status:7 'cd /home/pi/netz39_rollladensteuerung/raspberry/door-service && python3 door-service.py' +echo 'start mqtt-clock' +tmux new-window -t status:8 'cd /home/pi/mqtt-tools/agents && ./mqtt-clock' + +#echo 'start ampel controller' +# This does not work as intended xD +#tmux new-window -t status:9 'cd /home/pi/netz39_space_notification/raspberry/ledcontrol && ./ledcontrol' + + +#echo 'start shuttercontrol-service (experimental)' +#tmux new-window -t status:9 'cd /home/pi && python3 ./shuttercontrol-service.py' diff --git a/files/platon/sesame-open.sh b/files/platon/sesame-open.sh new file mode 100755 index 0000000..575af40 --- /dev/null +++ b/files/platon/sesame-open.sh @@ -0,0 +1,5 @@ +#/bin/bash + +/home/pi/netz39_rollladensteuerung/raspberry/doorcontrol/door-open.sh +/home/pi/netz39_rollladensteuerung/raspberry/shuttercontrol/doorshutter-open.sh + diff --git a/files/platon/unstuck.sh b/files/platon/unstuck.sh new file mode 100755 index 0000000..c35bc22 --- /dev/null +++ b/files/platon/unstuck.sh @@ -0,0 +1,13 @@ +#!/bin/bash +logger -t unstuck "unstuck $(date)" + +killall tmux +gpio mode 2 output +gpio mode 3 output +gpio write 2 0 +gpio write 3 0 +sudo modprobe -r i2c_dev +sudo modprobe -r i2c_bcm2708 + +sleep 1 +~/reboot.sh diff --git a/platon.yml b/platon.yml index 8ea6ea5..64381d6 100644 --- a/platon.yml +++ b/platon.yml @@ -18,6 +18,8 @@ # Should come from ble-keeper-role # see https://github.com/netz39/ble-keykeeper-role/issues/4 - python3-pip + # Regular packages + - tmux - name: Set MAC address for proper DHCP recognition @@ -56,3 +58,20 @@ name: "{{ gatekeeper_user }}" groups: dialout,audio,plugdev,input,netdev,i2c,gpio append: yes + + - name: Copy management scripts + ansible.builtin.copy: + src: "files/platon/{{ item }}" + dest: "/home/{{ gatekeeper_user }}/{{ item }}" + owner: "{{ gatekeeper_user }}" + group: "{{ gatekeeper_user }}" + mode: "0755" + loop: + - i2cspeed.sh + - reboot.sh + - unstuck.sh + - sesame-open.sh + + # WiringPi needs to be installed, but that library seems to be + # obsolete, so not automating. + # Follow the instructions on http://wiringpi.com/download-and-install/