/etc/profile: Unterschied zwischen den Versionen

Aus Freifunk Halle
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „== LEDE /etc/profile == Die originale /etc/profile als Referenz: <pre> #!/bin/sh [ -f /etc/banner ] && cat /etc/banner [ -e /tmp/.failsafe ] && cat /etc/banne…“)
 
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
== LEDE /etc/profile ==
== LEDE /etc/profile ==
Die originale /etc/profile als Referenz:
Die originale /etc/profile als Referenz:
<pre>
<pre>
Zeile 14: Zeile 13:
export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
export HOME=${HOME:-/root}
export HOME=${HOME:-/root}
#export PS1='\u@\h:\w\$ ' # custom ps1 at the bottom
export PS1='\u@\h:\w\$ ' # custom ps1 at the bottom


[ "$TERM" = "xterm" ] && export PS1='\[\e]0;\u@\h: \w\a\]'$PS1
[ "$TERM" = "xterm" ] && export PS1='\[\e]0;\u@\h: \w\a\]'$PS1
Zeile 60: Zeile 59:
Statistiken und Farbe:
Statistiken und Farbe:
<pre>
<pre>
## Prompt
## buntes Prompt
#export PS1='\u@\h:\w\$ '
#export PS1='\u@\h:\w\$ ' # Standard-Prompt abschalten
export PS1="\[\033[01;31m\]\u\[\033[01;34m\]@\[\033[01;31m\]\h\[\033[01;34m\]\w\#\[\033[00m\] "
export PS1="\[\033[01;31m\]\u\[\033[01;34m\]@\[\033[01;31m\]\h\[\033[01;34m\]\w\#\[\033[00m\] "


## Variablen und Aliase
## Variablen und Aliase
pool=250
alias l='ls -lha'
alias l='ls -lha'
alias df='df -h'
alias df='df -h'
Zeile 78: Zeile 76:
alias clients2='iwinfo wlan0 assoclist'
alias clients2='iwinfo wlan0 assoclist'
alias clients5='iwinfo wlan1 assoclist'
alias clients5='iwinfo wlan1 assoclist'
 
pool=250
## Statusmeldung
alias status='available=$(($pool - $(batleases))); echo "$(uname -n).ffhal $(uptime)"; echo "bekannte WiFi-Clients: $(bekannt), derzeit geleased: $(batleases), direkt verbunden: $(direkt), remote bekannt: $(remote), verfügbare Adressen: $available"'
echo ""; echo "$(status)"; echo ""
 
## Summen
wanrx=$(cat /sys/devices/virtual/net/eth0.2/statistics/rx_bytes)
wanrx=$(cat /sys/devices/virtual/net/eth0.2/statistics/rx_bytes)
wifirx=$(cat /sys/devices/virtual/net/br-batman/statistics/rx_bytes)
wifirx=$(cat /sys/devices/virtual/net/br-batman/statistics/rx_bytes)
wantx=$(cat /sys/devices/virtual/net/eth0.2/statistics/tx_bytes)
wantx=$(cat /sys/devices/virtual/net/eth0.2/statistics/tx_bytes)
wifitx=$(cat /sys/devices/virtual/net/br-batman/statistics/tx_bytes)
wifitx=$(cat /sys/devices/virtual/net/br-batman/statistics/tx_bytes)


echo "Insgesamt "$(($wanrx / 1000000000))" GBytes empfangen, davon "$(($wifitx / 1000000000))" GBytes fürs WLAN."
## Statusmeldung
echo "Insgesamt "$(($wantx / 1000000000))" GBytes gesendet, davon "$(($wifirx / 1000000000))" GBytes fürs WLAN."
alias status='available=$(($pool - $(batleases))); echo "$(uname -n).ffhal $(uptime)"; echo "bekannte WiFi-Clients: $(bekannt), derzeit geleased: $(batleases), direkt verbunden: $(direkt), remote bekannt: $(remote), verfügbare Adressen: $available"; echo ""; echo "Insgesamt "$(($wanrx / 1000000000))" GBytes empfangen, davon "$(($wifitx / 1000000000))" GBytes fürs WLAN."; echo "Insgesamt "$(($wantx / 1000000000))" GBytes gesendet, davon "$(($wifirx / 1000000000))" GBytes fürs WLAN."; echo ""'
echo ""
echo ""; echo "$(status)"; echo ""
</pre>
</pre>


Beispiel:
Beispiel:
<pre>
<pre>
root@huygens~# . /etc/profile  
root@huygens~# . /etc/profile  

Version vom 3. November 2017, 12:33 Uhr

LEDE /etc/profile

Die originale /etc/profile als Referenz:

#!/bin/sh
[ -f /etc/banner ] && cat /etc/banner
[ -e /tmp/.failsafe ] && cat /etc/banner.failsafe
fgrep -sq '/ overlay ro,' /proc/mounts && {
	echo 'Your JFFS2-partition seems full and overlayfs is mounted read-only.'
	echo 'Please try to remove files from /overlay/upper/... and reboot!'
}

export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
export HOME=${HOME:-/root}
export PS1='\u@\h:\w\$ ' # custom ps1 at the bottom

[ "$TERM" = "xterm" ] && export PS1='\[\e]0;\u@\h: \w\a\]'$PS1

[ -x /bin/more ] || alias more=less
[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi

alias ll='ls -alF --color=auto'

[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc

[ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; }
[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }

[ -n "$FAILSAFE" ] || {
	for FILE in /etc/profile.d/*.sh; do
		[ -e "$FILE" ] && . "$FILE"
	done
	unset FILE
}

if ( grep -qs '^root::' /etc/shadow && \
     [ -z "$FAILSAFE" ] )
then
cat << EOF
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
EOF
fi

service() {
	[ -f "/etc/init.d/$1" ] || {
		echo "service "'"'"$1"'"'" not found, the following services are available:"
		ls "/etc/init.d"
		return 1
	}
	/etc/init.d/$@
}

Anpassungen

Statistiken und Farbe:

## buntes Prompt
#export PS1='\u@\h:\w\$ ' # Standard-Prompt abschalten
export PS1="\[\033[01;31m\]\u\[\033[01;34m\]@\[\033[01;31m\]\h\[\033[01;34m\]\w\#\[\033[00m\] "

## Variablen und Aliase
alias l='ls -lha'
alias df='df -h'
alias free='free -m'
alias ips='ip a| grep inet| sort'
alias arps='arp| sort -n'
alias leases='cat /tmp/dhcp.leases'
alias batleases='cat /tmp/dhcp.leases| grep "6\."| wc -l'
alias bekannt='arp| grep br-batman| wc -l'
alias direkt='batctl tl| grep  W| wc -l'
alias remote='batctl tg| grep  W| wc -l'
alias clients2='iwinfo wlan0 assoclist'
alias clients5='iwinfo wlan1 assoclist'
pool=250
wanrx=$(cat /sys/devices/virtual/net/eth0.2/statistics/rx_bytes)
wifirx=$(cat /sys/devices/virtual/net/br-batman/statistics/rx_bytes)
wantx=$(cat /sys/devices/virtual/net/eth0.2/statistics/tx_bytes)
wifitx=$(cat /sys/devices/virtual/net/br-batman/statistics/tx_bytes)

## Statusmeldung
alias status='available=$(($pool - $(batleases))); echo "$(uname -n).ffhal $(uptime)"; echo "bekannte WiFi-Clients: $(bekannt), derzeit geleased: $(batleases), direkt verbunden: $(direkt), remote bekannt: $(remote), verfügbare Adressen: $available"; echo ""; echo "Insgesamt "$(($wanrx / 1000000000))" GBytes empfangen, davon "$(($wifitx / 1000000000))" GBytes fürs WLAN."; echo "Insgesamt "$(($wantx / 1000000000))" GBytes gesendet, davon "$(($wifirx / 1000000000))" GBytes fürs WLAN."; echo ""'
echo ""; echo "$(status)"; echo ""

Beispiel:

root@huygens~# . /etc/profile 
     _________
    /        /\      _    ___ ___  ___
   /  LE    /  \    | |  | __|   \| __|
  /    DE  /    \   | |__| _|| |) | _|
 /________/  LE  \  |____|___|___/|___|                      lede-project.org
 \        \   DE /
  \    LE  \    /  -----------------------------------------------------------
   \  DE    \  /    Reboot (SNAPSHOT, r3245+3-06bb0a8)
    \________\/    -----------------------------------------------------------


huygens.ffhal  11:52:41 up 24 days,  4:27,  load average: 1.79, 1.15, 0.59
bekannte WiFi-Clients: 75, derzeit geleased: 14, direkt verbunden: 0, remote bekannt: 2, verfügbare Adressen: 236

Insgesamt 272 GBytes empfangen, davon 148 GBytes fürs WLAN.
Insgesamt 41 GBytes gesendet, davon 11 GBytes fürs WLAN.

Erklärung:

1. Zeile: Hostname, Uptime, Load

2. Zeile: Adressen in der arp-Tabelle, Leases, batctl local, batctl remote, Differenz DHCP-Pool - Leases

3. Zeile: total WAN RX, total WIFI TX

4. Zeile: total WAN TX, total WIFI RX