fix(start.sh): remove snap and rogue local keyword, streamline fast portable scrcpy fallback
This commit is contained in:
1 parent
2e66ac5b8a
commit
739c1c2909
2 files changed
+12
-27
No files matched your search
+6
-14
@@ -231,34 +231,26 @@ install_system_packages() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if has_cmd apt-get; then
|
if has_cmd apt-get; then
|
||||||
echo -e " ${CYAN}Detected Debian/Ubuntu (apt-get). Synchronizing and installing...${NC}"
|
echo -e " ${CYAN}Detected Debian/Ubuntu (apt-get). Installing missing packages...${NC}"
|
||||||
${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=5 update -qq 2>/dev/null || true
|
DEBIAN_FRONTEND=noninteractive ${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=3 -o Acquire::http::Timeout=3 -o Acquire::https::Timeout=3 install -y "${PKGS[@]}" 2>/dev/null || true
|
||||||
${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=5 install -y "${PKGS[@]}" 2>/dev/null || true
|
|
||||||
elif has_cmd dnf; then
|
elif has_cmd dnf; then
|
||||||
echo -e " ${CYAN}Detected Fedora/RHEL (dnf). Installing packages...${NC}"
|
echo -e " ${CYAN}Detected Fedora/RHEL (dnf). Installing packages...${NC}"
|
||||||
local DNF_PKGS=()
|
local DNF_PKGS=()
|
||||||
[ "${need_adb}" = true ] && DNF_PKGS+=("android-tools")
|
[ "${need_adb}" = true ] && DNF_PKGS+=("android-tools")
|
||||||
[ "${need_ffmpeg}" = true ] && DNF_PKGS+=("ffmpeg")
|
[ "${need_ffmpeg}" = true ] && DNF_PKGS+=("ffmpeg")
|
||||||
[ "${need_scrcpy}" = true ] && DNF_PKGS+=("scrcpy")
|
[ "${need_scrcpy}" = true ] && DNF_PKGS+=("scrcpy")
|
||||||
${SUDO_PREFIX} dnf install -y "${DNF_PKGS[@]}" || true
|
${SUDO_PREFIX} dnf install -y "${DNF_PKGS[@]}" 2>/dev/null || true
|
||||||
elif has_cmd pacman; then
|
elif has_cmd pacman; then
|
||||||
echo -e " ${CYAN}Detected Arch Linux (pacman). Installing packages...${NC}"
|
echo -e " ${CYAN}Detected Arch Linux (pacman). Installing packages...${NC}"
|
||||||
local PAC_PKGS=()
|
local PAC_PKGS=()
|
||||||
[ "${need_adb}" = true ] && PAC_PKGS+=("android-tools")
|
[ "${need_adb}" = true ] && PAC_PKGS+=("android-tools")
|
||||||
[ "${need_ffmpeg}" = true ] && PAC_PKGS+=("ffmpeg")
|
[ "${need_ffmpeg}" = true ] && PAC_PKGS+=("ffmpeg")
|
||||||
[ "${need_scrcpy}" = true ] && PAC_PKGS+=("scrcpy")
|
[ "${need_scrcpy}" = true ] && PAC_PKGS+=("scrcpy")
|
||||||
${SUDO_PREFIX} pacman -S --noconfirm "${PAC_PKGS[@]}" || true
|
${SUDO_PREFIX} pacman -S --noconfirm "${PAC_PKGS[@]}" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fallback: if scrcpy is still missing, try snap or install portable scrcpy in user space
|
# Fallback: if scrcpy is still missing, install official precompiled portable scrcpy in user space
|
||||||
if ! has_cmd scrcpy; then
|
|
||||||
if has_cmd snap && request_sudo "install scrcpy via snap"; then
|
|
||||||
local SUDO_PREFIX=""
|
|
||||||
if [ "$(id -u)" -ne 0 ]; then SUDO_PREFIX="sudo"; fi
|
|
||||||
${SUDO_PREFIX} snap install scrcpy 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if ! has_cmd scrcpy; then
|
if ! has_cmd scrcpy; then
|
||||||
local SCRCPY_ARCH=""
|
local SCRCPY_ARCH=""
|
||||||
case "${ARCH_TYPE}" in
|
case "${ARCH_TYPE}" in
|
||||||
@@ -271,7 +263,7 @@ install_system_packages() {
|
|||||||
echo -e " ${CYAN}📦 Installing portable scrcpy in user space (~/.local)...${NC}"
|
echo -e " ${CYAN}📦 Installing portable scrcpy in user space (~/.local)...${NC}"
|
||||||
mkdir -p "${SCRCPY_DIR}" "${HOME}/.local/bin"
|
mkdir -p "${SCRCPY_DIR}" "${HOME}/.local/bin"
|
||||||
local SCRCPY_URL="https://github.com/Genymobile/scrcpy/releases/download/v4.1/scrcpy-linux-${SCRCPY_ARCH}-v4.1.tar.gz"
|
local SCRCPY_URL="https://github.com/Genymobile/scrcpy/releases/download/v4.1/scrcpy-linux-${SCRCPY_ARCH}-v4.1.tar.gz"
|
||||||
if curl -fsSL "${SCRCPY_URL}" | tar -xz -C "${SCRCPY_DIR}" --strip-components=1 2>/dev/null; then
|
if curl -fsSL --connect-timeout 5 --max-time 30 "${SCRCPY_URL}" | tar -xz -C "${SCRCPY_DIR}" --strip-components=1 2>/dev/null; then
|
||||||
ln -sf "${SCRCPY_DIR}/scrcpy" "${HOME}/.local/bin/scrcpy"
|
ln -sf "${SCRCPY_DIR}/scrcpy" "${HOME}/.local/bin/scrcpy"
|
||||||
export PATH="${SCRCPY_DIR}:${PATH}"
|
export PATH="${SCRCPY_DIR}:${PATH}"
|
||||||
echo -e " ${GREEN}✓ scrcpy installed in user space.${NC}"
|
echo -e " ${GREEN}✓ scrcpy installed in user space.${NC}"
|
||||||
|
|||||||
@@ -178,23 +178,16 @@ if [ ${#MISSING_CORE[@]} -gt 0 ]; then
|
|||||||
SUDO_PREFIX=""
|
SUDO_PREFIX=""
|
||||||
if [ "$(id -u)" -ne 0 ]; then SUDO_PREFIX="sudo"; fi
|
if [ "$(id -u)" -ne 0 ]; then SUDO_PREFIX="sudo"; fi
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=5 update -qq 2>/dev/null || true
|
echo -e " ${CYAN}📦 Installing missing packages (${MISSING_CORE[*]}) via apt-get...${NC}"
|
||||||
${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=5 install -y -qq "${MISSING_CORE[@]}" 2>/dev/null || true
|
DEBIAN_FRONTEND=noninteractive ${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=3 -o Acquire::http::Timeout=3 -o Acquire::https::Timeout=3 install -y -qq "${MISSING_CORE[@]}" 2>/dev/null || true
|
||||||
elif command -v dnf >/dev/null 2>&1; then
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
${SUDO_PREFIX} dnf install -y "${MISSING_CORE[@]}" || true
|
${SUDO_PREFIX} dnf install -y "${MISSING_CORE[@]}" 2>/dev/null || true
|
||||||
elif command -v pacman >/dev/null 2>&1; then
|
elif command -v pacman >/dev/null 2>&1; then
|
||||||
${SUDO_PREFIX} pacman -S --noconfirm "${MISSING_CORE[@]}" || true
|
${SUDO_PREFIX} pacman -S --noconfirm "${MISSING_CORE[@]}" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fallback: if scrcpy is still missing, try snap or install portable scrcpy in user space
|
# Fallback: if scrcpy is still missing, install official precompiled portable scrcpy in user space
|
||||||
if ! command -v scrcpy >/dev/null 2>&1; then
|
|
||||||
if command -v snap >/dev/null 2>&1 && request_sudo "install scrcpy via snap"; then
|
|
||||||
local SUDO_PREFIX=""
|
|
||||||
if [ "$(id -u)" -ne 0 ]; then SUDO_PREFIX="sudo"; fi
|
|
||||||
${SUDO_PREFIX} snap install scrcpy 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if ! command -v scrcpy >/dev/null 2>&1; then
|
if ! command -v scrcpy >/dev/null 2>&1; then
|
||||||
ARCH="$(uname -m)"
|
ARCH="$(uname -m)"
|
||||||
SCRCPY_ARCH=""
|
SCRCPY_ARCH=""
|
||||||
@@ -208,7 +201,7 @@ if [ ${#MISSING_CORE[@]} -gt 0 ]; then
|
|||||||
echo -e " ${CYAN}📦 Installing portable scrcpy in user space (~/.local)...${NC}"
|
echo -e " ${CYAN}📦 Installing portable scrcpy in user space (~/.local)...${NC}"
|
||||||
mkdir -p "${SCRCPY_DIR}" "${HOME}/.local/bin"
|
mkdir -p "${SCRCPY_DIR}" "${HOME}/.local/bin"
|
||||||
SCRCPY_URL="https://github.com/Genymobile/scrcpy/releases/download/v4.1/scrcpy-linux-${SCRCPY_ARCH}-v4.1.tar.gz"
|
SCRCPY_URL="https://github.com/Genymobile/scrcpy/releases/download/v4.1/scrcpy-linux-${SCRCPY_ARCH}-v4.1.tar.gz"
|
||||||
if curl -fsSL "${SCRCPY_URL}" | tar -xz -C "${SCRCPY_DIR}" --strip-components=1 2>/dev/null; then
|
if curl -fsSL --connect-timeout 5 --max-time 30 "${SCRCPY_URL}" | tar -xz -C "${SCRCPY_DIR}" --strip-components=1 2>/dev/null; then
|
||||||
ln -sf "${SCRCPY_DIR}/scrcpy" "${HOME}/.local/bin/scrcpy"
|
ln -sf "${SCRCPY_DIR}/scrcpy" "${HOME}/.local/bin/scrcpy"
|
||||||
export PATH="${SCRCPY_DIR}:${PATH}"
|
export PATH="${SCRCPY_DIR}:${PATH}"
|
||||||
echo -e " ${GREEN}✓ scrcpy installed in user space.${NC}"
|
echo -e " ${GREEN}✓ scrcpy installed in user space.${NC}"
|
||||||
|
|||||||
Reference in new issue
Block a user