Advertisement
Guest User

Untitled

a guest
Dec 8th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. #!/bin/bash
  2. ##OPEN AS ROOT##
  3. apt-get update
  4. apt-get -y upgrade
  5. apt-get -y install figlet openssh-server fortune bash-completion
  6. ##### update-motd #####
  7. mkdir -p /etc/update-motd.d
  8. cat > /etc/update-motd.d/10uname <<EOF
  9. #!/bin/sh
  10. uname -snrvm
  11. EOF
  12. cat > /etc/update-motd.d/11headers <<EOF
  13. #!/bin/sh
  14. #
  15. # 00-header - create the header of the MOTD
  16. # Copyright (c) 2013 Nick Charlton
  17. # Copyright (c) 2009-2010 Canonical Ltd.
  18. #
  19. # Authors: Nick Charlton <hello@nickcharlton.net>
  20. # Dustin Kirkland <kirkland@canonical.com>
  21. #
  22. # This program is free software; you can redistribute it and/or modify
  23. # it under the terms of the GNU General Public License as published by
  24. # the Free Software Foundation; either version 2 of the License, or
  25. # (at your option) any later version.
  26. #
  27. # This program is distributed in the hope that it will be useful,
  28. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. # GNU General Public License for more details.
  31. #
  32. # You should have received a copy of the GNU General Public License along
  33. # with this program; if not, write to the Free Software Foundation, Inc.,
  34. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  35.  
  36. [ -r /etc/lsb-release ] && . /etc/lsb-release
  37.  
  38. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  39. # Fall back to using the very slow lsb_release utility
  40. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  41. fi
  42.  
  43. figlet $(hostname)
  44. printf "\n"
  45.  
  46. printf "Welcome to %s (%s).\n" "$DISTRIB_DESCRIPTION" "$(uname -r)"
  47. printf "\n"
  48. EOF
  49. cat > /etc/update-motd.d/12sysinfo <<EOF
  50. #!/bin/bash
  51. #
  52. # 10-sysinfo - generate the system information
  53. # Copyright (c) 2013 Nick Charlton
  54. #
  55. # Authors: Nick Charlton <hello@nickcharlton.net>
  56. #
  57. # This program is free software; you can redistribute it and/or modify
  58. # it under the terms of the GNU General Public License as published by
  59. # the Free Software Foundation; either version 2 of the License, or
  60. # (at your option) any later version.
  61. #
  62. # This program is distributed in the hope that it will be useful,
  63. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  64. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  65. # GNU General Public License for more details.
  66. #
  67. # You should have received a copy of the GNU General Public License along
  68. # with this program; if not, write to the Free Software Foundation, Inc.,
  69. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  70.  
  71. date=`date`
  72. load=`cat /proc/loadavg | awk '{print $1}'`
  73. root_usage=`df -h / | awk '/\// {print $(NF-1)}'`
  74. memory_usage=`free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'`
  75. swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", "exit !$2;$3/$2*100") }'`
  76. users=`users | wc -w`
  77. time=`uptime | grep -ohe 'up .*' | sed 's/,/\ hours/g' | awk '{ printf $2" "$3 }'`
  78. processes=`ps aux | wc -l`
  79. ip=`ifconfig $(route | grep default | awk '{ print $8 }') | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`
  80.  
  81. echo "System information as of: $date"
  82. echo
  83. printf "System load:\t%s\tIP Address:\t%s\n" $load $ip
  84. printf "Memory usage:\t%s\tSystem uptime:\t%s\n" $memory_usage "$time"
  85. printf "Usage on /:\t%s\tSwap usage:\t%s\n" $root_usage $swap_usage
  86. printf "Local Users:\t%s\tProcesses:\t%s\n" $users $processes
  87. echo
  88. EOF
  89. cat > /etc/update-motd.d/20footer <<EOF
  90. #!/bin/sh
  91. #
  92. # 90-footer - write the admin's footer to the MOTD
  93. # Copyright (c) 2013 Nick Charlton
  94. # Copyright (c) 2009-2010 Canonical Ltd.
  95. #
  96. # Authors: Nick Charlton <hello@nickcharlton.net>
  97. # Dustin Kirkland <kirkland@canonical.com>
  98. #
  99. # This program is free software; you can redistribute it and/or modify
  100. # it under the terms of the GNU General Public License as published by
  101. # the Free Software Foundation; either version 2 of the License, or
  102. # (at your option) any later version.
  103. #
  104. # This program is distributed in the hope that it will be useful,
  105. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  106. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  107. # GNU General Public License for more details.
  108. #
  109. # You should have received a copy of the GNU General Public License along
  110. # with this program; if not, write to the Free Software Foundation, Inc.,
  111. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  112.  
  113. [ -f /etc/motd.tail ] && cat /etc/motd.tail || true
  114. EOF
  115. chmod a+x /etc/update-motd.d/*
  116. [ -f /etc/motd.tail ] && mv /etc/motd /etc/motd.old
  117. ln -s /var/run/motd /etc/motd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement