collect_rancheros_info.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. # How to use:
  3. #
  4. # 1. Login to your rancheros and switch to root
  5. # $ sudo su - root
  6. # 2. Collecting rancheros information
  7. # # curl https://raw.githubusercontent.com/rancher/os/master/scripts/tools/collect_rancheros_info.sh | sh
  8. set -e
  9. # /var/log directory
  10. log_src_dir=/var/log
  11. # Rancher config file directory
  12. conf_file_src_dir=/var/lib/rancher/conf
  13. # Os-config directory
  14. os_config_dir=/usr/share/ros/os-config.yml
  15. # Export directory
  16. dest_dir=/tmp/ros
  17. # Exported log directory
  18. dest_log_dir=$dest_dir/roslogs
  19. # Exported config directory
  20. dest_conf_dir=$dest_dir/rosconf
  21. DATE=`date +%Y_%m_%d_%H`
  22. ARCHIVE=$DATE.tar
  23. # Create destination directory
  24. for i in $dest_conf_dir $dest_log_dir; do
  25. if [ ! -d $i ]; then
  26. mkdir -p $i
  27. fi
  28. done
  29. # Hidden ssh-rsa
  30. hiddenSshRsa(){
  31. sed -i 's/ssh-rsa.*$/ssh-rsa .../g' $1
  32. }
  33. # Export /var/log
  34. cp -arf $log_src_dir $dest_log_dir
  35. # Export rancheros config
  36. ros c export -o $dest_conf_dir/ros-config-export.conf
  37. ros -v > $dest_conf_dir/ros-version
  38. uname -r > $dest_conf_dir/kernel-version
  39. system-docker info > $dest_conf_dir/system-docker-info
  40. docker info > $dest_conf_dir/docker-info
  41. cat /proc/mounts > $dest_conf_dir/proc-mounts
  42. cat /proc/1/mounts > $dest_conf_dir/proc-1-mounts
  43. cat /proc/cmdline > $dest_conf_dir/cmdline
  44. dmesg > $dest_conf_dir/dmesg.log
  45. cd $conf_file_src_dir && cp -rf `ls | grep -E -v "^(pem)$"` $dest_conf_dir
  46. cp -arf $os_config_dir $dest_conf_dir
  47. hiddenSshRsa $dest_conf_dir/ros-config-export.conf
  48. if [ -f $dest_conf_dir/metadata ]; then
  49. hiddenSshRsa $dest_conf_dir/metadata
  50. fi
  51. tar -c -f /tmp/rancheros_export_$ARCHIVE -C $dest_dir . >/dev/null 2>&1
  52. echo "*********************************************************"
  53. echo "The RancherOS config and log are successfully exported."
  54. echo "Please check the /tmp/rancheros_export_$ARCHIVE."
  55. echo "*********************************************************"