Skip to content

Commit fd8d4b7

Browse files
authored
Refactor IPv6 handling and enhance MOTD and SSH
Refactor IPv6 handling and update OS function. Enhance MOTD with additional details and configure SSH settings.
1 parent 840347c commit fd8d4b7

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

misc/alpine-install.func

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,19 @@ catch_errors
1515
verb_ip6() {
1616
set_std_mode # Set STD mode based on VERBOSE
1717

18-
if [ "$DISABLEIPV6" == "yes" ]; then
18+
if [ "$IPV6_METHOD" == "disable" ]; then
19+
msg_info "Disabling IPv6 (this may affect some services)"
1920
$STD sysctl -w net.ipv6.conf.all.disable_ipv6=1
20-
echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf
21+
$STD sysctl -w net.ipv6.conf.default.disable_ipv6=1
22+
$STD sysctl -w net.ipv6.conf.lo.disable_ipv6=1
23+
mkdir -p /etc/sysctl.d
24+
$STD tee /etc/sysctl.d/99-disable-ipv6.conf >/dev/null <<EOF
25+
net.ipv6.conf.all.disable_ipv6 = 1
26+
net.ipv6.conf.default.disable_ipv6 = 1
27+
net.ipv6.conf.lo.disable_ipv6 = 1
28+
EOF
2129
$STD rc-update add sysctl default
30+
msg_ok "Disabled IPv6"
2231
fi
2332
}
2433

@@ -109,8 +118,8 @@ network_check() {
109118
# This function updates the Container OS by running apt-get update and upgrade
110119
update_os() {
111120
msg_info "Updating Container OS"
112-
$STD apk update && $STD apk upgrade
113-
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/alpine-tools.func)
121+
$STD apk -U upgrade
122+
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func)
114123
msg_ok "Updated Container OS"
115124
}
116125

@@ -131,15 +140,18 @@ motd_ssh() {
131140
echo "echo -e \"\"" >"$PROFILE_FILE"
132141
echo -e "echo -e \"${BOLD}${APPLICATION} LXC Container${CL}"\" >>"$PROFILE_FILE"
133142
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"
134-
echo -e "echo -e \"${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >>"$PROFILE_FILE"
135-
echo -e "echo -e \"${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE"
136-
echo -e "echo -e \"${YW} IP Address: ${GN}${IP}${CL}\"" >>"$PROFILE_FILE"
137-
echo -e "echo -e \"${YW} Repository: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\"" >>"$PROFILE_FILE"
138143
echo "echo \"\"" >>"$PROFILE_FILE"
144+
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >>"$PROFILE_FILE"
145+
echo -e "echo -e \"${TAB}${HOSTNAME}${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE"
146+
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"
139147

148+
# Configure SSH if enabled
140149
if [[ "${SSH_ROOT}" == "yes" ]]; then
150+
# Enable sshd service
141151
$STD rc-update add sshd
152+
# Allow root login via SSH
142153
sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
154+
# Start the sshd service
143155
$STD /etc/init.d/sshd start
144156
fi
145157
}
@@ -178,4 +190,5 @@ EOF
178190

179191
echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/${app}.sh)\"" >/usr/bin/update
180192
chmod +x /usr/bin/update
193+
181194
}

0 commit comments

Comments
 (0)