From efa95b0858b95360a99abc3fca81e113eea6db58 Mon Sep 17 00:00:00 2001 From: MacRimi <123239993+MacRimi@users.noreply.github.com> Date: Sun, 24 Aug 2025 10:29:00 +0200 Subject: [PATCH] Update customizable_post_install.sh --- .../post_install/customizable_post_install.sh | 101 ++++++++++-------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/scripts/post_install/customizable_post_install.sh b/scripts/post_install/customizable_post_install.sh index fb1c3e7..2434491 100644 --- a/scripts/post_install/customizable_post_install.sh +++ b/scripts/post_install/customizable_post_install.sh @@ -3179,85 +3179,93 @@ add_repo_test() { configure_figurine_() { - msg_info2 "$(translate "Installing and configuring Figurine...")" local version="1.3.0" local file="figurine_linux_amd64_v${version}.tar.gz" local url="https://github.com/arsham/figurine/releases/download/v${version}/${file}" - local temp_dir - temp_dir=$(mktemp -d) + local temp_dir; temp_dir=$(mktemp -d) local install_dir="/usr/local/bin" local profile_script="/etc/profile.d/figurine.sh" local bin_path="${install_dir}/figurine" local bashrc="/root/.bashrc" - local marker_begin="# BEGIN PMX_FIGURINE" - local marker_end="# END PMX_FIGURINE" - - - cleanup_dir() { - rm -rf "$temp_dir" 2>/dev/null || true - } + + cleanup_dir() { rm -rf "$temp_dir" 2>/dev/null || true; } trap cleanup_dir EXIT - - + + [[ -f "$bashrc" ]] || touch "$bashrc" + if command -v figurine &>/dev/null; then msg_info "$(translate "Updating Figurine binary...")" else msg_info "$(translate "Downloading Figurine v${version}...")" fi - - if ! wget -qO "${temp_dir}/${file}" "$url" > /dev/null 2>&1; then + + if ! wget -qO "${temp_dir}/${file}" "$url"; then msg_error "$(translate "Failed to download Figurine")" return 1 fi - - if ! tar -xf "${temp_dir}/${file}" -C "${temp_dir}" > /dev/null 2>&1; then + if ! tar -xf "${temp_dir}/${file}" -C "${temp_dir}"; then msg_error "$(translate "Failed to extract package")" return 1 fi msg_ok "$(translate "Extraction successful")" - + if [[ ! -f "${temp_dir}/deploy/figurine" ]]; then msg_error "$(translate "Binary not found in extracted content.")" return 1 fi - - msg_info "$(translate "Installing binary to ${install_dir}...")" - install -m 0755 -o root -g root "${temp_dir}/deploy/figurine" "$bin_path" > /dev/null 2>&1 + msg_info "$(translate "Installing binary to ${install_dir}...")" + install -m 0755 -o root -g root "${temp_dir}/deploy/figurine" "$bin_path" + cat > "$profile_script" << 'EOF' /usr/local/bin/figurine -f "3d.flf" $(hostname) EOF - chmod +x "$profile_script" > /dev/null 2>&1 + chmod +x "$profile_script" - - - if grep -q "^${marker_begin}$" "$bashrc" 2>/dev/null; then - sed -i "/^${marker_begin}$/,/^${marker_end}$/d" "$bashrc" - fi - - - cat >> "$bashrc" << 'EOF' -${marker_begin} -# ProxMenux Figurine aliases and tools -alias aptup='apt update && apt dist-upgrade' -alias lxcclean='curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/clean-lxcs.sh | bash' -alias lxcupdate='curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/update-lxcs.sh | bash' -alias kernelclean='curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/kernel-clean.sh | bash' -alias cpugov='curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/scaling-governor.sh | bash' -alias lxctrim='curl -fsSL -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/fstrim.sh | bash' -alias updatecerts='pvecm updatecerts' -alias seqwrite='sync; fio --randrepeat=1 --ioengine=libaio --direct=1 --name=test --filename=test --bs=4M --size=32G --readwrite=write --ramp_time=4' -alias seqread='sync; fio --randrepeat=1 --ioengine=libaio --direct=1 --name=test --filename=test --bs=4M --size=32G --readwrite=read --ramp_time=4' -alias ranwrite='sync; fio --randrepeat=1 --ioengine=libaio --direct=1 --name=test --filename=test --bs=4k --size=4G --readwrite=randwrite --ramp_time=4' -alias ranread='sync; fio --randrepeat=1 --ioengine=libaio --direct=1 --name=test --filename=test --bs=4k --size=4G --readwrite=randread --ramp_time=4' -${marker_end} -EOF + + ensure_aliases() { + local bashrc="/root/.bashrc" + [[ -f "$bashrc" ]] || touch "$bashrc" + + local -a ALIASES=( + "aptup=apt update && apt dist-upgrade" + "lxcclean=curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/clean-lxcs.sh | bash" + "lxcupdate=curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/update-lxcs.sh | bash" + "kernelclean=curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/kernel-clean.sh | bash" + "cpugov=curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/scaling-governor.sh | bash" + "lxctrim=curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/fstrim.sh | bash" + "updatecerts=pvecm updatecerts" + "seqwrite=sync; fio --randrepeat=1 --ioengine=libaio --direct=1 --name=test --filename=test --bs=4M --size=32G --readwrite=write --ramp_time=4" + "seqread=sync; fio --randrepeat=1 --ioengine=libaio --direct=1 --name=test --filename=test --bs=4M --size=32G --readwrite=read --ramp_time=4" + "ranwrite=sync; fio --randrepeat=1 --ioengine=libaio --direct=1 --name=test --filename=test --bs=4k --size=4G --readwrite=randwrite --ramp_time=4" + "ranread=sync; fio --randrepeat=1 --ioengine=libaio --direct=1 --name=test --filename=test --bs=4k --size=4G --readwrite=randread --ramp_time=4" + ) + + for entry in "${ALIASES[@]}"; do + local name="${entry%%=*}" + local cmd="${entry#*=}" + local esc_cmd + esc_cmd=$(printf "%s" "$cmd" | sed -e 's/[\\/&]/\\&/g') + + if grep -Eq "^alias[[:space:]]+$name=" "$bashrc"; then + if ! grep -Eq "^alias[[:space:]]+$name='${esc_cmd}'$" "$bashrc"; then + sed -i -E "s|^alias[[:space:]]+$name=.*$|alias $name='${esc_cmd}'|" "$bashrc" + fi + else + printf "alias %s='%s'\n" "$name" "$cmd" >> "$bashrc" + fi + done + + + awk '!seen[$0]++' "$bashrc" > "${bashrc}.tmp" && mv "${bashrc}.tmp" "$bashrc" + } + + ensure_aliases msg_ok "$(translate "Aliases added to .bashrc")" - sed -i '/\${marker_begin}/d;/\${marker_end}/d' .bashrc - + msg_success "$(translate "Figurine installation and configuration completed successfully.")" register_tool "figurine" true } @@ -3269,6 +3277,7 @@ EOF + configure_figurine() { msg_info2 "$(translate "Installing and configuring Figurine...")" local version="1.3.0"