Update install.func

added code descriptions
This commit is contained in:
tteckster 2023-05-15 18:33:04 -04:00 committed by GitHub
parent 287a0837d3
commit 9192b8b076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -1,3 +1,4 @@
# This function sets color variables for formatting output in the terminal
color() { color() {
YW=$(echo "\033[33m") YW=$(echo "\033[33m")
BL=$(echo "\033[36m") BL=$(echo "\033[36m")
@ -14,6 +15,7 @@ color() {
HOLD="-" HOLD="-"
} }
# This function enables IPv6 if it's not disabled and sets verbose mode if the global variable is set to "yes"
verb_ip6() { verb_ip6() {
if [ "$VERBOSE" = "yes" ]; then if [ "$VERBOSE" = "yes" ]; then
set -x set -x
@ -26,11 +28,13 @@ verb_ip6() {
fi fi
} }
# This function sets error handling options and defines the error_handler function to handle errors
catch_errors() { catch_errors() {
set -Eeuo pipefail set -Eeuo pipefail
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
} }
# This function handles errors
error_handler() { error_handler() {
local exit_code="$?" local exit_code="$?"
local line_number="$1" local line_number="$1"
@ -42,21 +46,25 @@ error_handler() {
fi fi
} }
# This function prints an informational message
msg_info() { msg_info() {
local msg="$1" local msg="$1"
echo -ne " ${HOLD} ${YW}${msg}..." echo -ne " ${HOLD} ${YW}${msg}..."
} }
# This function prints a success message
msg_ok() { msg_ok() {
local msg="$1" local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}" echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
} }
# This function prints an error message
msg_error() { msg_error() {
local msg="$1" local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
} }
# This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection
setting_up_container() { setting_up_container() {
msg_info "Setting up Container OS" msg_info "Setting up Container OS"
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
@ -79,6 +87,7 @@ setting_up_container() {
msg_ok "Network Connected: ${BL}$(hostname -I)" msg_ok "Network Connected: ${BL}$(hostname -I)"
} }
# This function checks the network connection by pinging a known IP address and prompts the user to continue if the internet is not connected
network_check() { network_check() {
set +e set +e
trap - ERR trap - ERR
@ -98,6 +107,7 @@ network_check() {
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
} }
# This function updates the Container OS by running apt-get update and upgrade
update_os() { update_os() {
msg_info "Updating Container OS" msg_info "Updating Container OS"
$STD apt-get update $STD apt-get update
@ -105,6 +115,7 @@ update_os() {
msg_ok "Updated Container OS" msg_ok "Updated Container OS"
} }
# This function modifies the message of the day (motd) and SSH settings
motd_ssh() { motd_ssh() {
echo "export TERM='xterm-256color'" >>/root/.bashrc echo "export TERM='xterm-256color'" >>/root/.bashrc
echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" >/etc/motd echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" >/etc/motd
@ -115,6 +126,7 @@ motd_ssh() {
fi fi
} }
# This function customizes the container by modifying the getty service and enabling auto-login for the root user
customize() { customize() {
if [[ "$PASSWORD" == "" ]]; then if [[ "$PASSWORD" == "" ]]; then
msg_info "Customizing Container" msg_info "Customizing Container"