mirror of
https://github.com/kuhyx/scripts.git
synced 2026-11-20 05:14:28 +01:00
feat: more restrictive package installation
This commit is contained in:
parent
622fb438b4
commit
d2b0bcc160
@ -52,10 +52,10 @@ function display_operation() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to check if user is trying to install specific packages that require confirmation
|
# Function to check if user is trying to install packages that are always blocked
|
||||||
function check_for_steam() {
|
function check_for_always_blocked() {
|
||||||
# List of packages that require confirmation
|
# List of packages that are ALWAYS blocked without any challenge
|
||||||
local restricted_packages=("steam" "freetube-bin" "freetube" "seamonkey-bin" "seamonkey" "min-browser-bin" "min-browser" "beaker-browser" "catalyst-browser-bin" "hamsket" "min" "vieb-bin" "yt-dlp" "yt-dlp-git" "stremio" "stremio-git" "angelfish" "dooble" "eric" "falkon" "fiery" "maui" "konqueror" "liri" "otter" "quotebrowser" "beaker" "catalyst" "badwolf" "eolie" "epiphany" "surf" "uzbl" "vimb" "vimb-git" "web-browser" "web-browser-git" "web-browser-bin" "web-browser-bin-git" "web-browser-bin-git" "luakit" "nyxt" "tangram" "vimb" "dillo" "links" "netsurf" "amfora")
|
local always_blocked_packages=("freetube-bin" "freetube" "seamonkey-bin" "seamonkey" "min-browser-bin" "min-browser" "beaker-browser" "catalyst-browser-bin" "hamsket" "min" "vieb-bin" "yt-dlp" "yt-dlp-git" "stremio" "stremio-git" "angelfish" "dooble" "eric" "falkon" "fiery" "maui" "konqueror" "liri" "otter" "quotebrowser" "beaker" "catalyst" "badwolf" "eolie" "epiphany" "surf" "uzbl" "vimb" "vimb-git" "web-browser" "web-browser-git" "web-browser-bin" "web-browser-bin-git" "web-browser-bin-git" "luakit" "nyxt" "tangram" "vimb" "dillo" "links" "netsurf" "amfora")
|
||||||
|
|
||||||
# Check if the command is an installation command
|
# Check if the command is an installation command
|
||||||
if [[ "$1" == "-S" || "$1" == "-Sy" || "$1" == "-Syu" || "$1" == "-Syyu" || "$1" == "-U" ]]; then
|
if [[ "$1" == "-S" || "$1" == "-Sy" || "$1" == "-Syu" || "$1" == "-Syyu" || "$1" == "-U" ]]; then
|
||||||
@ -64,16 +64,40 @@ function check_for_steam() {
|
|||||||
# Strip repository prefix if present (like extra/ or community/)
|
# Strip repository prefix if present (like extra/ or community/)
|
||||||
local package_name="${arg##*/}"
|
local package_name="${arg##*/}"
|
||||||
|
|
||||||
# Check if argument matches any restricted package
|
# Check if argument matches any always blocked package
|
||||||
for package in "${restricted_packages[@]}"; do
|
for package in "${always_blocked_packages[@]}"; do
|
||||||
if [[ "$arg" == "$package" || "$arg" == *"/$package-"* || "$arg" == *"/$package/"* ||
|
if [[ "$arg" == "$package" || "$arg" == *"/$package-"* || "$arg" == *"/$package/"* ||
|
||||||
"$arg" == *"/$package" || "$package_name" == "$package" ]]; then
|
"$arg" == *"/$package" || "$package_name" == "$package" ]]; then
|
||||||
return 0 # Restricted package found
|
return 0 # Always blocked package found
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
return 1 # No restricted package found
|
return 1 # No always blocked package found
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to check if user is trying to install steam (challenge-eligible package)
|
||||||
|
function check_for_steam() {
|
||||||
|
# List of packages that require challenge (only steam in this case)
|
||||||
|
local steam_packages=("steam")
|
||||||
|
|
||||||
|
# Check if the command is an installation command
|
||||||
|
if [[ "$1" == "-S" || "$1" == "-Sy" || "$1" == "-Syu" || "$1" == "-Syyu" || "$1" == "-U" ]]; then
|
||||||
|
# Check all arguments
|
||||||
|
for arg in "$@"; do
|
||||||
|
# Strip repository prefix if present (like extra/ or community/)
|
||||||
|
local package_name="${arg##*/}"
|
||||||
|
|
||||||
|
# Check if argument matches steam
|
||||||
|
for package in "${steam_packages[@]}"; do
|
||||||
|
if [[ "$arg" == "$package" || "$arg" == *"/$package-"* || "$arg" == *"/$package/"* ||
|
||||||
|
"$arg" == *"/$package" || "$package_name" == "$package" ]]; then
|
||||||
|
return 0 # Steam package found
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
return 1 # No steam package found
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to check if current day is a weekday (Monday-Friday)
|
# Function to check if current day is a weekday (Monday-Friday)
|
||||||
@ -86,19 +110,19 @@ function is_weekday() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to prompt for solving a word unscrambling challenge
|
# Function to prompt for solving a word unscrambling challenge (only for steam)
|
||||||
function prompt_for_math_solution() {
|
function prompt_for_steam_challenge() {
|
||||||
echo -e "${YELLOW}WARNING: You are trying to install a restricted package.${NC}"
|
echo -e "${YELLOW}WARNING: You are trying to install Steam.${NC}"
|
||||||
|
|
||||||
# Check if it's a weekday and block completely
|
# Check if it's a weekday and block completely
|
||||||
if is_weekday; then
|
if is_weekday; then
|
||||||
local day_name=$(date +%A)
|
local day_name=$(date +%A)
|
||||||
echo -e "${RED}Installation BLOCKED: Restricted packages cannot be installed on weekdays.${NC}"
|
echo -e "${RED}Steam installation BLOCKED: Steam cannot be installed on weekdays.${NC}"
|
||||||
echo -e "${RED}Today is $day_name. Please try again on the weekend (Saturday or Sunday).${NC}"
|
echo -e "${RED}Today is $day_name. Please try again on the weekend (Saturday or Sunday).${NC}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${YELLOW}Challenge will begin shortly...${NC}"
|
echo -e "${YELLOW}Weekend Steam challenge will begin shortly...${NC}"
|
||||||
|
|
||||||
# Sleep for random 20-40 seconds
|
# Sleep for random 20-40 seconds
|
||||||
sleep_duration=$((RANDOM % 20 + 20))
|
sleep_duration=$((RANDOM % 20 + 20))
|
||||||
@ -220,9 +244,16 @@ if [[ "$1" == "--help-wrapper" ]]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if trying to install steam
|
# Check for always blocked packages first (highest priority)
|
||||||
|
if check_for_always_blocked "$@"; then
|
||||||
|
echo -e "${RED}Installation BLOCKED: This package is permanently restricted and cannot be installed.${NC}"
|
||||||
|
echo -e "${RED}Package installation has been denied by system policy.${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for steam (challenge-eligible package)
|
||||||
if check_for_steam "$@"; then
|
if check_for_steam "$@"; then
|
||||||
prompt_for_math_solution
|
prompt_for_steam_challenge
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user