aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoïc Guégan <loic.guegan@mailbox.org>2024-07-07 08:50:14 +0200
committerLoïc Guégan <loic.guegan@mailbox.org>2024-07-07 08:50:14 +0200
commite56009e7a83145ca87649fae5f90d8f043f5f7d8 (patch)
tree8c459e1cbc54a1f12d5c9a576f4e3b60835038d8
parenta93e496b520fefd1a61164cd3dafb8087fb08c9c (diff)
Improve script
-rw-r--r--README.md2
-rwxr-xr-xsysdump.sh33
2 files changed, 28 insertions, 7 deletions
diff --git a/README.md b/README.md
index b5b1ad4..9732478 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ Important note: Depending on the system, some entries may not be available.
| ping | Check if ping succeed (internet is available) |
| boot_folder | Recursive listing of /boot/ |
| root_folder | Content of / |
-| home_folder | Content of $HOME |
+| home_\<path\> | List the content of each home directory (at the root only) |
| cmd_\<command\>_version | Get the version of some specific commands (e.g: gcc, python etc) |
| /proc/cmdline | See kernel parameters |
| kernel_config | Get kernel config |
diff --git a/sysdump.sh b/sysdump.sh
index 50ab5f2..0ebe760 100755
--- a/sysdump.sh
+++ b/sysdump.sh
@@ -79,15 +79,30 @@ sysdump() {
echo "Current working directory is ${PWD}" >> "${LOG_FILE}"
echo "Current user is $(whoami)" >> "${LOG_FILE}"
echo "${DUMP_DELIMITER}"
+ # Populate users path
+ USER_DIRS=()
+ if [ $(id -u) -eq 0 ]
+ then
+ for dir in /home/*
+ do
+ [[ ${dir} != *"lost+found"* ]] && USER_DIRS+=($dir)
+ done
+ USER_DIRS+=(/root)
+ else
+ USER_DIRS+=($HOME)
+ fi
# Start dump
echo "{"
USE_COMMA=1
# safecat
dump "/etc/nftables.conf" safecat /etc/nftables.conf
dump "/etc/group" safecat /etc/group
- dump "$HOME/.bashrc" safecat $HOME/.bashrc
- dump "$HOME/.bash_profile" safecat $HOME/.bash_profile
- dump "$HOME/.bash_history" safecat $HOME/.bash_history
+ for hp in "${USER_DIRS[@]}"
+ do
+ dump "${hp}/.bashrc" safecat ${hp}/.bashrc
+ dump "${hp}/.bash_profile" safecat ${hp}/.bash_profile
+ dump "${hp}/.bash_history" safecat ${hp}/.bash_history
+ done
dump "/etc/fstab" safecat /etc/fstab
dump "/etc/ssh/sshd_config" safecat /etc/ssh/sshd_config
dump "/proc/cpuinfo" safecat /proc/cpuinfo
@@ -119,7 +134,10 @@ sysdump() {
dump "free" safecmd free -h
dump "df" safecmd df -h
dump "boot_folder" safecmd ls -R /boot/
- dump "home_folder" safecmd ls -al ${HOME}
+ for hp in "${USER_DIRS[@]}"
+ do
+ dump "home_${hp}" safecmd ls -al ${hp}
+ done
dump "root_folder" safecmd ls -al /
dump "uid" safecmd id -u
dump "gid" safecmd id -g
@@ -158,8 +176,11 @@ sysdump() {
dump "fdisk" safecmdroot fdisk -l
dump "dmesg" safecmdroot dmesg
# dumpdisk
- [ -d "${HOME}/.ssh" ] && dumpdisk "tar_${HOME}/.ssh" "${HOME}/.ssh"
- [ -d "${HOME}/.gnupg" ] && dumpdisk "tar_${HOME}/.gnupg" "${HOME}/.gnupg"
+ for hp in "${USER_DIRS[@]}"
+ do
+ [ -d "${hp}/.ssh" ] && dumpdisk "tar_${hp}/.ssh" "${hp}/.ssh"
+ [ -d "${hp}/.gnupg" ] && dumpdisk "tar_${hp}/.gnupg" "${hp}/.gnupg"
+ done
USE_COMMA=0
dump "dump_log" cat "${LOG_FILE}"
echo "}"