mirror of
https://github.com/sbrl/cloudcatcher.git
synced 2018-01-26 00:52:31 +00:00
I think it's about time I committed this.... :P
This commit is contained in:
commit
ef89799574
4 changed files with 138 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
.cloudcatcher_settings
|
||||||
|
|
||||||
|
# Created by https://www.gitignore.io/api/git
|
||||||
|
|
||||||
|
### Git ###
|
||||||
|
*.orig
|
||||||
|
|
||||||
|
# End of https://www.gitignore.io/api/git
|
90
cloudcatcher-info.sh
Executable file
90
cloudcatcher-info.sh
Executable file
|
@ -0,0 +1,90 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ███████ ███████ ████████ ██ ██ ██████ #
|
||||||
|
# ██ ██ ██ ██ ██ ██ ██ #
|
||||||
|
# ███████ █████ ██ ██ ██ ██████ #
|
||||||
|
# ██ ██ ██ ██ ██ ██ #
|
||||||
|
# ███████ ███████ ██ ██████ ██ #
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
tmpdir="$(mktemp --directory --suffix -cloudcatcher)/";
|
||||||
|
|
||||||
|
##########################
|
||||||
|
### Colour Definitions ###
|
||||||
|
#### ANSI color codes ####
|
||||||
|
RS="\033[0m" # reset
|
||||||
|
HC="\033[1m" # hicolor
|
||||||
|
UL="\033[4m" # underline
|
||||||
|
INV="\033[7m" # inverse background and foreground
|
||||||
|
LC="\033[2m" # locolor / dim
|
||||||
|
FBLK="\033[30m" # foreground black
|
||||||
|
FRED="\033[31m" # foreground red
|
||||||
|
FGRN="\033[32m" # foreground green
|
||||||
|
FYEL="\033[33m" # foreground yellow
|
||||||
|
FONG="\033[38;5;214m" # foreground orange
|
||||||
|
FBLE="\033[34m" # foreground blue
|
||||||
|
FMAG="\033[35m" # foreground magenta
|
||||||
|
FCYN="\033[36m" # foreground cyan
|
||||||
|
FWHT="\033[37m" # foreground white
|
||||||
|
BBLK="\033[40m" # background black
|
||||||
|
BRED="\033[41m" # background red
|
||||||
|
BGRN="\033[42m" # background green
|
||||||
|
BYEL="\033[43m" # background yellow
|
||||||
|
BBLE="\033[44m" # background blue
|
||||||
|
BMAG="\033[45m" # background magenta
|
||||||
|
BCYN="\033[46m" # background cyan
|
||||||
|
BWHT="\033[47m" # background white
|
||||||
|
##########################
|
||||||
|
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
# ██████ ██████ ██ ██ ███████ ██████ ████████ ██ ██████ ███ ██ #
|
||||||
|
# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ #
|
||||||
|
# ██ ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ #
|
||||||
|
# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ #
|
||||||
|
# ██████ ██████ ███████ ███████ ███████ ██████ ██ ██ ██████ ██ ████ #
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
function calc_reboot_required {
|
||||||
|
if [ -f /var/run/reboot-required ]; then
|
||||||
|
echo "${HC}${FRED}*** System restart required ***${RS}";
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Apt package pending upgrade count
|
||||||
|
/usr/lib/update-notifier/apt-check --human-readable | head -n1 >${tmpdir}apt-packages.txt &
|
||||||
|
# Distribution name
|
||||||
|
lsb_release -ds | awk '{ gsub("GNU/Linux |[()]", ""); print($0); }' >${tmpdir}distro-description.txt &
|
||||||
|
|
||||||
|
# Hostname
|
||||||
|
hostname >${tmpdir}hostname.txt &
|
||||||
|
# Kernel version
|
||||||
|
uname -r >${tmpdir}kernel-version.txt &
|
||||||
|
# Uptime
|
||||||
|
uptime --pretty | sed -e 's/up //' >${tmpdir}uptime.txt &
|
||||||
|
# Current ips
|
||||||
|
ip addr show scope global | awk -f ./parse_interface_ips.awk >${tmpdir}ips.txt &
|
||||||
|
# Load
|
||||||
|
cat /proc/loadavg | cut -d' ' -f 2 >${tmpdir}load.txt &
|
||||||
|
|
||||||
|
# Last login
|
||||||
|
last -1 | awk '{ print $1,"on",$5,$6,$7,"\n\tfrom",$3; exit; }' >${tmpdir}last_login.txt &
|
||||||
|
# Whether a reboot is required
|
||||||
|
calc_reboot_required >${tmpdir}reboot_required.txt &
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
echo -e "Welcome to $(cat ${tmpdir}hostname.txt)";
|
||||||
|
echo -e " ${LC}running $(cat ${tmpdir}distro-description.txt)${RS}";
|
||||||
|
echo -e "Kernel: ${FRED}$(cat ${tmpdir}kernel-version.txt)${RS}";
|
||||||
|
echo -e "Uptime: ${FGRN}$(cat ${tmpdir}uptime.txt)${RS}";
|
||||||
|
echo -e "Load: ${FONG}$(cat ${tmpdir}load.txt)${RS}";
|
||||||
|
echo -e "IPs: ${FBLE}$(cat ${tmpdir}ips.txt)${RS}";
|
||||||
|
cat ${tmpdir}apt-packages.txt;
|
||||||
|
cat ${tmpdir}reboot_required.txt;
|
||||||
|
|
||||||
|
### Cleanup ###
|
||||||
|
|
||||||
|
rm -r ${tmpdir};
|
24
cloudcatcher.sh
Executable file
24
cloudcatcher.sh
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
### Settings ###
|
||||||
|
logo_filename="logo.txt";
|
||||||
|
info_filename=$(mktemp --suffix -cloudcatcher);
|
||||||
|
|
||||||
|
if [ -f .cloudcatcher_settings ]; then
|
||||||
|
source .cloudcatcher_settings;
|
||||||
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
|
||||||
|
cloudcatcher-info.sh >${info_filename}
|
||||||
|
|
||||||
|
### Output ###
|
||||||
|
echo
|
||||||
|
pr -mtJ ${logo_filename} ${info_filename};
|
||||||
|
|
||||||
|
##############
|
||||||
|
|
||||||
|
### Cleanup ###
|
||||||
|
rm "${info_filename}"
|
||||||
|
|
||||||
|
###############
|
16
parse_interface_ips.awk
Normal file
16
parse_interface_ips.awk
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
BEGIN {
|
||||||
|
ORS = ""; # We control the output separator in END
|
||||||
|
ip_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/inet6?/ {
|
||||||
|
gsub("/[0-9]+$", "", $2); # Remove the subnet from the end
|
||||||
|
ips[ip_count++] = $2;
|
||||||
|
}
|
||||||
|
|
||||||
|
END {
|
||||||
|
for(i = 0 ; i < ip_count ; i++) {
|
||||||
|
print(ips[i]);
|
||||||
|
if(i < ip_count - 1) print(", ");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue