Initial commit
This commit is contained in:
commit
8910dc207d
14 changed files with 388 additions and 0 deletions
16
.gitignore.d/motd-colmaris
Normal file
16
.gitignore.d/motd-colmaris
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
*
|
||||||
|
!/git
|
||||||
|
!/git/motd-colmaris
|
||||||
|
!/git/motd-colmaris/README.md
|
||||||
|
!/git/motd-colmaris/source
|
||||||
|
!/git/motd-colmaris/source/bootlogs
|
||||||
|
!/git/motd-colmaris/source/debian
|
||||||
|
!/git/motd-colmaris/source/debian/changelog
|
||||||
|
!/git/motd-colmaris/source/debian/compat
|
||||||
|
!/git/motd-colmaris/source/debian/control
|
||||||
|
!/git/motd-colmaris/source/debian/copyright
|
||||||
|
!/git/motd-colmaris/source/debian/postinst
|
||||||
|
!/git/motd-colmaris/source/debian/rules
|
||||||
|
!/git/motd-colmaris/source/motd
|
||||||
|
!/git/motd-colmaris/source/motd.tcl
|
||||||
|
!/git/motd-colmaris/source/profile
|
46
README.md
Normal file
46
README.md
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# Dynamic Message of the day for my Debian server
|
||||||
|
|
||||||
|
Screenshot
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Configuration :
|
||||||
|
|
||||||
|
You have to install the rsb-release package to use it.
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt-get install lsb-release
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install the developpment release
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone https://labo.olivierdelort.net/olivier/motd.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Disable the SSH's motd
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo sed -i 's/#PrintMotd yes/PrintMotd no/g' /etc/ssh/sshd_config
|
||||||
|
```
|
||||||
|
|
||||||
|
Enable the new motd at start session
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo echo "/usr/local/bin/coldmotd" > /etc/profile.d/coldmotd.sh
|
||||||
|
sudo chmod +x /etc/profile.d/coldmotd.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Copy the new motd
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo cp motd /usr/local/bin/
|
||||||
|
sudo chmod +x /usr/local/bin/motd
|
||||||
|
```
|
||||||
|
# FOR ZSH USERS
|
||||||
|
|
||||||
|
Just add this line "/usr/local/bin/motd" in your ~/.ZSHRC. It's recommanded to add it at the end of the file
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Sources : https://github.com/jjasghar/scripts/blob/master/dynmotd
|
BIN
screen_shot.jpg
Normal file
BIN
screen_shot.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
33
source/coldmotd
Normal file
33
source/coldmotd
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
PROCCOUNT=`ps -Afl | wc -l`
|
||||||
|
PROCCOUNT=`expr $PROCCOUNT - 5`
|
||||||
|
|
||||||
|
uptime=$(</proc/uptime)
|
||||||
|
uptime=${uptime%%.*}
|
||||||
|
|
||||||
|
seconds=$(( uptime%60 ))
|
||||||
|
minutes=$(( uptime/60%60 ))
|
||||||
|
hours=$(( uptime/60/60%24 ))
|
||||||
|
days=$(( uptime/60/60/24 ))
|
||||||
|
|
||||||
|
echo -e "
|
||||||
|
\033[1;31m+++++++++++++++++: \033[0;37mSystem Data\033[1;31m :+++++++++++++++++++
|
||||||
|
+ \033[0;37mHostname \033[1;31m= \033[1;32m`hostname`
|
||||||
|
\033[1;31m+ \033[0;37mAddress \033[1;31m= \033[1;32m`ip addr show | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | sed ':a;N;$!ba;s/\n/ , /g'`
|
||||||
|
\033[1;31m+ \033[0;37mSystem \033[1;31m= \033[1;32m`lsb_release -d | awk -F':' '{print $2}' | sed 's/^\s*//g'`
|
||||||
|
\033[1;31m+ \033[0;37mKernel \033[1;31m= \033[1;32m`uname -r`
|
||||||
|
\033[1;31m+ \033[0;37mCPU Info \033[1;31m= \033[1;32m`more /proc/cpuinfo | grep -i processor | wc -l` "x" `more /proc/cpuinfo | grep 'model name' | uniq |awk -F":" '{print $2}'`
|
||||||
|
\033[1;31m+ \033[0;37mUptime \033[1;31m= \033[1;32m"$days days, $hours hours, $minutes minutes, $seconds seconds"
|
||||||
|
\033[1;31m+ \033[0;37mMemory \033[1;31m= \033[1;32m`free -m |grep Mem: | awk -F " " '{print $2}'` MO / `free -m |grep Mem: | awk -F " " '{print $3}'` MO Used
|
||||||
|
\033[1;31m+ \033[0;37mMemory Free \033[1;31m= \033[1;32m`free -m |grep Mem: | awk -F " " '{print $4}'` MO
|
||||||
|
\033[1;31m+ \033[0;37mSwap \033[1;31m= \033[1;32m`free -m | tail -n 1 | awk {'print $2'}` Mb Total | \033[1;32m`free -m | tail -n 1 | awk {'print $4'}` Mb Free | \033[1;32m`free -m | tail -n 1 | awk {'print $3'}` Mb used
|
||||||
|
\033[1;31m+ \033[0;37mRoot Disk Space \033[1;31m= \033[1;32m`df -h / | awk '{ a = $2 } END { print a }'` Total | \033[1;32m`df -h / | awk '{ a = $3 } END { print a }'` Used | \033[1;32m`df -h / | awk '{ a = $4 } END { print a }'` Free
|
||||||
|
\033[1;31m+ \033[0;37mOpenVz Space Use \033[1;31m= \033[1;32m`/usr/local/bin/openvz`
|
||||||
|
\033[1;31m+ \033[0;37mLXC Space Use \033[1;31m= \033[1;32m`/usr/local/bin/lxc`
|
||||||
|
\033[1;31m+++++++++++++++++: \033[0;37mUser Data\033[1;31m :+++++++++++++++++++++
|
||||||
|
+ \033[0;37mUsername \033[1;31m= \033[1;32m`whoami`
|
||||||
|
\033[1;31m+ \033[0;37mProcesses \033[1;31m= \033[1;32m$PROCCOUNT of `ulimit -u` MAX
|
||||||
|
\033[1;31m+++++++++++++++++: \033[0;37mLast Maintenance\033[1;31m :++++++++++++++
|
||||||
|
\033[1;32m`tail /etc/motd-maint -n 3`
|
||||||
|
\033[1;31m+++++++++++++++++++++++++++++++++++++++++++++++++++\033[0m"
|
||||||
|
|
108
source/debian/changelog
Normal file
108
source/debian/changelog
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
coldmotd (1.7) stable; urgency=low
|
||||||
|
|
||||||
|
* disable the system message of the day
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Fri, 23 Oct 2015 11:18:00 +0100
|
||||||
|
|
||||||
|
coldmotd (1.6) stable; urgency=low
|
||||||
|
|
||||||
|
* obsolete ifconfig fixed by ip addr show
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Wed, 21 Oct 2015 00:56:00 +0100
|
||||||
|
|
||||||
|
coldmotd (1.5) stable; urgency=low
|
||||||
|
|
||||||
|
* back to the first install for zsh users
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Wed, 21 Oct 2015 00:13:00 +0100
|
||||||
|
|
||||||
|
coldmotd (1.4) stable; urgency=low
|
||||||
|
|
||||||
|
* message for zsh most viewer
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Wed, 21 Oct 2015 00:13:00 +0100
|
||||||
|
|
||||||
|
coldmotd (1.3) stable; urgency=low
|
||||||
|
|
||||||
|
* pause in postintall file fixed
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Wed, 21 Oct 2015 00:07:00 +0100
|
||||||
|
|
||||||
|
coldmotd (1.2) stable; urgency=low
|
||||||
|
|
||||||
|
* installation fixed fir zsh users
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Wed, 21 Oct 2015 00:03:00 +0100
|
||||||
|
|
||||||
|
coldmotd (1.1) stable; urgency=low
|
||||||
|
|
||||||
|
* use space disk for root partition added
|
||||||
|
* container space disk use for openvz and lxc
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Tue, 20 Oct 2015 23:42:00 +0100
|
||||||
|
|
||||||
|
coldmotd (1.0) stable; urgency=low
|
||||||
|
|
||||||
|
* new code
|
||||||
|
* Most simply to configure and install
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Thu, 25 Jun 2015 06:56:00 +0100
|
||||||
|
|
||||||
|
coldmotd (1.0.1) stable; urgency=low
|
||||||
|
|
||||||
|
* new layout
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Mon, 28 Apr 2014 13:12:00 +0100
|
||||||
|
|
||||||
|
coldmotd (1.0.0) unstable; urgency=low
|
||||||
|
|
||||||
|
* disk usage deleted
|
||||||
|
* warning message deleted
|
||||||
|
* new ascii logo
|
||||||
|
* first stable version 1.0.0
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Mon, 28 Apr 2014 13:12:00 +0100
|
||||||
|
|
||||||
|
|
||||||
|
coldmotd (0.1-beta5) unstable; urgency=low
|
||||||
|
|
||||||
|
* new logo.
|
||||||
|
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Fri, 21 Mar 2014 14:12:00 +0100
|
||||||
|
|
||||||
|
coldmotd (0.1-beta4) unstable; urgency=low
|
||||||
|
|
||||||
|
* motd.tcl right configured at the end of the postinst.
|
||||||
|
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Fri, 21 Mar 2014 14:12:00 +0100
|
||||||
|
|
||||||
|
coldmotd (0.1-beta3) unstable; urgency=low
|
||||||
|
|
||||||
|
* fi function was forgoten.
|
||||||
|
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Fri, 21 Mar 2014 11:56:00 +0100
|
||||||
|
|
||||||
|
|
||||||
|
coldmotd (0.1-beta2) unstable; urgency=low
|
||||||
|
|
||||||
|
* exit 0 added at the end of the postinst file.
|
||||||
|
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Fri, 21 Mar 2014 11:56:00 +0100
|
||||||
|
|
||||||
|
coldmotd (0.1-beta1) unstable; urgency=low
|
||||||
|
|
||||||
|
* postinst file added to install new bootlogs file.
|
||||||
|
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Fri, 21 Mar 2014 10:56:00 +0100
|
||||||
|
|
||||||
|
coldmotd (0.1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Initial release.
|
||||||
|
|
||||||
|
|
||||||
|
-- Olivier Delort <courriel@olivierdelort.net> Fri, 21 Mar 2014 06:56:00 +0100
|
1
source/debian/compat
Normal file
1
source/debian/compat
Normal file
|
@ -0,0 +1 @@
|
||||||
|
5
|
12
source/debian/control
Normal file
12
source/debian/control
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
Source: coldmotd
|
||||||
|
Section: misc
|
||||||
|
Priority: extra
|
||||||
|
Maintainer: Olivier Delort <courriel@olivierdelort.net>
|
||||||
|
Build-Depends: debhelper (>= 5.0.0)
|
||||||
|
Standards-Version: 1.7
|
||||||
|
Homepage: http://wiki-colmaris.olivierdelort.net
|
||||||
|
|
||||||
|
Package: coldmotd
|
||||||
|
Architecture: all
|
||||||
|
Depends: lsb-release
|
||||||
|
Description: Configuration for the message of the day colmaris's server.
|
21
source/debian/copyright
Normal file
21
source/debian/copyright
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
This package was debianized by Olivier Delort <courriel@olivierdelort.net>
|
||||||
|
Fri, 21 Mar 2014 06:59:00 +0100
|
||||||
|
|
||||||
|
Copyright:
|
||||||
|
Packaging copyright © 2014 Olivier Delort <courriel@olivierdelort.net>
|
||||||
|
Writting copyright © 2014 Olivier Delort <courriel@olivierdelort.net>
|
||||||
|
|
||||||
|
License:
|
||||||
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
Version 2, December 2004
|
||||||
|
|
||||||
|
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim or modified
|
||||||
|
copies of this license document, and changing it is allowed as long
|
||||||
|
as the name is changed.
|
||||||
|
|
||||||
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. You just DO WHAT THE FUCK YOU WANT TO.
|
15
source/debian/postinst
Normal file
15
source/debian/postinst
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#Disable the motd in SSH Server
|
||||||
|
sed -i 's/#PrintMotd yes/PrintMotd no/g' /etc/ssh/sshd_config
|
||||||
|
#Enable motd for bash user
|
||||||
|
echo "/usr/local/bin/coldmotd" > /etc/profile.d/coldmotd.sh
|
||||||
|
chmod +x /etc/profile.d/coldmotd.sh
|
||||||
|
# for zsh users
|
||||||
|
if [ -f "/usr/bin/zsh" ];then
|
||||||
|
echo "/usr/local/bin/coldmotd" >> ~/.zprofile;
|
||||||
|
fi
|
||||||
|
#disable the system motd
|
||||||
|
echo "" > /etc/motd
|
||||||
|
chmod +x /usr/local/bin/coldmotd
|
||||||
|
exit 0
|
36
source/debian/rules
Executable file
36
source/debian/rules
Executable file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
build:
|
||||||
|
|
||||||
|
build-arch:
|
||||||
|
|
||||||
|
build-indep:
|
||||||
|
|
||||||
|
clean:
|
||||||
|
dh_testdir
|
||||||
|
dh_testroot
|
||||||
|
dh_clean
|
||||||
|
|
||||||
|
install:
|
||||||
|
dh_install coldmotd /usr/local/bin
|
||||||
|
dh_install motd-maint /etc/
|
||||||
|
dh_install openvz /usr/local/bin
|
||||||
|
dh_install lxc /usr/local/bin
|
||||||
|
dh_testdir
|
||||||
|
dh_testroot
|
||||||
|
binary-arch:
|
||||||
|
|
||||||
|
binary-indep: install
|
||||||
|
dh_testdir
|
||||||
|
dh_testroot
|
||||||
|
dh_installchangelogs
|
||||||
|
dh_installdocs
|
||||||
|
dh_fixperms
|
||||||
|
dh_installdeb
|
||||||
|
dh_gencontrol
|
||||||
|
dh_md5sums
|
||||||
|
dh_builddeb
|
||||||
|
|
||||||
|
binary: binary-indep binary-arch
|
||||||
|
|
||||||
|
.PHONY: clean install binary-arch binary-indep binary
|
7
source/lxc
Executable file
7
source/lxc
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -d "/var/lib/lxc" ];then
|
||||||
|
df -h /var/lib/lxc | awk '{ a = $5} END {print a}';
|
||||||
|
else
|
||||||
|
echo "Not Installed";
|
||||||
|
fi
|
3
source/motd-maint
Normal file
3
source/motd-maint
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Nothing to report !
|
||||||
|
Modify the motd-maint file in /etc/
|
||||||
|
Only the 3 last lines are display!
|
83
source/old_motd.tcl
Normal file
83
source/old_motd.tcl
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
#!/usr/bin/tclsh
|
||||||
|
# MOTD script for server
|
||||||
|
# 21.03.2014 08:53:17
|
||||||
|
# Olivier Delort contact@olivierdelort.net
|
||||||
|
|
||||||
|
# * Variables
|
||||||
|
set var(user) $env(USER)
|
||||||
|
set var(path) $env(PWD)
|
||||||
|
|
||||||
|
|
||||||
|
# * Calculate last login
|
||||||
|
set lastlog [exec -- lastlog -u $var(user)]
|
||||||
|
set ll(1) [lindex $lastlog 7]
|
||||||
|
set ll(2) [lindex $lastlog 8]
|
||||||
|
set ll(3) [lindex $lastlog 9]
|
||||||
|
set ll(4) [lindex $lastlog 10]
|
||||||
|
set ll(5) [lindex $lastlog 6]
|
||||||
|
|
||||||
|
# * Calculate current system uptime
|
||||||
|
set uptime [exec -- /usr/bin/cut -d. -f1 /proc/uptime]
|
||||||
|
set up(days) [expr {$uptime/60/60/24}]
|
||||||
|
set up(hours) [expr {$uptime/60/60%24}]
|
||||||
|
set up(mins) [expr {$uptime/60%60}]
|
||||||
|
set up(secs) [expr {$uptime%60}]
|
||||||
|
|
||||||
|
# * Calculate SSH logins:
|
||||||
|
set logins [exec -- w -s]
|
||||||
|
set log(c) [lindex $logins 5]
|
||||||
|
|
||||||
|
# * Calculate processes
|
||||||
|
set psu [lindex [exec -- ps U $var(user) h | wc -l] 0]
|
||||||
|
set psa [lindex [exec -- ps -A h | wc -l] 0]
|
||||||
|
|
||||||
|
# * Calculate current system load
|
||||||
|
set loadavg [exec -- /bin/cat /proc/loadavg]
|
||||||
|
set sysload(1) [lindex $loadavg 0]
|
||||||
|
set sysload(5) [lindex $loadavg 1]
|
||||||
|
set sysload(15) [lindex $loadavg 2]
|
||||||
|
|
||||||
|
# * Calculate Memory
|
||||||
|
set memory [exec -- free -m]
|
||||||
|
set mem(t) [lindex $memory 7]
|
||||||
|
set mem(u) [lindex $memory 8]
|
||||||
|
set mem(f) [lindex $memory 9]
|
||||||
|
set mem(c) [lindex $memory 16]
|
||||||
|
set mem(s) [lindex $memory 19]
|
||||||
|
|
||||||
|
# * display kernel version
|
||||||
|
set uname [exec -- /bin/uname -nrmo]
|
||||||
|
set unameoutput0 [lindex $uname 0]
|
||||||
|
set unameoutput1 [lindex $uname 1]
|
||||||
|
set unameoutput2 [lindex $uname 2]
|
||||||
|
set unameoutput3 [lindex $uname 3]
|
||||||
|
# * ascii head
|
||||||
|
set head {
|
||||||
|
_
|
||||||
|
| |
|
||||||
|
__ _____| | ___ ___ _ __ ___ ___
|
||||||
|
\ \ /\ / / _ \ |/ __/ _ \| '_ ` _ \ / _ \
|
||||||
|
\ V V / __/ | (_| (_) | | | | | | __/
|
||||||
|
\_/\_/ \___|_|\___\___/|_| |_| |_|\___|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# * Print Output
|
||||||
|
puts "\033\[01;32m$head\033\[0m"
|
||||||
|
puts " \033\[35mSystem........:\033\[0m \033\[36m $unameoutput0 $unameoutput1 $unameoutput2 $unameoutput3"
|
||||||
|
puts " \033\[35mLast Login....:\033\[0m \033\[36m $ll(1) $ll(2) $ll(3) $ll(4) from $ll(5)"
|
||||||
|
puts " \033\[35mUptime........:\033\[0m \033\[36m $up(days)days $up(hours)hours $up(mins)minutes $up(secs)seconds"
|
||||||
|
puts " \033\[35mLoad..........:\033\[0m \033\[36m $sysload(1) (1minute) $sysload(5) (5minutes) $sysload(15) (15minutes)"
|
||||||
|
puts " \033\[35mMemory MB.....:\033\[0m \033\[36m $mem(t) Used: $mem(u) Free: $mem(f) Free Cached: $mem(c) Swap In Use: $mem(s)"
|
||||||
|
puts " \033\[35mSSH Logins....:\033\[0m \033\[36m There are currently $log(c) users logged in."
|
||||||
|
puts " \033\[35mProcesses.....:\033\[0m \033\[36m $psa total running of which $psu yours"
|
||||||
|
|
||||||
|
if {[file exists /etc/changelog]&&[file readable /etc/changelog]} {
|
||||||
|
puts " . .. More or less important system informations:\n"
|
||||||
|
set fp [open /etc/changelog]
|
||||||
|
while {-1!=[gets $fp line]} {
|
||||||
|
puts " ..) $line"
|
||||||
|
}
|
||||||
|
close $fp
|
||||||
|
puts ""
|
||||||
|
}
|
7
source/openvz
Executable file
7
source/openvz
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -d "/var/lib/vz" ];then
|
||||||
|
df -h /var/lib/vz | awk '{ a = $5} END {print a}';
|
||||||
|
else
|
||||||
|
echo "Not Installed";
|
||||||
|
fi
|
Loading…
Add table
Reference in a new issue