Skip to content

Commit

Permalink
Force $lastbackup to use latest date.
Browse files Browse the repository at this point in the history
  Use ls -1tr in place of find
      * produce a simple list,
      * one item per line,
      * sorted by date reverse.
  • Loading branch information
Bryan Jeter committed Mar 3, 2021
1 parent 6c377f5 commit 389964f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lgsm/functions/info_distro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"

### Game Server pid
if [ "${status}" == "1" ]; then
gameserverpid=$(tmux list-sessions -F "#{session_name} #{pane_pid}" | grep "^${sessionname} " | awk '{print $NF}')
fi
### Distro information

## Distro
Expand Down Expand Up @@ -66,17 +70,17 @@ done
glibcversion=$(ldd --version | sed -n '1s/.* //p')

## tmux version
tmuxv=$(tmux -V | sed "s/tmux //")
tmuxvdigit=$(echo "${tmuxv}" | tr -cd '[:digit:]')

## Game Server pid
if [ "${status}" == "1" ]&&[ "${tmuxv}" != "1.8" ]; then
gameserverpid=$(tmux list-sessions -F "#{session_name} #{pane_pid}" | grep "^${sessionname} " | awk '{print $NF}')
# e.g: tmux 1.6
if [ ! "$(command -V tmux 2>/dev/null)" ]; then
tmuxv="${red}NOT INSTALLED!${default}"
else
if [ "$(tmux -V | sed "s/tmux //" | sed -n '1 p' | tr -cd '[:digit:]')" -lt "16" ]; then
tmuxv="$(tmux -V) (>= 1.6 required for console log)"
else
tmuxv=$(tmux -V)
fi
fi

## Date
date="$(date)"

## Uptime
uptime=$(</proc/uptime)
uptime=${uptime/[. ]*/}
Expand Down Expand Up @@ -208,7 +212,7 @@ if [ -d "${backupdir}" ]; then
# number of backups.
backupcount=$(find "${backupdir}"/*.tar.gz | wc -l)
# most recent backup.
lastbackup=$(find "${backupdir}"/*.tar.gz | tail -1)
lastbackup=$(ls -1tr "${backupdir}"/*.tar.gz | head -1)
# date of most recent backup.
lastbackupdate=$(date -r "${lastbackup}")
# no of days since last backup.
Expand Down

0 comments on commit 389964f

Please sign in to comment.