Skip to content

Commit 10d4ce4

Browse files
authored
Verbose_Update (#2583)
1 parent 35f635b commit 10d4ce4

File tree

3 files changed

+218
-124
lines changed

3 files changed

+218
-124
lines changed

misc/alpine-install.func

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ color() {
1818
BFR="\\r\\033[K"
1919
BOLD=$(echo "\033[1m")
2020
TAB=" "
21-
21+
2222
# System
2323
RETRY_NUM=10
2424
RETRY_EVERY=3
@@ -36,12 +36,24 @@ color() {
3636
DEFAULT="${TAB}⚙️${TAB}${CL}"
3737
}
3838

39-
# This function enables IPv6 if it's not disabled and sets verbose mode if the global variable is set to "yes"
40-
verb_ip6() {
39+
# Function to set STD mode based on verbosity
40+
set_std_mode() {
4141
if [ "$VERBOSE" = "yes" ]; then
4242
STD=""
43-
else STD="silent"; fi
44-
silent() { "$@" >/dev/null 2>&1; }
43+
else
44+
STD="silent"
45+
fi
46+
}
47+
48+
# Silent execution function
49+
silent() {
50+
"$@" >/dev/null 2>&1
51+
}
52+
53+
# This function enables IPv6 if it's not disabled and sets verbose mode
54+
verb_ip6() {
55+
set_std_mode # Set STD mode based on VERBOSE
56+
4557
if [ "$DISABLEIPV6" == "yes" ]; then
4658
$STD sysctl -w net.ipv6.conf.all.disable_ipv6=1
4759
echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf
@@ -107,15 +119,15 @@ setting_up_container() {
107119
network_check() {
108120
set +e
109121
trap - ERR
110-
if ping -c 1 -W 1 1.1.1.1 &>/dev/null || ping -c 1 -W 1 8.8.8.8 &>/dev/null || ping -c 1 -W 1 9.9.9.9 &>/dev/null; then
111-
msg_ok "Internet Connected";
122+
if ping -c 1 -W 1 1.1.1.1 &>/dev/null || ping -c 1 -W 1 8.8.8.8 &>/dev/null || ping -c 1 -W 1 9.9.9.9 &>/dev/null; then
123+
msg_ok "Internet Connected"
112124
else
113125
msg_error "Internet NOT Connected"
114126
read -r -p "Would you like to continue anyway? <y/N> " prompt
115127
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
116128
echo -e "${INFO}${RD}Expect Issues Without Internet${CL}"
117129
else
118-
echo -e "${NETWORK}Check Network Settings"
130+
echo -e "${NETWORK}Check Network Settings"
119131
exit 1
120132
fi
121133
fi
@@ -148,13 +160,13 @@ motd_ssh() {
148160
fi
149161

150162
PROFILE_FILE="/etc/profile.d/00_lxc-details.sh"
151-
echo "echo -e \"\"" > "$PROFILE_FILE"
152-
echo -e "echo -e \"${BOLD}${APPLICATION} LXC Container${CL}"\" >> "$PROFILE_FILE"
153-
echo -e "echo -e \"${TAB}${GATEWAY}${YW} Provided by: ${GN}community-scripts ORG ${YW}| GitHub: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\"" >> "$PROFILE_FILE"
154-
echo "echo \"\"" >> "$PROFILE_FILE"
155-
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >> "$PROFILE_FILE"
156-
echo -e "echo -e \"${TAB}${HOSTNAME}${YW} Hostname: ${GN}\$(hostname)${CL}\"" >> "$PROFILE_FILE"
157-
echo -e "echo -e \"${TAB}${INFO}${YW} IP Address: ${GN}\$(ip -4 addr show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 | head -n 1)${CL}\"" >> "$PROFILE_FILE"
163+
echo "echo -e \"\"" >"$PROFILE_FILE"
164+
echo -e "echo -e \"${BOLD}${APPLICATION} LXC Container${CL}"\" >>"$PROFILE_FILE"
165+
echo -e "echo -e \"${TAB}${GATEWAY}${YW} Provided by: ${GN}community-scripts ORG ${YW}| GitHub: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\"" >>"$PROFILE_FILE"
166+
echo "echo \"\"" >>"$PROFILE_FILE"
167+
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >>"$PROFILE_FILE"
168+
echo -e "echo -e \"${TAB}${HOSTNAME}${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE"
169+
echo -e "echo -e \"${TAB}${INFO}${YW} IP Address: ${GN}\$(ip -4 addr show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 | head -n 1)${CL}\"" >>"$PROFILE_FILE"
158170

159171
# Configure SSH if enabled
160172
if [[ "${SSH_ROOT}" == "yes" ]]; then
@@ -170,8 +182,8 @@ motd_ssh() {
170182
# This function customizes the container and enables passwordless login for the root user
171183
customize() {
172184
if [[ "$PASSWORD" == "" ]]; then
173-
msg_info "Customizing Container"
174-
bash -c "passwd -d root" >/dev/null 2>&1
175-
msg_ok "Customized Container"
185+
msg_info "Customizing Container"
186+
bash -c "passwd -d root" >/dev/null 2>&1
187+
msg_ok "Customized Container"
176188
fi
177-
}
189+
}

0 commit comments

Comments
 (0)