Birthday: Rename get_birthday() to get_install_date()

This commit is contained in:
Dylan Araps 2016-12-16 18:03:29 +11:00
parent d375aa24d6
commit 2490a45293
4 changed files with 27 additions and 25 deletions

View File

@ -39,7 +39,7 @@ print_info() {
# info "Local IP" local_ip # info "Local IP" local_ip
# info "Public IP" public_ip # info "Public IP" public_ip
# info "Users" users # info "Users" users
# info "Birthday" birthday # info "Install Date" install_date
info line_break info line_break
info cols info cols
@ -292,19 +292,19 @@ public_ip_host="http://ident.me"
song_shorthand="off" song_shorthand="off"
# Birthday # Install Date
# Whether to show the time in the output # Whether to show the time in the output
# #
# Default: 'on' # Default: 'on'
# Values: 'on', 'off' # Values: 'on', 'off'
# Flag: --birthday_time # Flag: --install_time
# #
# Example: # Example:
# on: 'Thu 14 Apr 2016 11:50 PM' # on: 'Thu 14 Apr 2016 11:50 PM'
# off: 'Thu 14 Apr 2016' # off: 'Thu 14 Apr 2016'
birthday_time="on" install_time="on"
# Text Colors # Text Colors

View File

@ -33,7 +33,7 @@ print_info() {
info "Local IP" local_ip info "Local IP" local_ip
info "Public IP" public_ip info "Public IP" public_ip
info "Users" users info "Users" users
info "Birthday" birthday info "Install Date" install_date
info line_break info line_break
info cols info cols

View File

@ -1726,51 +1726,51 @@ get_users() {
users="${users%\,*}" users="${users%\,*}"
} }
get_birthday() { get_install_date() {
case "$os" in case "$os" in
"Linux" | "GNU" | "iPhone OS") "Linux" | "GNU" | "iPhone OS")
birthday="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')" install_date="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')"
;; ;;
"Mac OS X") "Mac OS X")
birthday="$(ls -lUT /var/log/install.log | awk '{printf $9 " " $6 " " $7 " " $8}')" install_date="$(ls -lUT /var/log/install.log | awk '{printf $9 " " $6 " " $7 " " $8}')"
;; ;;
"BSD") "BSD")
case "$kernel_name" in case "$kernel_name" in
"OpenBSD"* | "Bitrig"*) "OpenBSD"* | "Bitrig"*)
birthday_file="/" install_file="/"
;; ;;
"FreeBSD"*) "FreeBSD"*)
birthday_file="/etc/hostid" install_file="/etc/hostid"
;; ;;
"NetBSD"* | "DragonFly"*) "NetBSD"* | "DragonFly"*)
birthday_file="/etc/defaults/rc.conf" install_file="/etc/defaults/rc.conf"
;; ;;
esac esac
birthday="$(ls -alctT "$birthday_file" | awk '{printf $9 " " $6 " " $7 " " $8 " "}')" install_date="$(ls -alctT "$install_file" | awk '{printf $9 " " $6 " " $7 " " $8 " "}')"
;; ;;
"Windows") "Windows")
birthday="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')" install_date="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')"
;; ;;
"Solaris") "Solaris")
birthday="$(ls -alct --full-time /var/sadm/system/logs/install_log | awk '{printf $6 " " $7}')" install_date="$(ls -alct --full-time /var/sadm/system/logs/install_log | awk '{printf $6 " " $7}')"
;; ;;
"Haiku") "Haiku")
birthday="$(ls -alctd --full-time /boot | awk '{printf $6 " " $7}')" install_date="$(ls -alctd --full-time /boot | awk '{printf $6 " " $7}')"
;; ;;
esac esac
birthday="${birthday//-/ }" install_date="${install_date//-/ }"
birthday="${birthday%:*}" install_date="${install_date%:*}"
birthday=($birthday) install_date=($install_date)
birthday="$(convert_time "${birthday[@]}")" install_date="$(convert_time "${install_date[@]}")"
} }
get_cols() { get_cols() {
@ -2883,6 +2883,8 @@ old_functions() {
get_publicip() { get_public_ip; publicip="$public_ip"; } get_publicip() { get_public_ip; publicip="$public_ip"; }
get_linebreak() { get_line_break; linebreak="$line_break"; } get_linebreak() { get_line_break; linebreak="$line_break"; }
fi fi
get_birthday() { get_install_date; birthday="$install_date"; }
} }
old_options() { old_options() {
@ -2970,9 +2972,9 @@ convert_time() {
esac esac
# Toggle showing the time # Toggle showing the time
[[ "$birthday_time" == "off" ]] && unset time [[ "$install_time" == "off" ]] && unset time
# Print the birthday. # Print the install date.
printf "%s" "$week_day $day $month $year $time" printf "%s" "$week_day $day $month $year $time"
} }
@ -3034,7 +3036,7 @@ INFO
--shell_version on/off Enable/Disable showing \$SHELL version --shell_version on/off Enable/Disable showing \$SHELL version
--ip_host url URL to query for public IP --ip_host url URL to query for public IP
--song_shorthand on/off Print the Artist/Title on seperate lines --song_shorthand on/off Print the Artist/Title on seperate lines
--birthday_time on/off Enable/Disable showing the time in birthday output. --install_time on/off Enable/Disable showing the time in Install Date output.
TEXT FORMATTING TEXT FORMATTING
@ -3203,7 +3205,7 @@ get_args() {
"--shell_version") shell_version="$2" ;; "--shell_version") shell_version="$2" ;;
"--ip_host") public_ip_host="$2" ;; "--ip_host") public_ip_host="$2" ;;
"--song_shorthand") song_shorthand="$2" ;; "--song_shorthand") song_shorthand="$2" ;;
"--birthday_time") birthday_time="$2" ;; "--install_time") install_time="$2" ;;
"--disable") "--disable")
for func in "$@"; do for func in "$@"; do
case "$func" in case "$func" in

View File

@ -89,8 +89,8 @@ URL to query for public IP
\fB\-\-song_shorthand\fR on/off \fB\-\-song_shorthand\fR on/off
Print the Artist/Title on seperate lines Print the Artist/Title on seperate lines
.TP .TP
\fB\-\-birthday_time\fR on/off \fB\-\-install_time\fR on/off
Enable/Disable showing the time in birthday output. Enable/Disable showing the time in Install Date output.
.PP .PP
TEXT FORMATTING TEXT FORMATTING
.TP .TP