7 Commits

Author SHA1 Message Date
19f54c9f52 Specifically use os-release
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-08 10:02:22 +13:00
1f6b4d51e0 Silence /proc
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-08 07:30:20 +13:00
2652ce3653 Fix output
All checks were successful
continuous-integration/drone Build is passing
2022-11-07 22:45:06 +13:00
0f3221ac3e Fix IP address display
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-06 21:56:55 +13:00
158095b011 lies, again we go
Some checks failed
continuous-integration/drone/push Build was killed
2022-11-02 17:24:56 +13:00
dec7676e87 last test
Some checks failed
continuous-integration/drone/push Build was killed
2022-11-02 17:23:16 +13:00
943aecfe55 Escape the variables
Some checks failed
continuous-integration/drone/push Build was killed
2022-11-02 17:18:50 +13:00
2 changed files with 45 additions and 29 deletions

View File

@@ -71,23 +71,24 @@ local gen_release() =
type: 'docker',
image: 'guisea/ansible-molecule:alpine-latest',
name: 'Generate Release',
environment:
{ USER: { from_secret: 'GITEA_USER' },
TOKEN: { from_secret: 'GITEA_TOKEN' },
REPOUSER: { from_secret: 'GITEA_REPOUSER'},
URL: { from_secret: 'GITEA_URL' },
},
commands: [
'sleep 10', // give docker enough time to start
'env',
'mkdir ${DRONE_REPO_NAME}',
'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}',
'cd ${DRONE_REPO_NAME}',
'echo GITEA_USER=${USER}',
'echo GITEA_USER=$USER',
'apk update && apk add --no-cache curl',
'tar -czf ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz ./*', // Create an archive of the role
'curl --user ${USER}:${TOKEN} --upload-file ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz https://${URL}/api/packages/${REPOUSER}/generic/ansible-role-common/${DRONE_TAG}/${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz',
'curl --user $USER:$TOKEN --upload-file ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz https://$URL/api/packages/$REPOUSER/generic/ansible-role-common/${DRONE_TAG}/${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz',
],
environment:
{ USER: { from_secret: 'GITEA_USER' },
TOKEN: { from_secret: 'GITEA_TOKEN' },
REPOUSER: { from_secret: 'GITEA_REPOUSER'},
URL: { from_secret: 'GITEA_URL' },
},
when:
{ event: {include: ['tag']},
},

View File

@@ -15,21 +15,21 @@
# /usr/local/bin/dynmotd
#
USER=`whoami`
HOSTNAME=`uname -n | cut -d. -f1`
IP=`ip route get 1 | awk '{print $NF;exit}'`
NUM_CPU=`lscpu | grep "CPU(s):" | head -n 1 | awk '{print $2}'`
ROOT=`df -x fuse.gvfs-fuse-daemon -Ph | egrep -i 'root|logvol|vda' | awk '{print $4}' | tr -d '\n'`
HOME=`df -x fuse.gvfs-fuse-daemon -Ph | grep home | awk '{print $4}' | tr -d '\n'`
FILESYSTEMS=`cat /etc/fstab | grep -v '#' | grep -v 'swap' | awk '{if(NF>0) {print $2}}'`
BACKUP=`df -x fuse.gvfs-fuse-daemon -Ph | grep backup | awk '{print $4}' | tr -d '\n'`
OS_RELEASE=`awk -F= '$1=="PRETTY_NAME" { print $2 ;}' /etc/os-release | sed -e 's/^"//' -e 's/"$//'`
MEMORY=`free -m | grep "Mem" | awk '{print $2,"-",$3,"-",$4}'`
SWAP=`free -m | grep "Swap" | awk '{print $2,"-",$3,"-",$4}'`
PSA=`ps -Afl | wc -l`
USER=`/usr/bin/env whoami`
HOSTNAME=`/usr/bin/env uname -n | /usr/bin/env cut -d. -f1`
IP=`/usr/bin/env ip route get 1 | /usr/bin/env grep -Po '(?<=src.)[\w\d.]+'`
IP6=`/usr/bin/env ip -6 addr | /usr/bin/env awk -F '[ \t]+|/' '$3 == "::1" { next;} $3 ~ /^fe80::/ { next ; } /inet6/ {print $3} '`
NUM_CPU=`cat /proc/cpuinfo | grep processor | wc -l`
#ROOT=`/usr/bin/df / -x fuse.gvfs-fuse-daemon -Ph | /usr/bin/egrep -i 'root|logvol|vda' | awk '{print $4}' | tr -d '\n'`
#HOME=`/usr/bin/df /home -x fuse.gvfs-fuse-daemon -Ph | grep home | awk '{print $4}' | tr -d '\n'`
#BACKUP=`/usr/bin/df -x fuse.gvfs-fuse-daemon -Ph | grep backup | awk '{print $4}' | tr -d '\n'`
FILESYSTEMS=`cat /etc/fstab | grep -v '#' | grep -v 'swap' | grep -v 'proc' | awk '{if(NF>0) {print $2}}'`
MEMORY=`/usr/bin/env free -m | /usr/bin/env grep "Mem" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'`
SWAP=`/usr/bin/env free -m | /usr/bin/env grep "Swap" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'`
PSA=`/usr/bin/env ps -Afl | /usr/bin/env wc -l`
# time of day
HOUR=$(date +"%H")
HOUR=$(/usr/bin/env date +"%H")
if [ $HOUR -lt 12 -a $HOUR -ge 0 ]
then TIME="morning"
elif [ $HOUR -lt 17 -a $HOUR -ge 12 ]
@@ -39,17 +39,17 @@ else
fi
#System uptime
uptime=`cat /proc/uptime | cut -f1 -d.`
uptime=`/usr/bin/env cat /proc/uptime | cut -f1 -d.`
upDays=$((uptime/60/60/24))
upHours=$((uptime/60/60%24))
upMins=$((uptime/60%60))
upSecs=$((uptime%60))
#System load
LOADAVG=`cat /proc/loadavg`
LOAD1=`echo $LOADAVG | awk {'print $1'}`
LOAD5=`echo $LOADAVG | awk {'print $2'}`
LOAD15=`echo $LOADAVG | awk {'print $3'}`
LOADAVG=`/usr/bin/env cat /proc/loadavg`
LOAD1=`echo $LOADAVG | /usr/bin/env awk {'print $1'}`
LOAD5=`echo $LOADAVG | /usr/bin/env awk {'print $2'}`
LOAD15=`echo $LOADAVG | /usr/bin/env awk {'print $3'}`
echo ""
echo -e "\e[7m--- GOOD $TIME $USER ----\e[0m"
@@ -63,9 +63,19 @@ RESET_COLORS="\e[0m"
echo -e "
===========================================================================
$COLOR_COLUMN- Hostname$RESET_COLORS............: $COLOR_VALUE $HOSTNAME $RESET_COLORS
$COLOR_COLUMN- IP Address (Default)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE $OS_RELEASE $RESET_COLORS
{% if common_show_ipv6 == true %}
$COLOR_COLUMN- IP Address (Main v4)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS
$COLOR_COLUMN- IP Address (Main v6)$RESET_COLORS: $COLOR_VALUE $IP6 $RESET_COLORS
{% else %} $COLOR_COLUMN- IP Address (Default)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS
{% endif %}
{% if ansible_distribution == "Alpine" %}
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE Alpine `/usr/bin/env cat /etc/os-release` $RESET_COLORS
{% else %}
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE `/usr/bin/env cat /etc/os-release | /usr/bin/env grep PRETTY_NAME | /usr/bin/env cut -d '"' -f 2` $RESET_COLORS
{% endif %}
{% if ansible_distribution != "Alpine" %}
$COLOR_COLUMN- Users$RESET_COLORS...............: $COLOR_VALUE Currently `users | wc -w` user(s) logged on $RESET_COLORS
{% endif %}
=========================================================================== $RESET_COLORS
$COLOR_COLUMN- Current user$RESET_COLORS........: $COLOR_VALUE $USER $RESET_COLORS
$COLOR_COLUMN- Number of CPU$RESET_COLORS.......: $COLOR_VALUE $NUM_CPU $RESET_COLORS
@@ -74,10 +84,15 @@ echo -e "
$COLOR_COLUMN- Swap in use$RESET_COLORS.........: $COLOR_VALUE $SWAP (total-used-free) MB $RESET_COLORS
$COLOR_COLUMN- Processes$RESET_COLORS...........: $COLOR_VALUE $PSA running $RESET_COLORS
$COLOR_COLUMN- System uptime$RESET_COLORS.......: $COLOR_VALUE $upDays days $upHours hours $upMins minutes $upSecs seconds $RESET_COLORS
{% if ansible_virtualization_type != "lxc" %}
$COLOR_COLUMN- Disk space$RESET_COLORS..........: "
for FS in ${FILESYSTEMS}; do
echo -e " $COLOR_COLUMN- ..........$RESET_COLORS..........: $COLOR_VALUE `df -H ${FS} | grep -v 'Filesystem' | grep -v '^[[:space:]]*$' | awk '{print $6 " " $4}'` remaining $RESET_COLORS"
echo -e " $COLOR_COLUMN- ..........$RESET_COLORS..........: $COLOR_VALUE `df -H ${FS} | grep -v 'Filesystem' | grep -v '^[[:space:]]*$' | awk '{print $6 \" \" $4}'` remaining $RESET_COLORS"
done
{% endif %}
echo -e "
===========================================================================
"
if [ -f /etc/motd ]; then
`/usr/bin/env cat /etc/motd`
fi