indentation

This commit is contained in:
tteckster 2023-03-22 14:59:10 -04:00 committed by GitHub
parent 602d4496f8
commit 38381bb6ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 36 deletions

View File

@ -16,9 +16,15 @@ color() {
} }
verb_ip6() { verb_ip6() {
if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi if [ "$VERBOSE" = "yes" ]; then
silent() { "$@" > /dev/null 2>&1; } set -x
if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi STD=""
else STD="silent"; fi
silent() { "$@" >/dev/null 2>&1; }
if [ "$DISABLEIPV6" == "yes" ]; then
echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf
$STD sysctl -p
fi
} }
catch_errors() { catch_errors() {
@ -51,21 +57,21 @@ msg_error() {
setting_up_container() { setting_up_container() {
msg_info "Setting up Container OS" msg_info "Setting up Container OS"
while [ $i -gt 0 ]; do while [ $i -gt 0 ]; do
if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then
break break
fi fi
echo 1>&2 -en "${CROSS}${RD} No Network! " echo 1>&2 -en "${CROSS}${RD} No Network! "
sleep $RETRY_EVERY sleep $RETRY_EVERY
i=$((i-1)) i=$((i - 1))
done done
if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then
echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
echo -e " 🖧 Check Network Settings" echo -e " 🖧 Check Network Settings"
exit 1 exit 1
fi fi
cat <<EOF >/etc/apk/repositories cat <<EOF >/etc/apk/repositories
https://dl-cdn.alpinelinux.org/alpine/edge/main https://dl-cdn.alpinelinux.org/alpine/edge/main
https://dl-cdn.alpinelinux.org/alpine/edge/community https://dl-cdn.alpinelinux.org/alpine/edge/community
https://dl-cdn.alpinelinux.org/alpine/edge/testing https://dl-cdn.alpinelinux.org/alpine/edge/testing
@ -77,7 +83,7 @@ EOF
network_check() { network_check() {
set +e set +e
trap - ERR trap - ERR
if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else if ping -c 1 -W 1 1.1.1.1 &>/dev/null; then msg_ok "Internet Connected"; else
msg_error "Internet NOT Connected" msg_error "Internet NOT Connected"
read -r -p "Would you like to continue anyway? <y/N> " prompt read -r -p "Would you like to continue anyway? <y/N> " prompt
if echo "$prompt" | grep -Eq "^(y|yes)$"; then if echo "$prompt" | grep -Eq "^(y|yes)$"; then
@ -101,7 +107,10 @@ update_os() {
} }
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
if [[ "${SSH_ROOT}" == "yes" ]]; then $STD rc-update add sshd; $STD /etc/init.d/sshd start; fi if [[ "${SSH_ROOT}" == "yes" ]]; then
} $STD rc-update add sshd
$STD /etc/init.d/sshd start
fi
}

View File

@ -15,9 +15,15 @@ color() {
} }
verb_ip6() { verb_ip6() {
if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi if [ "$VERBOSE" = "yes" ]; then
silent() { "$@" > /dev/null 2>&1; } set -x
if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi STD=""
else STD="silent"; fi
silent() { "$@" >/dev/null 2>&1; }
if [ "$DISABLEIPV6" == "yes" ]; then
echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf
$STD sysctl -p
fi
} }
catch_errors() { catch_errors() {
@ -52,14 +58,14 @@ 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
locale-gen >/dev/null locale-gen >/dev/null
echo $tz > /etc/timezone echo $tz >/etc/timezone
ln -sf /usr/share/zoneinfo/$tz /etc/localtime ln -sf /usr/share/zoneinfo/$tz /etc/localtime
for ((i=RETRY_NUM; i>0; i--)); do for ((i = RETRY_NUM; i > 0; i--)); do
if [ "$(hostname -I)" != "" ]; then if [ "$(hostname -I)" != "" ]; then
break break
fi fi
echo 1>&2 -en "${CROSS}${RD} No Network! " echo 1>&2 -en "${CROSS}${RD} No Network! "
sleep $RETRY_EVERY sleep $RETRY_EVERY
done done
if [ "$(hostname -I)" = "" ]; then if [ "$(hostname -I)" = "" ]; then
echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
@ -73,7 +79,7 @@ setting_up_container() {
network_check() { network_check() {
set +e set +e
trap - ERR trap - ERR
if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else if ping -c 1 -W 1 1.1.1.1 &>/dev/null; then msg_ok "Internet Connected"; else
msg_error "Internet NOT Connected" msg_error "Internet NOT Connected"
read -r -p "Would you like to continue anyway? <y/N> " prompt read -r -p "Would you like to continue anyway? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
@ -97,10 +103,13 @@ update_os() {
} }
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
chmod -x /etc/update-motd.d/* chmod -x /etc/update-motd.d/*
if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi if [[ "${SSH_ROOT}" == "yes" ]]; then
sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
systemctl restart sshd
fi
} }
customize() { customize() {
@ -119,6 +128,6 @@ EOF
root() { root() {
if ! getent shadow root | grep -q "^root:[^\!*]"; then if ! getent shadow root | grep -q "^root:[^\!*]"; then
customize customize
fi fi
} }