This commit is contained in:
pika 2025-05-19 10:12:38 +02:00
parent d389b5eef1
commit 470c36fc4f

View file

@ -155,7 +155,7 @@ checkAndInstall() {
} }
# ─< Check if the user is root and set sudo variable if necessary >─────────────────────── # ─< Check if the user is root and set sudo variable if necessary >───────────────────────
check_root() { check_env() {
if [ "$(id -u)" -ne 0 ]; then if [ "$(id -u)" -ne 0 ]; then
if command_exists sudo; then if command_exists sudo; then
echo_info "User is not root. Using sudo for privileged operations." echo_info "User is not root. Using sudo for privileged operations."
@ -168,6 +168,12 @@ check_root() {
echo_info "Root access confirmed." echo_info "Root access confirmed."
_sudo="" _sudo=""
fi fi
pikaCheckFile="$HOME/.cache/pika_script_detection"
if [ -e "$pikaCheckFile" ]; then
PIKA_INIT=true
fi
} }
_setup() { _setup() {
@ -396,18 +402,19 @@ update_package_list() {
alpine) run $_sudo apk update ;; alpine) run $_sudo apk update ;;
*) echo_error "Unsupported distribution: ${BRIGHT_RED}$distro" ;; *) echo_error "Unsupported distribution: ${BRIGHT_RED}$distro" ;;
esac esac
} }
if check_root; then if check_env; then
get_packager get_packager
dist_setup dist_setup
if [[ -z "$PIKA_INIT" ]]; then if [[ -z "$PIKA_INIT" ]]; then
echo_info "First time being imported.." echo_pkg "First time being imported.."
export PIKA_INIT=true touch "$pikaCheckFile"
update_package_list update_package_list
else
echo_note "Skipping repo refresh (PIKA_INIT is already set)"
fi fi
fi fi