mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-07-07 15:56:53 +00:00
Update menu_post_install.sh
This commit is contained in:
parent
a41df16f14
commit
d98b68ca65
@ -1,13 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ==========================================================
|
||||
# ProxMenu - A menu-driven script for Proxmox VE management
|
||||
# ==========================================================
|
||||
# Author : MacRimi
|
||||
# Copyright : (c) 2024 MacRimi
|
||||
# License : MIT (https://raw.githubusercontent.com/MacRimi/ProxMenux/main/LICENSE)
|
||||
# Version : 1.1
|
||||
# Last Updated: 28/05/2025
|
||||
# Version : 1.2
|
||||
# Last Updated: 06/07/2025
|
||||
# ==========================================================
|
||||
|
||||
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
|
||||
@ -23,16 +22,16 @@ load_language
|
||||
initialize_cache
|
||||
|
||||
# ==========================================================
|
||||
|
||||
confirm_and_run() {
|
||||
local name="$1"
|
||||
local command="$2"
|
||||
|
||||
|
||||
dialog --clear --title "$(translate "Confirmation")" \
|
||||
--yesno "\n\n$(translate "Do you want to run the post-installation script from") $name?" 10 70
|
||||
|
||||
response=$?
|
||||
clear
|
||||
|
||||
|
||||
if [ $response -eq 0 ]; then
|
||||
eval "$command"
|
||||
echo
|
||||
@ -44,75 +43,153 @@ confirm_and_run() {
|
||||
fi
|
||||
}
|
||||
|
||||
scripts_es=(
|
||||
"Script post-install personalizable |ProxMenux|bash <(curl -s $REPO_URL/scripts/customizable_post_install.sh)"
|
||||
"Script post-install Proxmox VE |Helper-Scripts|bash -c \"\$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/post-pve-install.sh); msg_success \\\"\$(translate 'Press ENTER to continue...')\\\"; read -r _\""
|
||||
"Script post-iinstall xshok-proxmox|fork xshok-proxmox|confirm_and_run \"Xshok\" \"wget https://raw.githubusercontent.com/MacRimi/xshok-proxmox/master/install-post.sh -c -O install-post.sh && bash install-post.sh && rm install-post.sh\""
|
||||
"Desinstalar herramientas|ProxMenux|bash <(curl -s $REPO_URL/scripts/uninstall-tools.sh)"
|
||||
# ==========================================================
|
||||
confirm_automated_script() {
|
||||
local script_info=""
|
||||
|
||||
|
||||
script_info+="\n$(translate "The automated post-install script performs the following system adjustments"):\n\n"
|
||||
|
||||
script_info+="• $(translate "Configure") \Z4repositories\Z0 $(translate "and upgrade system")\n"
|
||||
script_info+="• $(translate "Remove") \Z4subscription banner\Z0 $(translate "from Proxmox interface")\n"
|
||||
script_info+="• $(translate "Optimize") \Z4memory\Z0 $(translate "and") \Z4system limits\Z0\n"
|
||||
script_info+="• $(translate "Enhance") \Z4network\Z0 $(translate "performance and") \Z4TCP settings\Z0\n"
|
||||
script_info+="• $(translate "Install") \Z4log2ram\Z0 $(translate "for") \Z4SSD protection\Z0\n"
|
||||
script_info+="• $(translate "Configure") \Z4security\Z0 $(translate "and") \Z4time synchronization\Z0\n"
|
||||
script_info+="• $(translate "Optimize") \Z4journald\Z0, \Z4entropy\Z0 $(translate "and") \Z4bash environment\Z0\n"
|
||||
script_info+="• $(translate "Apply") \Z4kernel\Z0 $(translate "and") \Z4logrotate\Z0 $(translate "optimizations")\n\n"
|
||||
|
||||
script_info+="$(translate "Do you want to run this script?")"
|
||||
|
||||
|
||||
dialog --clear --colors \
|
||||
--backtitle "ProxMenux" \
|
||||
--title "$(translate "Automated post-install Script")" \
|
||||
--yesno "$script_info" 20 70
|
||||
|
||||
response=$?
|
||||
clear
|
||||
|
||||
if [ $response -eq 0 ]; then
|
||||
bash <(curl -s $REPO_URL/scripts/post_install/auto_post_install.sh)
|
||||
echo
|
||||
msg_success "$(translate 'Press ENTER to continue...')"
|
||||
read -r _
|
||||
else
|
||||
msg_warn "$(translate "Cancelled by user.")"
|
||||
sleep 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ==========================================================
|
||||
|
||||
declare -a PROXMENUX_SCRIPTS=(
|
||||
"Automated post-installation script|ProxMenux|confirm_automated_script"
|
||||
"Customizable post-installation script|ProxMenux|bash <(curl -s $REPO_URL/scripts/post_install/customizable_post_install.sh)"
|
||||
"Uninstall optimizations|ProxMenux|bash <(curl -s $REPO_URL/scripts/post_install/uninstall-tools.sh)"
|
||||
)
|
||||
|
||||
scripts_all_langs=(
|
||||
"Customizable script post-installation|ProxMenux|bash <(curl -s $REPO_URL/scripts/customizable_post_install.sh)"
|
||||
|
||||
declare -a COMMUNITY_SCRIPTS=(
|
||||
"Proxmox VE Post Install|Helper-Scripts|bash -c \"\$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/post-pve-install.sh); msg_success \\\"\$(translate 'Press ENTER to continue...')\\\"; read -r _\""
|
||||
"Xshok-proxmox Post install|fork xshok-proxmox|confirm_and_run \"Xshok\" \"wget https://raw.githubusercontent.com/MacRimi/xshok-proxmox/master/install-post.sh -c -O install-post.sh && bash install-post.sh && rm install-post.sh\""
|
||||
"Uninstall Tools|ProxMenux|bash <(curl -s $REPO_URL/scripts/uninstall-tools.sh)"
|
||||
)
|
||||
|
||||
# ==========================================================
|
||||
|
||||
format_menu_item() {
|
||||
local description="$1"
|
||||
local source="$2"
|
||||
local total_width=62
|
||||
|
||||
|
||||
local desc_length=${#description}
|
||||
local source_length=${#source}
|
||||
local spaces_needed=$((total_width - desc_length - source_length))
|
||||
|
||||
|
||||
[ $spaces_needed -lt 3 ] && spaces_needed=3
|
||||
|
||||
|
||||
local spacing=""
|
||||
for ((i=0; i<spaces_needed; i++)); do
|
||||
spacing+=" "
|
||||
done
|
||||
|
||||
echo "${description}${spacing}${source}"
|
||||
}
|
||||
|
||||
# ==========================================================
|
||||
show_menu() {
|
||||
while true; do
|
||||
local HEADER
|
||||
local current_scripts=()
|
||||
|
||||
if [[ "$LANGUAGE" == "es" ]]; then
|
||||
HEADER="\n Seleccione un script post-instalación:\n\n Descripción │ Fuente"
|
||||
current_scripts=("${scripts_es[@]}")
|
||||
else
|
||||
HEADER="\n$(translate " Select a post-installation script:")\n\n Description │ Source"
|
||||
current_scripts=("${scripts_all_langs[@]}")
|
||||
fi
|
||||
|
||||
menu_items=()
|
||||
|
||||
for i in "${!current_scripts[@]}"; do
|
||||
IFS='|' read -r name repository command <<< "${current_scripts[$i]}"
|
||||
number=$((i+1))
|
||||
local display_name="$name"
|
||||
[[ "$LANGUAGE" != "es" ]] && display_name="$(translate "$name")"
|
||||
formatted_line=$(printf "%-47s │ %s" "$display_name" "$repository")
|
||||
menu_items+=("$number" "$formatted_line")
|
||||
done
|
||||
|
||||
menu_items+=("$(( ${#current_scripts[@]}+1 ))" "$(translate "Return to Main Menu")")
|
||||
|
||||
exec 3>&1
|
||||
script_selection=$(dialog --clear --backtitle "ProxMenux" --title "$(translate "Post-Installation Scripts Menu")" \
|
||||
--menu "$HEADER" 20 78 $((${#menu_items[@]}/2)) \
|
||||
"${menu_items[@]}" 2>&1 1>&3)
|
||||
exit_status=$?
|
||||
exec 3>&-
|
||||
|
||||
local menu_items=()
|
||||
|
||||
|
||||
if [ $exit_status -ne 0 ]; then
|
||||
declare -A script_commands
|
||||
local counter=1
|
||||
|
||||
|
||||
for script in "${PROXMENUX_SCRIPTS[@]}"; do
|
||||
IFS='|' read -r name source command <<< "$script"
|
||||
local translated_name="$(translate "$name")"
|
||||
local formatted_item
|
||||
formatted_item=$(format_menu_item "$translated_name" "$source")
|
||||
menu_items+=("$counter" "$formatted_item")
|
||||
script_commands["$counter"]="$command"
|
||||
((counter++))
|
||||
done
|
||||
|
||||
|
||||
menu_items+=("" "")
|
||||
menu_items+=("-" "───────────────────── $(translate "Community Scripts") ──────────────────────")
|
||||
menu_items+=("" "")
|
||||
|
||||
|
||||
for script in "${COMMUNITY_SCRIPTS[@]}"; do
|
||||
IFS='|' read -r name source command <<< "$script"
|
||||
local translated_name="$(translate "$name")"
|
||||
local formatted_item
|
||||
formatted_item=$(format_menu_item "$translated_name" "$source")
|
||||
menu_items+=("$counter" "$formatted_item")
|
||||
script_commands["$counter"]="$command"
|
||||
((counter++))
|
||||
done
|
||||
|
||||
|
||||
menu_items+=("" "")
|
||||
menu_items+=("0" "$(translate "Return to Main Menu")")
|
||||
|
||||
|
||||
exec 3>&1
|
||||
script_selection=$(dialog --clear \
|
||||
--backtitle "ProxMenux" \
|
||||
--title "$(translate "Post-Installation Scripts")" \
|
||||
--menu "\n$(translate "Select a post-installation script:"):\n" \
|
||||
22 78 15 \
|
||||
"${menu_items[@]}" 2>&1 1>&3)
|
||||
exit_status=$?
|
||||
exec 3>&-
|
||||
|
||||
|
||||
if [ $exit_status -ne 0 ] || [ "$script_selection" = "0" ]; then
|
||||
exec bash <(curl -s "$REPO_URL/scripts/menus/main_menu.sh")
|
||||
fi
|
||||
|
||||
|
||||
if [ "$script_selection" = "$(( ${#current_scripts[@]} + 1 ))" ]; then
|
||||
exec bash <(curl -s "$REPO_URL/scripts/menus/main_menu.sh")
|
||||
if [[ "$script_selection" == "-" || "$script_selection" == "" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
|
||||
index=$((script_selection - 1))
|
||||
if [ $index -ge 0 ] && [ $index -lt ${#current_scripts[@]} ]; then
|
||||
IFS='|' read -r _ _ command <<< "${current_scripts[$index]}"
|
||||
eval "$command"
|
||||
if [[ -n "${script_commands[$script_selection]}" ]]; then
|
||||
eval "${script_commands[$script_selection]}"
|
||||
else
|
||||
msg_error "$(translate "Invalid selection")"
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ==========================================================
|
||||
|
||||
#if [[ "$LANGUAGE" != "en" ]]; then
|
||||
# show_proxmenux_logo
|
||||
# msg_lang "$(translate "Generating automatic translations...")"
|
||||
#fi
|
||||
cleanup
|
||||
show_menu
|
Loading…
x
Reference in New Issue
Block a user