/etc/profile
Zur Navigation springen
Zur Suche springen
LEDE /etc/profile
Diese Datei wird ausgeführt, wenn sich root am Terminal anmeldet.
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
Buntes Prompt, Aliase und Variablen um ein paar Statistiken zu berechnen und anzuzeigen:
## 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 "$(status)"; echo ""
So sieht es aus:
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: Der Name des Knotens, seine Laufzeit und Last
2. Zeile: BATMAN-Einträge in der arp-Tabelle, BATMAN-IP-Leases, batctl local (Clients am Knoten), batctl remote (Clients an Nachbarknoten), Differenz DHCP-Pool - Leases
3. Zeile: Gesamte empfangene Datenmenge am WAN (Internetanschluss), davon soviel an das BATMAN (Freifunk) weitergeleitet
4. Zeile: Gesamte gesendete Datenmenge und davon der Anteil vom Freifunk