profile-pyratenet.sh.j2 (1437B)
1 #!/usr/bin/env sh 2 c00='[0;30m' 3 c01='[0;31m' 4 c02='[0;32m' 5 c03='[0;33m' 6 c04='[0;34m' 7 c05='[0;35m' 8 c06='[0;36m' 9 c07='[0;37m' 10 c08='[1;30m' 11 c09='[1;31m' 12 c10='[1;32m' 13 c11='[1;33m' 14 c12='[1;34m' 15 c13='[1;35m' 16 c14='[1;36m' 17 c15='[1;37m' 18 19 f0='[1;30m' 20 f1='[1;37m' 21 f2='[0;37m' 22 23 {% if ansible_distribution == "OpenBSD" %} 24 host=$(hostname) 25 up=$(uptime | awk -F"up " '{print $NF}' | awk -F"user" '{print $1}' | sed 's/.\ $//' | tr -d ',') 26 birthd=$(stat -f "%Sm %N" -t "%Y%m%d" /bin | awk '{print $1}') 27 system=$(uname) 28 load=$(uptime | awk -F"load averages: " '{print $NF}') 29 {% else %} 30 host=$(hostname -f) 31 up=$(uptime -p | cut -b4- | tr -d ',|eeks|ay|our|inute') 32 birthd=$(stat -c %w / | awk '{print $1}' | tr -d '-') 33 system=$(awk -F= '/^NAME=/ {print $NF}' /etc/os-release | tr -d '"' | tr 'A-Z' 'a-z') 34 load=$(awk '{print $1" "$2" "$3}' /proc/loadavg) 35 {% endif %} 36 kernel=$(uname -r | tr '[:upper:]' '[:lower:]') 37 lastlog_date=$(last | head -2 | tail -1 | awk '{print $4" "$5" "$6" "$7}' | date +%Y%m%d@%H%M) 38 lastlog_ip=$(last | head -2 | tail -1 | awk '{print $3}') 39 40 if [ -t 1 ] && [ ! -f ~/.hushlogin ] && [ -n "$SSH_TTY" ] ; then 41 cat << EOF 42 ${f1}host ${f0}...... $f2$host 43 ${f1}up ${f0}........ $f2$up 44 ${f1}birth ${f0}..... $f2$birthd 45 ${f1}sys ${f0}....... $f2$system 46 ${f1}shell ${f0}..... $f2$SHELL 47 ${f1}kernel ${f0}.... $f2$kernel 48 ${f1}load ${f0}...... $f2$load 49 ${f1}lastlog ${f0}... $f2$lastlog_date from $lastlog_ip 50 51 EOF 52 fi