Hello OPNsensers,
I'm (very) curious of other users scripts and shell adaptions
With that I mean: do you tweak your shell, what does your .cshrc.mine look like, did you add some useful code/script to OPNsense?
I could find a BSD forum and ditch it there, but that don't seem right and besides that OPNsense is my only BSD ATM.
So moderators, I hope this is allowed and we can share some shell/scripting code for OPNsense here?, this could have some value for all of us, thanks.
If you decide to join in and add scripts, please, rather add SH code than BASH, I have it installed but most of us don't, thanks.
Let me do the kickoff right away :P
My .cshrch.mine
# $FreeBSD$
#
# .cshrc.mine - csh resource script, read at beginning of execution by each she
ll
#
# see also csh(1), environ(7).
# more examples available at /usr/share/examples/csh/
#
# few aliases I like to have
#alias sum 'cksum /usr/local/share/certs/ca-root-nss.crt | sort | diff sum.txt -'
alias tm tmux attach
alias vim vi
# Tab completion and - correction
if ($?prompt) then
set autocorrect = ambiguous
set complete = enhance
set correct = cmd
endif
# some extra program completions
complete sysctl 'n/*/`sysctl -Na`/'
complete man 'p,*,c,'
# BSD is functional but pretty colorless, let's change that
# Let 'ls' have some color
setenv CLICOLOR yes
# Basic colors
set red="%{\033[1;31m%}"
set green="%{\033[0;32m%}"
set blue="%{\033[1;34m%}"
set yellow="%{\033[1;33m%}"
set magenta="%{\033[1;35m%}"
set cyan="%{\033[1;36m%}"
set white="%{\033[0;37m%}"
set end="%{\033[0m%}"
# Colored prompt
set prompt="${cyan}%n${red}@%m ${white}%~ ${cyan}%%${end} "
# Colored man pages, I dislike the undelining of everything..
setenv LESS_TERMCAP_mb `echotc md; echotc AF 4`
setenv LESS_TERMCAP_md `echotc md; echotc AF 4`
setenv LESS_TERMCAP_me `echotc me`
setenv LESS_TERMCAP_se `echotc me`
setenv LESS_TERMCAP_so `echotc md; echotc AF 1; echotc AB 4`
setenv LESS_TERMCAP_ue `echotc me`
setenv LESS_TERMCAP_us `echotc md; echotc AF 2`
# Unset used colors
unset red green blue yellow magenta cyan white end
My .tmux.conf
set -g default-terminal "screen-256color"
# interval is up to you, but it may use precious cpu time if set to 1
set-option -g status-interval 30
set-option -g status-right-length 60
set-option -g status-left-length 120
set -g status-bg colour237
set -g status-fg colour237
set -g mouse on
set -g status-left '#[fg=blue] #(hostname -s) #[fg=colour41]*#[fg=blue] #(sh bin/tmx temp)C #[fg=colour41]* #[fg=blue]#(sh bin/tmx mem) #[fg=colour41]* #[fg=blue]#(sh bin/tmx sum) '
set -g status-right '#[fg=blue]#(sh bin/tmx avg)#[fg=colour41]* #[fg=blue]%H:%M'
# Attach a running session or create a fresh one
new-session -n $HOST
Script called by tmux, I use it for the statusbar,
#!/bin/sh
set -xe
temp () {
var1=$(sysctl -n dev.cpu.0.temperature | awk '{printf "%3.0f\n",$1}')
var2=$(sysctl -n dev.cpu.1.temperature | awk '{printf "%3.0f\n",$1}')
echo "scale=1; ($var1 + $var2) / 2" | bc
}
mem () {
mem_real=$(sysctl -n hw.realmem)
pagesize=$(sysctl -n hw.pagesize)
inact_count=$(sysctl -n vm.stats.vm.v_inactive_count)
free_count=$(sysctl -n vm.stats.vm.v_free_count)
mem_inact=$(printf "%s\\n" "$inact_count *$pagesize" | bc)
mem_free=$(printf "%s\\n" "$free_count * $pagesize" | bc)
mem_avail=$(printf "%s\\n" "$mem_inact + $mem_free" | bc)
mem_used=$(printf "%s\\n" "$mem_real - $mem_avail" | bc)
printf "%s\\n" "$(("$mem_used * 100 / $mem_real"))"%
exit 0
}
avg () {
sysctl -n vm.loadavg | sed 's/{//g;s/}//g'
}
sum () {
if [ "$(cksum /usr/local/share/certs/ca-root-nss.crt | \
awk '{printf "%-1s %s\n", $1 , $2}')" \
!= "$(awk '{printf "%-1s %s\n", $1 , $2}' ~/sum.txt)" ]; then
echo nss-mismatch
fi
}
if [ "$1" = temp ]; then
temp
elif [ "$1" = mem ]; then
mem
elif [ "$1" = avg ]; then
avg
elif [ "$1" = sum ]; then
sum
else
printf "Usage: sh tmx (temp mem or avg) \\n"
fi
exit 0
That's it, enjoy
Greetings, mark
edit:remove hard enter (CR)
edit2:add function sum to script
Hello all,
Added a function 'sum' to the script which gives a warning 'nss-mismatch' .
It's always usable, but very handy if self-signed certificates are added, your notified by the above warning to add your certificate/s again.
Create 'sum.txt' yourself of course :P
Greetings, mark