Improve script
This commit is contained in:
parent
a93e496b52
commit
e56009e7a8
2 changed files with 28 additions and 7 deletions
|
@ -24,7 +24,7 @@ Important note: Depending on the system, some entries may not be available.
|
||||||
| ping | Check if ping succeed (internet is available) |
|
| ping | Check if ping succeed (internet is available) |
|
||||||
| boot_folder | Recursive listing of /boot/ |
|
| boot_folder | Recursive listing of /boot/ |
|
||||||
| root_folder | Content of / |
|
| 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) |
|
| cmd_\<command\>_version | Get the version of some specific commands (e.g: gcc, python etc) |
|
||||||
| /proc/cmdline | See kernel parameters |
|
| /proc/cmdline | See kernel parameters |
|
||||||
| kernel_config | Get kernel config |
|
| kernel_config | Get kernel config |
|
||||||
|
|
33
sysdump.sh
33
sysdump.sh
|
@ -79,15 +79,30 @@ sysdump() {
|
||||||
echo "Current working directory is ${PWD}" >> "${LOG_FILE}"
|
echo "Current working directory is ${PWD}" >> "${LOG_FILE}"
|
||||||
echo "Current user is $(whoami)" >> "${LOG_FILE}"
|
echo "Current user is $(whoami)" >> "${LOG_FILE}"
|
||||||
echo "${DUMP_DELIMITER}"
|
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
|
# Start dump
|
||||||
echo "{"
|
echo "{"
|
||||||
USE_COMMA=1
|
USE_COMMA=1
|
||||||
# safecat
|
# safecat
|
||||||
dump "/etc/nftables.conf" safecat /etc/nftables.conf
|
dump "/etc/nftables.conf" safecat /etc/nftables.conf
|
||||||
dump "/etc/group" safecat /etc/group
|
dump "/etc/group" safecat /etc/group
|
||||||
dump "$HOME/.bashrc" safecat $HOME/.bashrc
|
for hp in "${USER_DIRS[@]}"
|
||||||
dump "$HOME/.bash_profile" safecat $HOME/.bash_profile
|
do
|
||||||
dump "$HOME/.bash_history" safecat $HOME/.bash_history
|
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/fstab" safecat /etc/fstab
|
||||||
dump "/etc/ssh/sshd_config" safecat /etc/ssh/sshd_config
|
dump "/etc/ssh/sshd_config" safecat /etc/ssh/sshd_config
|
||||||
dump "/proc/cpuinfo" safecat /proc/cpuinfo
|
dump "/proc/cpuinfo" safecat /proc/cpuinfo
|
||||||
|
@ -119,7 +134,10 @@ sysdump() {
|
||||||
dump "free" safecmd free -h
|
dump "free" safecmd free -h
|
||||||
dump "df" safecmd df -h
|
dump "df" safecmd df -h
|
||||||
dump "boot_folder" safecmd ls -R /boot/
|
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 "root_folder" safecmd ls -al /
|
||||||
dump "uid" safecmd id -u
|
dump "uid" safecmd id -u
|
||||||
dump "gid" safecmd id -g
|
dump "gid" safecmd id -g
|
||||||
|
@ -158,8 +176,11 @@ sysdump() {
|
||||||
dump "fdisk" safecmdroot fdisk -l
|
dump "fdisk" safecmdroot fdisk -l
|
||||||
dump "dmesg" safecmdroot dmesg
|
dump "dmesg" safecmdroot dmesg
|
||||||
# dumpdisk
|
# dumpdisk
|
||||||
[ -d "${HOME}/.ssh" ] && dumpdisk "tar_${HOME}/.ssh" "${HOME}/.ssh"
|
for hp in "${USER_DIRS[@]}"
|
||||||
[ -d "${HOME}/.gnupg" ] && dumpdisk "tar_${HOME}/.gnupg" "${HOME}/.gnupg"
|
do
|
||||||
|
[ -d "${hp}/.ssh" ] && dumpdisk "tar_${hp}/.ssh" "${hp}/.ssh"
|
||||||
|
[ -d "${hp}/.gnupg" ] && dumpdisk "tar_${hp}/.gnupg" "${hp}/.gnupg"
|
||||||
|
done
|
||||||
USE_COMMA=0
|
USE_COMMA=0
|
||||||
dump "dump_log" cat "${LOG_FILE}"
|
dump "dump_log" cat "${LOG_FILE}"
|
||||||
echo "}"
|
echo "}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue