Update function.sh

This commit is contained in:
tteckster 2023-03-20 21:31:42 -04:00 committed by GitHub
parent 76fb7ceffb
commit 1410656586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 43 additions and 15 deletions

View File

@ -1,3 +1,16 @@
color() {
YW=$(echo "\033[33m")
RD=$(echo "\033[01;31m")
BL=$(echo "\033[36m")
GN=$(echo "\033[1;92m")
CL=$(echo "\033[m")
RETRY_NUM=10
RETRY_EVERY=3
CM="${GN}${CL}"
CROSS="${RD}${CL}"
BFR="\\r\\033[K"
HOLD="-"
}
error_handler() { error_handler() {
local exit_code="$?" local exit_code="$?"
@ -58,22 +71,25 @@ install_script() {
} }
setting_up_container() { setting_up_container() {
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen msg_info "Setting up Container OS"
locale-gen >/dev/null sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
echo $tz > /etc/timezone locale-gen >/dev/null
ln -sf /usr/share/zoneinfo/$tz /etc/localtime echo $tz > /etc/timezone
for ((i=RETRY_NUM; i>0; i--)); do ln -sf /usr/share/zoneinfo/$tz /etc/localtime
if [ "$(hostname -I)" != "" ]; then for ((i=RETRY_NUM; i>0; i--)); do
break if [ "$(hostname -I)" != "" ]; then
fi break
echo 1>&2 -en "${CROSS}${RD} No Network! "
sleep $RETRY_EVERY
done
if [ "$(hostname -I)" = "" ]; then
echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
echo -e " 🖧 Check Network Settings"
exit 1
fi fi
echo 1>&2 -en "${CROSS}${RD} No Network! "
sleep $RETRY_EVERY
done
if [ "$(hostname -I)" = "" ]; then
echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
echo -e " 🖧 Check Network Settings"
exit 1
fi
msg_ok "Set up Container OS"
msg_ok "Network Connected: ${BL}$(hostname -I)"
} }
network_ckeck() { network_ckeck() {
@ -94,6 +110,18 @@ network_ckeck() {
set -e set -e
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
} }
update_os() {
msg_info "Updating Container OS"
$STD apt-get update
$STD apt-get -y upgrade
msg_ok "Updated Container OS"
}
motd() {
echo "export TERM='xterm-256color'" >>/root/.bashrc
echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd
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
}
customize() { customize() {
msg_info "Customizing Container" msg_info "Customizing Container"