Compare commits

...

13 Commits

Author SHA1 Message Date
pgrondek
750dc27d46 Network 2020-11-29 01:12:15 +01:00
pgrondek
b8e7b41ad1 DNS/DHCP 2020-10-16 00:02:46 +02:00
pgrondek
756f50f416 Add Octoprint-WiFiStatus plugin 2020-10-12 18:43:11 +02:00
pgrondek
9925b775f5 Update octoprint plugin url 2020-10-02 23:39:47 +02:00
pgrondek
f06d6831e4 Update script for network restarts 2020-09-11 08:18:57 +02:00
pgrondek
83c561fc1d Add Procrastinator plugin for octoprint 2020-08-23 14:53:23 +02:00
pgrondek
33759d96f4 Update octoprint service 2020-08-09 16:05:20 +02:00
pgrondek
0592034d1e Update octoprint script 2020-08-09 14:58:47 +02:00
pgrondek
0df5ccd0f0 Add Octoprint influxdb plugin 2020-07-25 11:04:15 +02:00
pgrondek
e8c3911b47 Update router script 2020-07-24 02:08:04 +02:00
pgrondek
f1303b103c Update router script 2020-07-03 09:27:38 +02:00
pgrondek
d92b89215e Add more libs to dwm for window swallowing 2020-07-01 13:39:41 +02:00
pgrondek
9beb10a985 [WIP] auto install desktop environment 2020-07-01 13:39:41 +02:00
17 changed files with 345 additions and 15 deletions

4
localhost.yml Normal file
View File

@ -0,0 +1,4 @@
---
- hosts: localhost
roles:
- network

6
prusa.yml Normal file
View File

@ -0,0 +1,6 @@
---
- hosts: prusa.lan
roles:
# - ssh
- octoprint
# - ubuntu

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

View File

@ -0,0 +1,7 @@
[Desktop Entry]
Encoding=UTF-8
Name=Dwm
Comment=Dynamic window manager
Exec=dwm
Icon=dwm
Type=XSession

View File

@ -0,0 +1,41 @@
---
- name: install required packages
apt:
update_cache: yes
pkg:
- git
- make
- libx11-dev
- libxft-dev
- libxinerama-dev
- libxcb-res0-dev
- libx11-xcb-dev
- name: checkout
shell:
cmd: |
mkdir -p ~/src
cd ~/src
git clone {{ dwm-repo }}
- name: build dwm
make:
chdir: ~/src/dwm
- name: copy xsession
become: yes
copy:
src: usr/share/xsessions/dwm.desktop
dest: /usr/share/xsessions/dwm.desktop
- name: copy icon
become: yes
copy:
src: usr/share/icons/dwm.png
dest: /usr/share/icons/dwm.png
- name: install dwm
become: yes
make:
chdir: ~/src/dwm
target: install

View File

@ -0,0 +1,4 @@
---
- import_tasks: setup.yml
- import_tasks: dwm.yml

View File

@ -0,0 +1,9 @@
---
- block:
become: yes
- name: install git and make
apt:
update_cache: yes
pkg:
- git
- make

View File

@ -0,0 +1,3 @@
---
dwm-repo: https://github.com/pgrondek/dwm.git
st-repo: https://github.com/pgrondek/stterm.git

View File

@ -0,0 +1,12 @@
---
- name: create build directory
file:
path: build/dhcp
state: directory
- name: Create dhcpd.conf
template:
src: etc/dhcpd/dhcpd.conf.j2
dest: build/dhcp/dhcpd.conf
vars:
network: "{{ lan }}"

View File

@ -0,0 +1,14 @@
---
- name: create build directory
file:
path: build/dns
state: directory
- name: Create db.lan
# become: yes
template:
src: etc/bind/db.lan.j2
dest: build/dns/db.lan
vars:
network: "{{ lan }}"
serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02"

View File

@ -0,0 +1,4 @@
---
- import_tasks: dns-file.yml
- import_tasks: dhcp-file.yml

View File

@ -0,0 +1,17 @@
$TTL 86400
$ORIGIN {{ network.network_name }}.
@ IN SOA {{ network.network_name }}. dns.{{ network.network_name }}. (
{{ serial }};
604800;
86400;
2419200;
86400;
)
@ IN NS dns.lan.
DNS IN A {{ network.network_prefix }}.100
{% for host in network.hosts %}
{{ host.name }} IN A {{ network.network_prefix }}.{{ host.ip }}
{% endfor %}

View File

@ -0,0 +1,20 @@
ddns-update-style none;
authorative;
subnet {{ network.address }} netmask {{ network.mask }} {
option domain-name-servers {{ network.dns }};
option domain-name "{{ network.network_name }}";
option routers {{ network.gateway }};
default-lease-time 86400;
max-lease-time 86400;
{% if network.range_start is defined %}
range {{ network.range_start }} {{ network.range_end }};
{% endif %}
{% for host in network.hosts %}
host {{ host.name }} { hardware ethernet {{ host.mac }}; fixed-address {{ network.network_prefix }}.{{ host.ip }}; }
{% if host.mac2 is defined %}
host {{ host.name }}_2 { hardware ethernet {{ host.mac2 }}; fixed-address {{ network.network_prefix }}.{{ host.ip }}; }
{% endif %}
{% endfor %}
}

144
roles/network/vars/main.yml Normal file
View File

@ -0,0 +1,144 @@
---
lan:
network_prefix: 192.168.50
network_name: lan
address: 192.168.50.0
mask: 255.255.255.0
gateway: 192.168.50.2
dns: 192.168.50.100
range_start: 192.168.50.200
range_end: 192.168.50.250
hosts:
- name: router
ip: 2
mac: 2c:b0:5d:4a:72:62
- name: bender
ip: 3
mac: e0:3f:49:6f:03:c2
- name: prusa-new
ip: 4
mac: b8:27:eb:96:f3:3f
mac2: b8:27:eb:c3:a6:6a
- name: home-assistant
ip: 5
mac: dc:a6:32:8b:7b:ab
mac2: 6a:1b:c8:63:58:7a
- name: iron-man
ip: 7
mac: dc:a6:32:03:6d:fa
- name: prusa
ip: 8
mac: b8:27:eb:ff:2a:86
- name: farnsworth
ip: 21
mac: e0:3f:49:83:e8:dd
- name: ipad
ip: 46
mac: b8:63:4d:b6:4c:bc
- name: android-sgs9
ip: 47
mac: 24:18:1d:bc:fe:4f
- name: node-01
ip: 101
mac: dc:a6:32:03:6d:fa
- name: node-02
ip: 102
mac: dc:a6:32:3c:0f:ff
- name: node-03
ip: 103
mac: dc:a6:32:3c:1a:ec
iot:
network: 192.168.60
hosts:
- name: smartthings
ip: 2
mac: d0:52:a8:a3:65:95
- name: hue-light
ip: 3
mac: 00:17:88:27:38:8a
- name: zhimi-airpurifier-m1_miio61353463
ip: 5
mac: 34:ce:00:a4:f6:75
- name: zhimi-airpurifier-mb3_mibt952D
ip: 6
mac: 50:ec:50:85:95:2d
- name: roborock
ip: 7
mac: 50:ec:50:0a:c3:94
- name: soundbar
ip: 8
mac: 10:ce:a9:0f:25:08
- name: google-home-bathroom
ip: 10
mac: f4:f5:d8:dd:10:d0
- name: google-home
ip: 11
mac: 20:df:b9:a0:d2:cd
- name: google-home
ip: 12
mac: 20:df:b9:9b:a2:3b
- name: gree-ac
ip: 13
mac: f4:91:1e:47:e3:bd
- name: router-power-outlet
ip: 14
mac: cc:32:e5:69:7a:da
- name: tv
ip: 15
mac: c0:48:e6:1f:ca:a7
- name: soundbar
ip: 16
mac: cc:6e:a4:2a:06:4e
- name: camera-livingroom
ip: 20
mac: 78:11:dc:7b:4d:04
- name: camera-kitchen
ip: 21
mac: 34:ce:00:b2:62:3c
- name: openhab
ip: 100
mac: b8:27:eb:96:f3:3f
guest:
network: 192.168.70
equipment:
network: 192.168.80
hosts:
- name: nvidia-shield
ip: 10
# ip: 11
mac: 00:04:4b:cd:a6:5b
mac2: 00:04:4b:cd:a6:59
- name: kindle
ip: 11
mac: 68:54:FD:BB:06:61
- name: printer
ip: 17
mac: 38:9d:92:d0:6d:8e
- name: wii
ip: 21
mac: 00:1e:35:e7:b3:a0
- name: xbox
ip: 22
mac: 7c:ed:8d:0f:c6:63
- name: ps3
ip: 23
mac: 00:1d:0d:c2:07:b0
- name: ps-vita
ip: 34
mac: 00:d9:d1:4f:8f:91
- name: ps4
ip: 25
mac: 00:d9:d1:76:7b:c5
- name: nintendo-switch
ip: 26
mac: 64:b5:c6:6f:ff:a8
management:
network: 192.168.1
hosts:
- name: router
ip: 1
- name: switch
ip: 2
- name: access-point
ip: 3

View File

@ -6,7 +6,7 @@ After=network.target
User=octoprint
Group=octoprint
Restart=always
ExecStart=/home/octoprint/bin/octoprint serve
ExecStart=/home/octoprint/.local/bin/octoprint
Type=simple
[Install]

View File

@ -19,13 +19,30 @@
shell:
chdir: /home/octoprint
cmd: |
virtualenv system-site-packages .
virtualenv --system-site-packages .
source bin/activate
pip install pip --upgrade
pip install octoprint
args:
executable: /bin/bash
- name: enable system wide packages
file:
path: /home/octoprint/lib/python2.7/no-global-site-packages.txt
state: absent
- name: Create symbolic link for PIL package
file:
src: /usr/lib/python2.7/dist-packages/PIL
dest: /home/octoprint/lib/python2.7/site-packages/PIL
state: link
- name: Create symbolic link for pillow package
file:
src: /usr/lib/python2.7/dist-packages/Pillow-5.1.0.egg-info
dest: /home/octoprint/lib/python2.7/site-packages/Pillow-5.1.0.egg-info
state: link
- name: install plugins
become_user: octoprint
pip:
@ -35,8 +52,12 @@
- https://github.com/jneilliii/OctoPrint-PrusaSlicerThumbnails/archive/master.zip
- https://github.com/juniorRubyist/OctoPrint-OctoFlat/archive/master.zip
- https://github.com/kanocz/octopi_eta_override/archive/master.zip
- https://github.com/malnvenshorn/OctoPrint-FilamentManager/archive/master.zip
- https://github.com/OllisGit/OctoPrint-FilamentManager/releases/latest/download/master.zip
- https://github.com/OllisGit/OctoPrint-DeleteAfterPrint/releases/latest/download/master.zip
- https://github.com/OllisGit/OctoPrint-PrintJobHistory/releases/latest/download/master.zip
# - https://github.com/OllisGit/OctoPrint-PrintJobHistory/releases/latest/download/master.zip
- https://github.com/paukstelis/OctoPrint-Cancelobject/archive/master.zip
- https://github.com/Renaud11232/OctoPrint-Resource-Monitor/archive/master.zip
- https://github.com/agrif/OctoPrint-InfluxDB/archive/master.zip
- https://github.com/juergenpabel/OctoPrint-Procastinator/archive/master.zip
- https://github.com/ManuelMcLure/OctoPrint-WiFiStatus/archive/master.zip

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env vbash
WAN=eth0
HOSTS=(
@ -17,14 +17,25 @@ PING="/bin/ping -c 1 -W ${PING_TIMEOUT} -w ${PING_TIMEOUT}"
RESET_MODEM_SCRIPT="/config/scripts/tplink_smartplug.py"
DEBUG=true
DISABLE_SOFT_RESTART=true
DEBUG_FILE=/var/log/cron-monitor.log
DISABLE_SOFT_RESTART=false
function debug() {
if [[ ${DEBUG} ]]; then
echo $@
echo $@ > ${DEBUG_FILE}
fi
}
function interfaceDown() {
interface=$1
ip link set dev ${interface} down
}
function interfaceUp() {
interface=$1
ip link set dev ${interface} up
}
function soft_restart() {
if [[ ${DISABLE_SOFT_RESTART} ]] ; then
return
@ -34,27 +45,45 @@ function soft_restart() {
release dhcp interface ${WAN}
debug "Disabling ${WAN} interface"
set interfaces ethernet ${WAN} disable
interfaceDown ${WAN}
debug "Waiting ${SOFT_WAIT_TIME}"
sleep ${SOFT_WAIT_TIME}
debug "Enabling ${WAN} interface"
set interfaces ethernet ${WAN} enable
interfaceUp ${WAN}
debug "Renewing DHCP IP lease on ${WAN}"
renew dhcp interface ${WAN}
debug "Waiting for ip lease from dhcp (${DHCP_WAIT_TIME}s)"
sleep ${DHCP_WAIT_TIME}
}
function hard_restart() {
debug "Releasing DHCP IP lease on ${WAN}"
release dhcp interface ${WAN}
debug "Disabling ${WAN} interface"
interfaceDown ${WAN}
debug "Turning off router outlet"
${RESET_MODEM_SCRIPT} -t ${OUTLET_IP} -c off >> /dev/null 2>&1
debug "Waiting ${SOFT_WAIT_TIME}"
sleep ${SOFT_WAIT_TIME}
debug "Turning off router outlet"
debug "Turning on router outlet"
${RESET_MODEM_SCRIPT} -t ${OUTLET_IP} -c on >> /dev/null 2>&1
debug "Waiting for modem to bootup ${MODEM_RESET_WAIT_TIME}"
sleep ${MODEM_RESET_WAIT_TIME}
debug "Enabling ${WAN} interface"
interfaceUp ${WAN}
debug "Renewing DHCP IP lease on ${WAN}"
renew dhcp interface ${WAN}
}
function ping() {
@ -73,14 +102,9 @@ function main() {
ping
soft_restart
debug "Waiting for ip lease from dhcp (${DHCP_WAIT_TIME}s)"
sleep ${DHCP_WAIT_TIME}
ping
hard_restart
debug "Waiting for modem to bootup (${DHCP_WAIT_TIME}s)"
sleep ${MODEM_RESET_WAIT_TIME}
ping
soft_restart
}