Added view option

This commit is contained in:
Price Hiller 2022-01-01 04:14:39 -06:00
parent 258f36d8bc
commit 5aa40bc1e2

View File

@ -605,6 +605,52 @@ backup() {
fi
}
view() {
local server_id
server_id=""
while :; do
case ${1} in
-h | -\? | --help)
printf "Usage: %s\n" \
"view [OPTIONS]
--server <server id: int> | -s <server id: int>
Views the given server's latest log file via tail -f
Example:
--server 3"
exit
;;
--) # End of all options.
break
;;
--server | -s)
shift
server_id="${1}"
[[ -z "${server_id}" ]] && log "error" "No server id passed" && exit 1
;;
-?*)
printf 'Unknown option: %s\n' "$1" >&2
;;
*) # Default case: No more options, so break out of the loop.
break ;;
esac
shift
done
[[ -z "${server_id}" ]] && log "error" "No server id passed" && exit 1
local server_directory
local server_name
server_name="Server-${server_id}"
server_directory="${BASE_DIR}/${server_name}"
cd "${server_directory}"
tail -f "$(ls -t output_log* | head -1)"
}
list_servers() {
local picked_option
picked_option=""
@ -695,7 +741,9 @@ usage() {
list
Exposes options to list 7 Days To Die Servers, pass -h to it for details
backup
Exposes options to backup 7 Days To Die Servers, pass -h to it for details"
Exposes options to backup 7 Days To Die Servers, pass -h to it for details
view
Exposes options to view 7 Days To Die Server Logs, pass -h to it for details"
}
main() {