playbooks

ansible config management
git clone git://git.pyratebeard.net/playbooks.git
Log | Files | Refs | README

profile-pyratenet.sh.j2 (1437B)


      1 #!/usr/bin/env sh
      2 c00=''
      3 c01=''
      4 c02=''
      5 c03=''
      6 c04=''
      7 c05=''
      8 c06=''
      9 c07=''
     10 c08=''
     11 c09=''
     12 c10=''
     13 c11=''
     14 c12=''
     15 c13=''
     16 c14=''
     17 c15=''
     18 
     19 f0=''
     20 f1=''
     21 f2=''
     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