diff --git a/blini.py b/bin/blini.py similarity index 66% rename from blini.py rename to bin/blini.py index 567ed09..8f52b77 100755 --- a/blini.py +++ b/bin/blini.py @@ -7,13 +7,27 @@ import blinkt blinkt.set_clear_on_exit() waitstate = 0.75 -for i in range(3): - blinkt.set_pixel(2,255,150,0) +from_led = 0 +to_led=6 + +def pixel_on(): + for i in range(from_led,to_led): + blinkt.set_pixel(i,255,0,0) blinkt.show() - time.sleep(waitstate) - blinkt.set_pixel(2,0,0,0) + +def pixel_off(): + for i in range(from_led,to_led): + blinkt.set_pixel(i,0,0,0) blinkt.show() + +def blink_once(): + pixel_on() + time.sleep(waitstate) + pixel_off() time.sleep(waitstate) + +for i in range(3): + blink_once() #while True: # pixels = random.sample(range(blinkt.NUM_PIXELS), random.randint(1, 5)) # for i in range(blinkt.NUM_PIXELS): diff --git a/bin/showtemp b/bin/showtemp new file mode 100755 index 0000000..8458865 --- /dev/null +++ b/bin/showtemp @@ -0,0 +1,10 @@ +cpu=$( ${gpu}" +echo "CPU => $((cpu/1000))'C" diff --git a/bin/updatesys b/bin/updatesys new file mode 100755 index 0000000..3c0c8be --- /dev/null +++ b/bin/updatesys @@ -0,0 +1,21 @@ +# System-Updater CC-BY Olli Graf +# V 1.6 2019 + +VERSION="1.7" +TMPFILE="/tmp/updater.txt" + +echo "Updater V ${VERSION}" +sudo rm -f ${TMPFILE} +sudo apt-get update +sudo apt-get dist-upgrade -y --allow-unauthenticated |tee ${TMPFILE} +sudo snap refresh +sudo apt-get autoremove -y +if grep -q linux-header ${TMPFILE}; then + echo "reboot nötig" + read -n1 -p "Neustart? (J/N)" auswahl +if [ "${auswahl}" == "j" ]; then + echo "System wird gestartet." + sudo reboot +fi + +fi diff --git a/hosts b/hosts index 7ea8d97..f288a00 100644 --- a/hosts +++ b/hosts @@ -2,13 +2,16 @@ pis: hosts: brandine: clancy: -# martin: + martin: quimby: kirk: willie: hans: + pye: + julius: + carl: cleatus: - barney: +# barney: vars: ansible_python_interpreter: /usr/bin/python3 ansible_connection: ssh @@ -19,7 +22,10 @@ pis: ansible_ssh_private_key_file: ~/.ssh/id_rsa blini: hosts: - quimby + quimby: + willie: + kirk: + brandine: vars: ansible_python_interpreter: /usr/bin/python3 ansible_connection: ssh diff --git a/roles/blini/tasks/main.yml b/roles/blini/tasks/main.yml index 8c5b44f..389e174 100644 --- a/roles/blini/tasks/main.yml +++ b/roles/blini/tasks/main.yml @@ -1,4 +1,17 @@ -- name: Blini Test +- name: copy blini.py + ansible.builtin.copy: + src: bin/blini.py + dest: bin/blini.py + owner: pi + group: pi + mode: '0744' +- name: adding pi to gpio group + become: true + user: + name: pi + groups: gpio + +- name: Blini Run become_user: pi command: ~/bin/blini.py diff --git a/roles/initpi/tasks/main.yml b/roles/initpi/tasks/main.yml index 9b8bcd7..5694274 100644 --- a/roles/initpi/tasks/main.yml +++ b/roles/initpi/tasks/main.yml @@ -1,3 +1,21 @@ +- name: create bin dir + file: + path: ~/bin + state: directory + +- name: copy scripts + copy: + src: bin/{{ item }} + dest: /home/pi/bin + owner: pi + group: pi + mode: '0744' + with_items: + - blini.py + - updatesys + - showtemp + + - name: PI Update become: true apt: @@ -12,9 +30,11 @@ - cowsay - docker.io - git + - locate + - nfs-kernel-server update_cache: yes cache_valid_time: 86400 - autoremove: yes +# autoremove: yes - name: Permission für Docker become: true file: path=/var/run/docker.sock mode=0660