devuan-v5-install.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi
  7. silent() { "$@" > /dev/null 2>&1; }
  8. if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi
  9. YW=$(echo "\033[33m")
  10. RD=$(echo "\033[01;31m")
  11. BL=$(echo "\033[36m")
  12. GN=$(echo "\033[1;92m")
  13. CL=$(echo "\033[m")
  14. RETRY_NUM=10
  15. RETRY_EVERY=3
  16. CM="${GN}✓${CL}"
  17. CROSS="${RD}✗${CL}"
  18. BFR="\\r\\033[K"
  19. HOLD="-"
  20. set -Eeuo pipefail
  21. trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
  22. function error_handler() {
  23. local exit_code="$?"
  24. local line_number="$1"
  25. local command="$2"
  26. local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
  27. echo -e "\n$error_message\n"
  28. }
  29. function msg_info() {
  30. local msg="$1"
  31. echo -ne " ${HOLD} ${YW}${msg}..."
  32. }
  33. function msg_ok() {
  34. local msg="$1"
  35. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  36. }
  37. function msg_error() {
  38. local msg="$1"
  39. echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
  40. }
  41. msg_info "Setting up Container OS"
  42. for ((i=RETRY_NUM; i>0; i--)); do
  43. if [ "$(hostname -I)" != "" ]; then
  44. break
  45. fi
  46. echo 1>&2 -en "${CROSS}${RD} No Network! "
  47. sleep $RETRY_EVERY
  48. done
  49. if [ "$(hostname -I)" = "" ]; then
  50. echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
  51. echo -e " 🖧 Check Network Settings"
  52. exit 1
  53. fi
  54. msg_ok "Set up Container OS"
  55. msg_ok "Network Connected: ${BL}$(hostname -I)"
  56. set +e
  57. if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else
  58. msg_error "Internet NOT Connected"
  59. read -r -p "Would you like to continue anyway? <y/N> " prompt
  60. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  61. echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}"
  62. else
  63. echo -e " 🖧 Check Network Settings"
  64. exit 1
  65. fi
  66. fi
  67. RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }')
  68. if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi
  69. set -e
  70. msg_info "Updating Container OS"
  71. $STD apt-get update
  72. $STD apt-get -y upgrade
  73. msg_ok "Updated Container OS"
  74. msg_info "Installing Dependencies"
  75. $STD apt-get install -y curl
  76. $STD apt-get install -y sudo
  77. $STD apt-get install -y mc
  78. msg_ok "Installed Dependencies"
  79. echo "export TERM='xterm-256color'" >>/root/.bashrc
  80. echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd
  81. chmod -x /etc/update-motd.d/*
  82. if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi
  83. msg_info "Cleaning up"
  84. $STD apt-get autoremove
  85. $STD apt-get autoclean
  86. msg_ok "Cleaned"