[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: .bashrc (stile ubuntu)



Remove me from this list

-----Original Message-----
From: gerlos - gerlosgm@gmail.com
[mailto:debian.ares0.c1fd927f71.gerlosgm#gmail.com@ob.0sg.net] 
Sent: Wednesday, November 12, 2014 5:29 AM
To: debina mailing list italia
Subject: Re: .bashrc (stile ubuntu)


Il giorno 11/nov/2014, alle ore 20:14, Pol Hallen <debitvaio@fuckaround.org>
ha scritto:

> provando causualmente ubuntu, al login viene mostrata una pagina con
riassunte alcune caratteristiche hw/sw e sullo stato del sistema:
> 
> - pacchetti disponibili all'aggiornamento;
> - uptime
> - ip corrente
> etc
> 
> pensavo di modificare .bashrc (o passargli un mio script) facendo a 
> manina la stessa cosa
> 
> ma non esiste qualcosa di già fatto e personalizzabile?

Ecco come si può fare:
https://wiki.debian.org/it/motd#Come_aggiornare_automaticamente_con_script_i
l_proprio_.2Fetc.2Fmotd
http://manpages.ubuntu.com/manpages/quantal/man5/update-motd.5.html
http://www.howtogeek.com/104708/how-to-customize-ubuntus-message-of-the-day/

In pratica si fa tutto personalizzando degli script in /etc/update-motd.d/,
per esempio io ho:
$ ls /etc/update-motd.d/
00-header  10-sysinfo  50-footer  90-updates

Ecco un esempio del mio motd (spero che l?ASCII art sia comprensibile),
richiede che siano installati figlet e update-notifier:
$ sshdc01
Linux dc01 3.14-0.bpo.1-486 #1 Debian 3.14.12-1~bpo70+1 (2014-07-13) i586
     _       ___  _
  __| | ___ / _ \/ |
 / _` |/ __| | | | |
| (_| | (__| |_| | |
 \__,_|\___|\___/|_|


Welcome to Debian GNU/Linux 7.7 (wheezy) (3.14-0.bpo.1-486).

System information as of: Wed Nov 12 11:15:47 CET 2014

System load:	2.18	IP Address:	192.168.0.3
Memory usage:	32.6%	System uptime:	2 days
Usage on /:	11%	Swap usage:	0.0%
Local Users:	1	Processes:	114

Che la forza sia con te!

5 packages can be updated.
4 updates are security updates.

No mail.
Last login: Wed Nov 12 11:06:26 2014 from 192.168.0.22


Ecco i miei script più interessanti che lo generano:

- Il primo mostra la versione del kernel (sì, è un sistema vecchio...), del
sistema operativo, ed l?hostname in ASCII art:
$ cat /etc/update-motd.d/00-header
#!/bin/sh
#### CUT COMMENTS ####
[ -r /etc/lsb-release ] && . /etc/lsb-release

if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
        # Fall back to using the very slow lsb_release utility
        DISTRIB_DESCRIPTION=$(lsb_release -s -d) fi

figlet $(hostname)
printf "\n"

printf "Welcome to %s (%s).\n" "$DISTRIB_DESCRIPTION" "$(uname -r)"
printf "\n?


- Il secondo mostra informazioni sullo stato del sistema:
$ cat /etc/update-motd.d/10-sysinfo
#!/bin/bash
#### CUT COMMENTS ####
date=`date`
load=`cat /proc/loadavg | awk '{print $1}'` root_usage=`df -h / | awk '/\//
{print $(NF-1)}'` memory_usage=`free -m | awk '/Mem:/ { total=$2 }
/buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'`
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", $3/$2*100) }'`
users=`users | wc -w` time=`uptime | grep -ohe 'up .*' | sed 's/,//g' | awk
'{ printf $2" "$3 }'` processes=`ps aux | wc -l` ip=`ifconfig eth0 | grep
"inet addr" | awk -F: '{print $2}' | awk '{print $1}'`

echo "System information as of: $date"
echo
printf "System load:\t%s\tIP Address:\t%s\n" $load $ip printf "Memory
usage:\t%s\tSystem uptime:\t%s\n" $memory_usage "$time"
printf "Usage on /:\t%s\tSwap usage:\t%s\n" $root_usage $swap_usage printf
"Local Users:\t%s\tProcesses:\t%s\n" $users $processes echo


- Il terzo si limita a stampare quello che ho in /etc/motd.tail:
$ cat /etc/update-motd.d/50-footer
#!/bin/sh
#### CUT COMMENTS ####
[ -f /etc/motd.tail ] && cat /etc/motd.tail || true


- Il quarto controlla gli aggiornamenti e mi mostra un messaggio di notifica
se ci sono pacchetti da aggiornare - attenzione che a seconda del tuo
sistema e della tua rete questo controllo può parti perdere anche una
trentina di secondi al login!
$ cat /etc/update-motd.d/90-updates
#!/bin/sh
#### CUT COMMENTS ####
/usr/lib/update-notifier/update-motd-updates-available


Spero di esserti stato d?aiuto,
buona fortuna,
gerlos

--
"Fairy tales are more than true, not because they tell us that dragons
exist, but because they tell us that dragons can be beaten."
					G. K. Chesterton
       <http://gerlos.altervista.org>
gerlos +- - - > gnu/linux registred user #311588


-- 
Per REVOCARE l'iscrizione alla lista, inviare un email a 
debian-italian-REQUEST@lists.debian.org con oggetto "unsubscribe". Per
problemi inviare un email in INGLESE a listmaster@lists.debian.org

To UNSUBSCRIBE, email to debian-italian-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact
listmaster@lists.debian.org
Archive:
[🔎] B941D8F9-FD1B-4F69-B375-2278F50AEBE1@gmail.com">https://lists.debian.org/[🔎] B941D8F9-FD1B-4F69-B375-2278F50AEBE1@gmail.com



Reply to: