Move and improve ssh_check and shell_check functions
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
The ssh_check function was moved from build.func to core.func and enhanced to allow an override and to skip warnings for localhost connections. The shell_check function was simplified to directly check for Bash and provide clearer messaging. These changes centralize environment checks and improve user experience.
This commit is contained in:
parent
435890eee2
commit
d0f6818386
@ -239,25 +239,6 @@ update_motd_ip() {
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# ssh_check()
|
||||
#
|
||||
# - Detects if script is running over SSH
|
||||
# - Warns user and recommends using Proxmox shell
|
||||
# - User can choose to continue or abort
|
||||
# ------------------------------------------------------------------------------
|
||||
ssh_check() {
|
||||
if [ -n "${SSH_CLIENT:+x}" ]; then
|
||||
if whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's advisable to utilize the Proxmox shell rather than SSH, as there may be potential complications with variable retrieval. Proceed using SSH?" 10 72; then
|
||||
whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --msgbox --title "Proceed using SSH" "You've chosen to proceed using SSH. If any issues arise, please run the script in the Proxmox shell before creating a repository issue." 10 72
|
||||
else
|
||||
clear
|
||||
echo "Exiting due to SSH usage. Please consider using the Proxmox shell."
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# install_ssh_keys_into_ct()
|
||||
#
|
||||
|
@ -154,16 +154,12 @@ silent() {
|
||||
|
||||
# Check if the shell is using bash
|
||||
shell_check() {
|
||||
local CURRENT_SHELL
|
||||
CURRENT_SHELL="$(ps -p $$ -o comm= | xargs)" # trims whitespace
|
||||
echo "DEBUG: Detected shell is: '$CURRENT_SHELL'"
|
||||
|
||||
if [[ -z "$BASH_VERSION" ]]; then
|
||||
if [[ "$(ps -p $$ -o comm=)" != "bash" ]]; then
|
||||
clear
|
||||
msg_error "This script requires bash, but current shell is: $CURRENT_SHELL"
|
||||
msg_error "Your default shell is currently not set to Bash. To use these scripts, please switch to the Bash shell."
|
||||
echo -e "\nExiting..."
|
||||
sleep 2
|
||||
exit 1
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
@ -223,6 +219,39 @@ arch_check() {
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# ssh_check()
|
||||
#
|
||||
# - Detects if script is running over SSH
|
||||
# - Warns user and recommends using Proxmox shell
|
||||
# - User can choose to continue or abort
|
||||
# ------------------------------------------------------------------------------
|
||||
ssh_check() {
|
||||
# Skip if override
|
||||
if [[ "${ALLOW_SSH:-0}" -eq 1 ]]; then return; fi
|
||||
|
||||
if [ -n "$SSH_CLIENT" ]; then
|
||||
local client_ip server_port
|
||||
client_ip=$(awk '{print $1}' <<<"$SSH_CLIENT")
|
||||
server_port=$(awk '{print $3}' <<<"$SSH_CLIENT")
|
||||
|
||||
# Wenn client_ip = localhost oder host-IP → kein Warnpopup
|
||||
if [[ "$client_ip" == "127.0.0.1" || "$client_ip" == "$(hostname -I | awk '{print $1}')" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Andernfalls Popup
|
||||
if ! whiptail --backtitle "[dev] Proxmox VE Helper Scripts" \
|
||||
--defaultno \
|
||||
--title "SSH DETECTED" \
|
||||
--yesno "It's advisable to utilize the Proxmox shell rather than SSH..." 10 72; then
|
||||
clear
|
||||
echo "Exiting due to SSH usage."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to download & save header files
|
||||
get_header() {
|
||||
local app_name=$(echo "${APP,,}" | tr -d ' ')
|
||||
|
Loading…
x
Reference in New Issue
Block a user