Update install.func
added code descriptions
This commit is contained in:
parent
287a0837d3
commit
9192b8b076
1 changed files with 13 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
# This function sets color variables for formatting output in the terminal
|
||||
color() {
|
||||
YW=$(echo "\033[33m")
|
||||
BL=$(echo "\033[36m")
|
||||
|
@ -14,6 +15,7 @@ color() {
|
|||
HOLD="-"
|
||||
}
|
||||
|
||||
# This function enables IPv6 if it's not disabled and sets verbose mode if the global variable is set to "yes"
|
||||
verb_ip6() {
|
||||
if [ "$VERBOSE" = "yes" ]; then
|
||||
set -x
|
||||
|
@ -26,11 +28,13 @@ verb_ip6() {
|
|||
fi
|
||||
}
|
||||
|
||||
# This function sets error handling options and defines the error_handler function to handle errors
|
||||
catch_errors() {
|
||||
set -Eeuo pipefail
|
||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||
}
|
||||
|
||||
# This function handles errors
|
||||
error_handler() {
|
||||
local exit_code="$?"
|
||||
local line_number="$1"
|
||||
|
@ -42,21 +46,25 @@ error_handler() {
|
|||
fi
|
||||
}
|
||||
|
||||
# This function prints an informational message
|
||||
msg_info() {
|
||||
local msg="$1"
|
||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
||||
}
|
||||
|
||||
# This function prints a success message
|
||||
msg_ok() {
|
||||
local msg="$1"
|
||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||
}
|
||||
|
||||
# This function prints an error message
|
||||
msg_error() {
|
||||
local msg="$1"
|
||||
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() {
|
||||
msg_info "Setting up Container OS"
|
||||
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
|
||||
|
@ -79,6 +87,7 @@ setting_up_container() {
|
|||
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() {
|
||||
set +e
|
||||
trap - ERR
|
||||
|
@ -98,6 +107,7 @@ network_check() {
|
|||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||
}
|
||||
|
||||
# This function updates the Container OS by running apt-get update and upgrade
|
||||
update_os() {
|
||||
msg_info "Updating Container OS"
|
||||
$STD apt-get update
|
||||
|
@ -105,6 +115,7 @@ update_os() {
|
|||
msg_ok "Updated Container OS"
|
||||
}
|
||||
|
||||
# This function modifies the message of the day (motd) and SSH settings
|
||||
motd_ssh() {
|
||||
echo "export TERM='xterm-256color'" >>/root/.bashrc
|
||||
echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" >/etc/motd
|
||||
|
@ -115,6 +126,7 @@ motd_ssh() {
|
|||
fi
|
||||
}
|
||||
|
||||
# This function customizes the container by modifying the getty service and enabling auto-login for the root user
|
||||
customize() {
|
||||
if [[ "$PASSWORD" == "" ]]; then
|
||||
msg_info "Customizing Container"
|
||||
|
|
Loading…
Reference in a new issue