Skip to content

Commit

Permalink
Init unipi controll os
Browse files Browse the repository at this point in the history
  • Loading branch information
mh-superbox committed Jun 4, 2022
1 parent dc7748c commit f0c0cbd
Show file tree
Hide file tree
Showing 30 changed files with 240 additions and 163 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ git clone git://git.buildroot.net/buildroot

$ cd /buildroot
$ # checkout LTS version
$ git checkout 2021.02.8
$ git checkout 2022.02.2

$ make BR2_EXTERNAL=../rpi-buildroot list-defconfigs
$ make unipi_neuron_rpi3b_defconfig
Expand Down
5 changes: 4 additions & 1 deletion buildroot/Config.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
comment "Base packages"
source "$BR2_EXTERNAL_UNIPI_PATH/package/unipi-control/Config.in"
source "$BR2_EXTERNAL_UNIPI_PATH/package/python-asyncio-mqtt/Config.in"
source "$BR2_EXTERNAL_UNIPI_PATH/package/unipi-python-asyncio-mqtt/Config.in"
source "$BR2_EXTERNAL_UNIPI_PATH/package/unipi-python-paho-mqtt/Config.in"
source "$BR2_EXTERNAL_UNIPI_PATH/package/unipi-python-pymodbus/Config.in"
source "$BR2_EXTERNAL_UNIPI_PATH/package/unipi-python-pyyaml/Config.in"
source "$BR2_EXTERNAL_UNIPI_PATH/package/unipi-kernel/Config.in"
source "$BR2_EXTERNAL_UNIPI_PATH/package/unipi-tools/Config.in"

Expand Down
5 changes: 0 additions & 5 deletions buildroot/board/common/rootfs_overlay/etc/default/telegram

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ check process avahi with pidfile /var/run/avahi-daemon/pid
start program = "/bin/systemctl start avahi-daemon.service" with timeout 60 seconds
stop program = "/bin/systemctl stop avahi-daemon.service"

if failed host 0.0.0.0 port 5353 type udp then exec "/bin/telegram-send-message -s '*[unipi]* Avahi unavailable'"
if failed host 0.0.0.0 port 5353 type udp then restart
if 5 restarts within 5 cycles then timeout
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ check program mosquitto.service with path "/bin/systemctl --quiet is-active mosq
start program = "/bin/systemctl start mosquitto.service" with timeout 60 seconds
stop program = "/bin/systemctl stop mosquitto.service"

if status != 0 then exec "/bin/telegram-send-message -s '*[unipi]* Mosquitto unavailable!'"
if status != 0 then restart
if 5 restarts within 5 cycles then timeout
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ check process sshd with pidfile /var/run/sshd.pid
start program = "/bin/systemctl start ssh" with timeout 60 seconds
stop program = "/bin/systemctl start ssh"

if failed host 0.0.0.0 port 22 with protocol ssh then exec "/bin/telegram-send-message -s '*[unipi]* OpenSSH unavailable'"
if failed host 0.0.0.0 port 22 with protocol ssh then restart
if 5 restarts with 5 cycles then timeout
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ check program owhttpd.service with path "/bin/systemctl --quiet is-active owhttp
start program = "/bin/systemctl start owhttpd.service" with timeout 60 seconds
stop program = "/bin/systemctl stop owhttpd.service"

if status != 0 then exec "/bin/telegram-send-message -s '*[unipi]* 1-Wire Webserver unavailable!'"
if status != 0 then restart
if 5 restarts within 5 cycles then timeout

check program owserver.service with path "/bin/systemctl --quiet is-active owserver.service"
Expand All @@ -13,7 +13,7 @@ check program owserver.service with path "/bin/systemctl --quiet is-active owser
start program = "/bin/systemctl start owserver.service" with timeout 60 seconds
stop program = "/bin/systemctl stop owserver.service"

if status != 0 then exec "/bin/telegram-send-message -s '*[unipi]* 1-Wire Backend Server unavailable!'"
if status != 0 then restart
if 5 restarts within 5 cycles then timeout

check program owfs.service with path "/bin/systemctl --quiet is-active owfs.service"
Expand All @@ -22,5 +22,5 @@ check program owfs.service with path "/bin/systemctl --quiet is-active owfs.serv
start program = "/bin/systemctl start owfs.service" with timeout 60 seconds
stop program = "/bin/systemctl stop owfs.service"

if status != 0 then exec "/bin/telegram-send-message -s '*[unipi]* 1-Wire Filesystem unavailable!'"
if status != 0 then restart
if 5 restarts within 5 cycles then timeout
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ check system $HOST
if swap usage > 20% for 4 cycles then exec "/bin/telegram-send-message -s '*[unipi]* Swap usage greater then 20 %'"

# Test the user part of CPU usage
if cpu usage (user) > 95% for 2 cycles then exec "/bin/telegram-send-message -s '*[unipi]* CPU (User) greater then 95 %'"
if cpu usage (user) > 95% for 2 cycles then alert

# Test the system part of CPU usage
if cpu usage (system) > 80% for 2 cycles then exec "/bin/telegram-send-message -s '*[unipi]* CPU (System) greater then 80 %'"
if cpu usage (system) > 80% for 2 cycles then alert

# Test the i/o wait part of CPU usage
if cpu usage (wait) > 80% for 2 cycles then exec "/bin/telegram-send-message -s '*[unipi]* CPU (Wait) greater then 80 %'"
if cpu usage (wait) > 80% for 2 cycles then alert

# Test CPU usage including user, system and wait. Note that
# multi-core systems can generate 100 % per core
# so total CPU usage can be more than 100 %
if cpu usage > 200% for 4 cycles then exec "/bin/telegram-send-message -s '*[unipi]* CPU greater then 200 %'"
if cpu usage > 200% for 4 cycles then alert

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ check program unipitcp.service with path "/bin/systemctl --quiet is-active unipi
start program = "/bin/systemctl start unipitcp.service" with timeout 60 seconds
stop program = "/bin/systemctl stop unipitcp.service"

if status != 0 then exec "/bin/telegram-send-message -s '*[unipi]* Unipi TCP unavailable!'"
if status != 0 then restart
if 5 restarts within 5 cycles then timeout

check program unipicheck.service with path "/bin/systemctl --quiet is-active unipicheck.service"
Expand All @@ -13,7 +13,7 @@ check program unipicheck.service with path "/bin/systemctl --quiet is-active uni
start program = "/bin/systemctl start unipicheck.service" with timeout 60 seconds
stop program = "/bin/systemctl stop unipicheck.service"

if status != 0 then exec "/bin/telegram-send-message -s '*[unipi]* Unipi Check unavailable!'"
if status != 0 then restart
if 5 restarts within 5 cycles then timeout

check program unipi-control.service with path "/bin/systemctl --quiet is-active unipi-control.service"
Expand All @@ -22,5 +22,5 @@ check program unipi-control.service with path "/bin/systemctl --quiet is-active
start program = "/bin/systemctl start unipi-control.service" with timeout 60 seconds
stop program = "/bin/systemctl stop unipi-control.service"

if status != 0 then exec "/bin/telegram-send-message -s '*[unipi]* Unipi Control unavailable!'"
if status != 0 then restart
if 5 restarts within 5 cycles then timeout

This file was deleted.

14 changes: 7 additions & 7 deletions buildroot/board/common/rootfs_overlay/etc/motd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_ _ _ _ ___ _ _
| | | | _ _ (_) _ __ (_) / __| ___ _ _ | |_ _ _ ___ | |
| |_| || ' \ | || '_ \| | | (__ / _ \| ' \| _|| '_|/ _ \| |
\___/ |_||_||_|| .__/|_| \___|\___/|_||_|\__||_| \___/|_|
|_|
-------------------------------------------------------------

_ _ _ _
| | | |_ __ (_)_ __ (_)
| | | | '_ \| | '_ \| |
| |_| | | | | | |_) | |
\___/|_| |_|_| .__/|_|
|_| Controller
--------------------------------------------------------
182 changes: 115 additions & 67 deletions buildroot/board/common/rootfs_overlay/etc/zshrc
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
################################################################################
###############################################################################
# BASIC

setopt autocd
setopt autopushd
setopt extended_glob
setopt long_list_jobs
setopt noflowcontrol
setopt interactive
setopt longlistjobs
setopt monitor
setopt nobeep
setopt notify
setopt no_hup
setopt auto_pushd
setopt pushd_ignore_dups
setopt no_glob_dots
setopt no_sh_word_split
setopt nohup
setopt noglobdots
setopt noshwordsplit
setopt pushdignoredups
setopt rmstarwait
setopt unset
setopt rm_star_wait

setopt zle

################################################################################
# SYNTAX HIGHLIGHTING
# PLUGINS

source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-history-substring-search/zsh-history-substring-search.zsh


################################################################################
###############################################################################
# PROMPT

setopt prompt_subst
Expand All @@ -32,11 +36,10 @@ else
p_user='%F{green}%n%f'
fi

RPROMPT='%B%K{blue}${VIRTUAL_ENV:+${VIRTUAL_ENV##*/}}%k%b'
PS1='%B${p_user}@%m:%~%b%F{yellow} %# %f'

RPROMPT="%B%K{blue}${VIRTUAL_ENV:+${VIRTUAL_ENV##*/}}%k%b"
PS1="%B${p_user}@%m:%~%b%F{yellow} %# %f"

###############################################################################
##############################################################################
# KEYS

# The best way to find out what a key or key combination sends for your terminal,
Expand All @@ -46,91 +49,136 @@ PS1='%B${p_user}@%m:%~%b%F{yellow} %# %f'
bindkey -e

# [PageUp] - Up a line of history
bindkey '^[[A' up-line-or-history
bindkey "^[[A" up-line-or-history

# [PageDown] - Down a line of history
bindkey '^[[B' down-line-or-history
bindkey "^[[B" down-line-or-history

# Start typing + [Up-Arrow] - Search substring in history
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down

# [Home] - Go to beginning of line
bindkey '^[[H' beginning-of-line
bindkey "^[[H" beginning-of-line

# [End] - Go to end of line
bindkey '^[[F' end-of-line
bindkey "^[[F" end-of-line

# [Shift-Tab] - move through the completion menu backwards
bindkey '^[[Z' reverse-menu-complete
bindkey "^[[Z" reverse-menu-complete

# [Delete] - delete forward
bindkey '^[[3~' delete-char
bindkey '^[3;5~' delete-char
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char

# [Ctrl-Delete] - delete whole forward-word
bindkey '^[[3;5~' kill-word
bindkey "^[[3;5~" kill-word

# [Ctrl-Right] - move forward one word
bindkey '^[[1;5C' forward-word
bindkey "^[[1;5C" forward-word

# [Ctrl-Left] - move backward one word
bindkey '^[[1;5D' backward-word
bindkey "^[[1;5D" backward-word


###############################################################################
# HISTORY

setopt append_history
setopt share_history
setopt extended_history
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt appendhistory
setopt sharehistory
setopt extendedhistory
setopt histexpiredupsfirst
setopt histignoredups
setopt histignorespace
setopt histverify
setopt incappendhistory

HISTFILE=~/.zsh_history
HISTSIZE=2000
SAVEHIST=1000

HISTSIZE=200000
SAVEHIST=100000

################################################################################
###############################################################################
# ALIAS

alias chmod='chmod -c'
alias chown='chown -c'
alias chmod="chmod -c"
alias chown="chown -c"

alias history='history -i'
alias history="history -i"

alias rezsh='. /etc/zshrc'
alias ls='ls --color=auto'
alias la='ls -la'
alias ll='ls -lh'
alias lh='ls -lhA'
alias l='ls -lh'
alias ls="ls --color=auto"
alias la="ls -la"
alias ll="ls -lh"
alias l="ls -lh"
alias lh="ls -lhA"
alias lr="ls -lctr"
alias lhr="ls -lhctr"

alias rezsh=". /etc/zshrc"

################################################################################
###############################################################################
# COLORS IN LESS

export LESS_TERMCAP_mb=$'\e[1;33m'
export LESS_TERMCAP_md=$'\e[1;33m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[1;44;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;32m'

eval $(dircolors -b)
export ZLSCOLORS="${LS_COLORS}"

###############################################################################
# COMPLETION

setopt auto_cd
setopt complete_aliases
setopt complete_in_word
setopt hash_list_all
setopt alwaystoend
setopt autonamedirs
setopt automenu
setopt autolist
setopt completealiases
setopt completeinword
setopt hashlistall
setopt listpacked

autoload -Uz compinit
compinit

zstyle ':completion:*' menu select
zstyle ':completion:*' rehash true
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh_cache

zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
/usr/local/bin \
/usr/sbin \
/usr/bin \
/sbin \
/bin

# Zsh spelling correction options
setopt correct
setopt dvorak
zstyle ":completion:*" menu select
zstyle ":completion:*" rehash true
zstyle ":completion:*" use-cache on
zstyle ":completion:*" cache-path ~/.zsh_cache

export CLICOLOR=1
zstyle ":completion:*" list-colors ${(s.:.)LS_COLORS}
zstyle ":completion:*:aliases" list-colors "=*=1;36;5;142"
zstyle ":completion:*:options" list-colors "=^(-- *)=33;5;142"

zstyle ":completion:*:*:kill:*" menu yes select
zstyle ":completion:*:*:kill:*:processes" list-colors "=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34;5;142=0=01"

zstyle ":completion:*:*:cp:*" file-sort modification reverse
zstyle ":completion:*:*:mv:*" file-sort modification reverse

zstyle ":completion:*:man:*" menu yes select

zstyle ":completion:*:sudo:*" menu yes select
zstyle ":completion:*:sudo:*" command-path /usr/local/sbin \
/usr/local/bin \
/usr/sbin \
/usr/bin \
/sbin \
/bin

if [ -r ~/.ssh/config ]; then
zstyle ":completion:*:(scp|ssh):*" hosts ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*}
fi

zstyle ":completion:*:(scp|ssh):*" hosts on

###############################################################################
# LANGUAGE

export LANG="en_GB.UTF-8"
export LC_ALL="en_GB.UTF-8"
export LC_CTYPE="en_GB.UTF-8"

0 comments on commit f0c0cbd

Please sign in to comment.