mirror of
https://github.com/buildplan/du_setup.git
synced 2025-12-29 16:14:59 +00:00
address edge cases for different VPS terminals
This commit is contained in:
11
du_setup.sh
11
du_setup.sh
@@ -364,6 +364,7 @@ detect_environment() {
|
|||||||
ENVIRONMENT_TYPE="unknown"
|
ENVIRONMENT_TYPE="unknown"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
DETECTED_PROVIDER_NAME=""
|
||||||
case "$ENVIRONMENT_TYPE" in
|
case "$ENVIRONMENT_TYPE" in
|
||||||
commercial-cloud)
|
commercial-cloud)
|
||||||
if [[ "$MANUFACTURER" =~ digitalocean ]]; then
|
if [[ "$MANUFACTURER" =~ digitalocean ]]; then
|
||||||
@@ -657,8 +658,8 @@ cleanup_provider_packages() {
|
|||||||
print_info "Auditing /root/.ssh/authorized_keys for unexpected keys..."
|
print_info "Auditing /root/.ssh/authorized_keys for unexpected keys..."
|
||||||
if [[ -f /root/.ssh/authorized_keys ]]; then
|
if [[ -f /root/.ssh/authorized_keys ]]; then
|
||||||
local key_count
|
local key_count
|
||||||
key_count=$(grep -cE '^ssh-(rsa|ed25519|ecdsa)' /root/.ssh/authorized_keys 2>/dev/null || echo 0)
|
key_count=$( (grep -cE '^ssh-(rsa|ed25519|ecdsa)' /root/.ssh/authorized_keys 2>/dev/null || echo 0) | tr -dc '0-9' )
|
||||||
if [[ $key_count -gt 0 ]]; then
|
if [ "$key_count" -gt 0 ]; then
|
||||||
print_warning "Found $key_count SSH key(s) in /root/.ssh/authorized_keys"
|
print_warning "Found $key_count SSH key(s) in /root/.ssh/authorized_keys"
|
||||||
ROOT_SSH_KEYS=("present")
|
ROOT_SSH_KEYS=("present")
|
||||||
fi
|
fi
|
||||||
@@ -878,15 +879,15 @@ cleanup_provider_packages() {
|
|||||||
echo -e "${YELLOW}Found user: $user${NC}"
|
echo -e "${YELLOW}Found user: $user${NC}"
|
||||||
|
|
||||||
local proc_count
|
local proc_count
|
||||||
proc_count=$(ps -u "$user" --no-headers 2>/dev/null | wc -l)
|
proc_count=$( (ps -u "$user" --no-headers 2>/dev/null || true) | wc -l)
|
||||||
if [[ $proc_count -gt 0 ]]; then
|
if [[ $proc_count -gt 0 ]]; then
|
||||||
print_warning "User $user has $proc_count running process(es)."
|
print_warning "User $user has $proc_count running process(es)."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "/home/$user" ]] && [[ -f "/home/$user/.ssh/authorized_keys" ]]; then
|
if [[ -d "/home/$user" ]] && [[ -f "/home/$user/.ssh/authorized_keys" ]]; then
|
||||||
local key_count=0
|
local key_count=0
|
||||||
key_count=$(grep -cE '^ssh-(rsa|ed25519|ecdsa)' "/home/$user/.ssh/authorized_keys" 2>/dev/null || echo 0)
|
key_count=$( (grep -cE '^ssh-(rsa|ed25519|ecdsa)' "/home/$user/.ssh/authorized_keys" 2>/dev/null || echo 0) | tr -dc '0-9' )
|
||||||
if [[ $key_count -gt 0 ]]; then
|
if [ "$key_count" -gt 0 ]; then
|
||||||
print_warning "User $user has $key_count SSH key(s) configured."
|
print_warning "User $user has $key_count SSH key(s) configured."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user