-
-
Notifications
You must be signed in to change notification settings - Fork 807
install.func ‐ script function explanations
CanbiZ edited this page Jan 17, 2025
·
1 revision
Purpose: Sets up various color and formatting variables for terminal output.
- Defines colors like yellow (
YW
), green (GN
), and red (RD
) using ANSI escape codes for text formatting. - Also defines icons for different types of output, such as checkmarks (
CM
), error crosses (CROSS
), and network-related icons (NETWORK
,GATEWAY
).
color
echo -e "${GN}Success${CL}" # Output: Green colored "Success"
echo -e "${NETWORK}Network${CL}" # Network icon followed by text "Network"
Purpose: Enables or disables IPv6 based on the DISABLEIPV6
variable and sets the verbose mode.
- Disables IPv6 by adding a line to
/etc/sysctl.conf
ifDISABLEIPV6
is set toyes
. - Optionally suppresses output based on the
VERBOSE
variable.
DISABLEIPV6="yes"
verb_ip6 # Disables IPv6 if the variable is set
Purpose: Sets up error handling for the script.
- Configures the script to exit immediately on errors using
set -Eeuo pipefail
. - Defines a trap that calls
error_handler()
when an error occurs.
catch_errors
ls non_existent_file # This will trigger the error handler
Purpose: Handles errors that occur during script execution.
- Stops the spinner if it's running.
- Prints the error message with details like the exit code, line number, and the command that failed.
error_handler 42 "ls non_existent_file"
# Output: [ERROR] in line 42: exit code 2: while executing command "ls non_existent_file"
Purpose: Displays a rotating spinner animation.
- Uses a set of frames to create a spinning effect in the terminal.
spinner # Starts the spinner animation
Purpose: Displays messages with different statuses.
-
msg_info()
: Displays an informational message with a spinner animation. -
msg_ok()
: Displays a success message and stops the spinner. -
msg_error()
: Displays an error message and stops the spinner.
msg_info "This is an informational message"
msg_ok "Success!"
msg_error "An error occurred"
Purpose: Sets up the container OS, configures locale, timezone, and network.
- Modifies
/etc/locale.gen
to enable the correct locale. - Configures timezone and network, retrying network configuration if necessary.
setting_up_container # Configures OS, locale, timezone, and network
Purpose: Verifies internet connectivity via IPv4 and IPv6.
- Checks IPv4 connectivity to Google, Cloudflare, and Quad9 DNS servers.
- Checks IPv6 connectivity and performs DNS lookup for
github.com
.
network_check # Verifies internet connectivity
Purpose: Updates the container's OS using apt-get update
and apt-get dist-upgrade
.
- If
CACHER
is enabled, it configures a proxy for package fetching. - Runs system update and upgrades all installed packages.
update_os # Updates the container's OS
Purpose: Modifies the message of the day (MOTD) and SSH settings.
- Sets terminal to 256-color mode and updates
/etc/motd
with system information. - Configures SSH settings to allow root login if enabled.
motd_ssh # Modifies MOTD and SSH settings
Purpose: Customizes the container by enabling auto-login and setting up SSH keys.
- If no password is provided, it enables auto-login for the root user.
- Optionally configures SSH by adding the provided public key to the root user.
customize # Customizes the container with auto-login and SSH key setup