Files
DynastyRevolution-Scripts/core/install.func

62 lines
1.1 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
BLUE='\033[38;5;45m'
PURPLE='\033[38;5;127m'
GOLD='\033[38;5;178m'
RED='\033[38;5;196m'
NC='\033[0m'
BFR='\r\033[K'
catch_errors_lxc() {
set -Eeuo pipefail
trap 'echo "1" > /root/.install-${SESSION_ID:-unknown}.failed; exit 1' ERR
}
msg_info() {
local msg="$1"
echo -ne " ${BLUE} ${msg}${NC}"
}
msg_ok() {
local msg="$1"
echo -e "${BFR} ${GOLD}${msg}${NC}"
}
msg_error() {
local msg="$1"
echo -e "${BFR} ${RED}${msg}${NC}"
}
set_std_mode() {
if [[ "${VERBOSE:-no}" == "yes" ]]; then
export STD=""
else
export STD="&>/dev/null"
fi
}
update_os() {
msg_info "Updating Container Core"
if [[ "${PCT_OSTYPE}" == "alpine" ]]; then
apk update $STD
apk upgrade $STD
else
apt-get update $STD
apt-get -y upgrade $STD
fi
msg_ok "Container Core Updated"
}
cleanup_lxc() {
msg_info "Finalizing Stance"
if [[ "${PCT_OSTYPE}" == "alpine" ]]; then
apk cache clean $STD
else
apt-get -y autoremove $STD
apt-get -y autoclean $STD
fi
rm -rf /tmp/*
msg_ok "Stance Manifested"
}
catch_errors_lxc