From 62f71f067aa451130d5d13c3b1010f62a83aa0e9 Mon Sep 17 00:00:00 2001 From: X-Anonymous-Y Date: Sat, 29 Jul 2023 00:08:24 +0200 Subject: [PATCH] Changed from 4 spaces to 2 spaces # Changed from 4 spaces to 2 spaces ## Description Just cleaned script codes Fixes # (issue) Tabular length changed ## Type of change Please delete options that are not relevant. - [x] Bug fix - [ ] New feature - [ ] New Script - [ ] This change requires a documentation update --- install/magicmirror-install.sh | 166 ++++++++--------- install/prometheus-install.sh | 10 +- install/shinobi-install.sh | 10 +- misc/bluetooth.sh | 26 +-- misc/code-server.sh | 42 ++--- misc/container-restore-from-backup.sh | 44 ++--- misc/core-restore-from-backup.sh | 44 ++--- misc/crowdsec.sh | 38 ++-- misc/edge-kernel.sh | 252 +++++++++++++------------- misc/filebrowser.sh | 34 ++-- misc/kernel-clean.sh | 154 ++++++++-------- misc/scaling-governor.sh | 66 +++---- misc/webmin.sh | 12 +- 13 files changed, 451 insertions(+), 447 deletions(-) diff --git a/install/magicmirror-install.sh b/install/magicmirror-install.sh index 1ad0323e..6201b212 100644 --- a/install/magicmirror-install.sh +++ b/install/magicmirror-install.sh @@ -37,88 +37,92 @@ $STD npm install --only=prod --omit=dev cat </opt/magicmirror/config/config.js let config = { - address: "0.0.0.0", - port: 8080, - basePath: "/", - ipWhitelist: [], - useHttps: false, - httpsPrivateKey: "", - httpsCertificate: "", - language: "en", - locale: "en-US", - logLevel: ["INFO", "LOG", "WARN", "ERROR"], - timeFormat: 24, - units: "metric", - serverOnly: true, - modules: [ - { - module: "alert", - }, - { - module: "updatenotification", - position: "top_bar" - }, - { - module: "clock", - position: "top_left" - }, - { - module: "calendar", - header: "US Holidays", - position: "top_left", - config: { - calendars: [ - { - symbol: "calendar-check", - url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics" - } - ] - } - }, - { - module: "compliments", - position: "lower_third" - }, - { - module: "weather", - position: "top_right", - config: { - weatherProvider: "openweathermap", - type: "current", - location: "New York", - locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city - apiKey: "YOUR_OPENWEATHER_API_KEY" - } - }, - { - module: "weather", - position: "top_right", - header: "Weather Forecast", - config: { - weatherProvider: "openweathermap", - type: "forecast", - location: "New York", - locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city - apiKey: "YOUR_OPENWEATHER_API_KEY" - } - }, - { - module: "newsfeed", - position: "bottom_bar", - config: { - feeds: [ - { - title: "New York Times", - url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" - } - ], - showSourceTitle: true, - showPublishDate: true, - broadcastNewsFeeds: true, - broadcastNewsUpdates: true - } - }, + address: "0.0.0.0", + port: 8080, + basePath: "/", + ipWhitelist: [], + useHttps: false, + httpsPrivateKey: "", + httpsCertificate: "", + language: "en", + locale: "en-US", + logLevel: [ + "INFO", + "LOG", + "WARN", + "ERROR"], + timeFormat: 24, + units: "metric", + serverOnly: true, + modules: [ + { + module: "alert", + }, + { + module: "updatenotification", + position: "top_bar" + }, + { + module: "clock", + position: "top_left" + }, + { + module: "calendar", + header: "US Holidays", + position: "top_left", + config: { + calendars: [ + { + symbol: "calendar-check", + url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics" + } ] + } + }, + { + module: "compliments", + position: "lower_third" + }, + { + module: "weather", + position: "top_right", + config: { + weatherProvider: "openweathermap", + type: "current", + location: "New York", + locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city + apiKey: "YOUR_OPENWEATHER_API_KEY" + } + }, + { + module: "weather", + position: "top_right", + header: "Weather Forecast", + config: { + weatherProvider: "openweathermap", + type: "forecast", + location: "New York", + locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city + apiKey: "YOUR_OPENWEATHER_API_KEY" + } + }, + { + module: "newsfeed", + position: "bottom_bar", + config: { + feeds: [ + { + title: "New York Times", + url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" + } + ], + showSourceTitle: true, + showPublishDate: true, + broadcastNewsFeeds: true, + broadcastNewsUpdates: true + } + }, + ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ diff --git a/install/prometheus-install.sh b/install/prometheus-install.sh index 2bc3da31..4c967daf 100644 --- a/install/prometheus-install.sh +++ b/install/prometheus-install.sh @@ -43,11 +43,11 @@ User=root Restart=always Type=simple ExecStart=/usr/local/bin/prometheus \ - --config.file=/etc/prometheus/prometheus.yml \ - --storage.tsdb.path=/var/lib/prometheus/ \ - --web.console.templates=/etc/prometheus/consoles \ - --web.console.libraries=/etc/prometheus/console_libraries \ - --web.listen-address=0.0.0.0:9090 + --config.file=/etc/prometheus/prometheus.yml \ + --storage.tsdb.path=/var/lib/prometheus/ \ + --web.console.templates=/etc/prometheus/consoles \ + --web.console.libraries=/etc/prometheus/console_libraries \ + --web.listen-address=0.0.0.0:9090 [Install] WantedBy=multi-user.target" >$service_path diff --git a/install/shinobi-install.sh b/install/shinobi-install.sh index be3bc831..f5b77fc3 100644 --- a/install/shinobi-install.sh +++ b/install/shinobi-install.sh @@ -15,11 +15,11 @@ update_os ubuntuversion=$(lsb_release -r | awk '{print $2}' | cut -d . -f1) if [ "$ubuntuversion" = "18" ] || [ "$ubuntuversion" -le "18" ]; then - apt install sudo wget -y - sudo apt install -y software-properties-common - sudo add-apt-repository universe -y - apt update -y - apt update --fix-missing -y + apt install sudo wget -y + sudo apt install -y software-properties-common + sudo add-apt-repository universe -y + apt update -y + apt update --fix-missing -y fi msg_info "Installing Dependencies" diff --git a/misc/bluetooth.sh b/misc/bluetooth.sh index ee775c8f..c3c26ab2 100644 --- a/misc/bluetooth.sh +++ b/misc/bluetooth.sh @@ -6,19 +6,19 @@ # https://github.com/tteck/Proxmox/raw/main/LICENSE if command -v pveversion >/dev/null 2>&1; then - echo -e "⚠️ Can't Run from the Proxmox Shell" - exit + echo -e "⚠️ Can't Run from the Proxmox Shell" + exit fi set -e clear while true; do - read -p "Start the Bluetooth Integration Preparation (y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac + read -p "Start the Bluetooth Integration Preparation (y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done clear @@ -45,17 +45,17 @@ cat <<"EOF" EOF read -r -p "Switch from dbus-daemon to dbus-broker? " prompt if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - cat <>/etc/apt/sources.list + cat <>/etc/apt/sources.list deb http://deb.debian.org/debian bullseye-backports main contrib non-free deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free EOF - apt-get update &>/dev/null - apt-get -t bullseye-backports install -y dbus-broker &>/dev/null - systemctl enable dbus-broker.service &>/dev/null + apt-get update &>/dev/null + apt-get -t bullseye-backports install -y dbus-broker &>/dev/null + systemctl enable dbus-broker.service &>/dev/null fi read -r -p "Install BlueZ? " prompt if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - apt-get -t bullseye-backports install -y bluez* &>/dev/null + apt-get -t bullseye-backports install -y bluez* &>/dev/null fi echo -e "Finished, reboot for changes to take affect" diff --git a/misc/code-server.sh b/misc/code-server.sh index 4fbf2946..921b47bd 100644 --- a/misc/code-server.sh +++ b/misc/code-server.sh @@ -6,7 +6,7 @@ # https://github.com/tteck/Proxmox/raw/main/LICENSE function header_info { - cat <<"EOF" + cat <<"EOF" ______ __ _____ / ____/___ ____/ /__ / ___/___ ______ _____ _____ / / / __ \/ __ / _ \ \__ \/ _ \/ ___/ | / / _ \/ ___/ @@ -37,36 +37,36 @@ alias die='EXIT=$? LINE=$LINENO error_exit' trap die ERR function error_exit() { - trap - ERR - local reason="Unknown failure occured." - local msg="${1:-$reason}" - local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" - echo -e "$flag $msg" 1>&2 - exit $EXIT + trap - ERR + local reason="Unknown failure occured." + local msg="${1:-$reason}" + local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" + echo -e "$flag $msg" 1>&2 + exit $EXIT } clear header_info if command -v pveversion >/dev/null 2>&1; then - echo -e "⚠️ Can't Install on Proxmox " - exit + echo -e "⚠️ Can't Install on Proxmox " + exit fi while true; do - read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac + read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } msg_info "Installing Dependencies" @@ -76,8 +76,8 @@ apt-get install -y git &>/dev/null msg_ok "Installed Dependencies" VERSION=$(curl -s https://api.github.com/repos/coder/code-server/releases/latest | - grep "tag_name" | - awk '{print substr($2, 3, length($2)-4) }') + grep "tag_name" | + awk '{print substr($2, 3, length($2)-4) }') msg_info "Installing Code-Server v${VERSION}" curl -fOL https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_amd64.deb &>/dev/null diff --git a/misc/container-restore-from-backup.sh b/misc/container-restore-from-backup.sh index 120ff2b7..6b51f08d 100644 --- a/misc/container-restore-from-backup.sh +++ b/misc/container-restore-from-backup.sh @@ -7,8 +7,8 @@ clear if command -v pveversion >/dev/null 2>&1; then - echo -e "⚠️ Can't Run from the Proxmox Shell" - exit + echo -e "⚠️ Can't Run from the Proxmox Shell" + exit fi YW=$(echo "\033[33m") BL=$(echo "\033[36m") @@ -23,16 +23,16 @@ CM="${GN}✓${CL}" CROSS="${RD}✗${CL}" APP="Home Assistant Container" while true; do - read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac + read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done clear function header_info { - cat <<"EOF" + cat <<"EOF" __ __ ___ _ __ __ / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ @@ -45,34 +45,34 @@ EOF header_info function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" } if [ -z "$(ls -A /var/lib/docker/volumes/hass_config/_data/backups/)" ]; then - msg_error "No backups found! \n" - exit 1 + msg_error "No backups found! \n" + exit 1 fi DIR=/var/lib/docker/volumes/hass_config/_data/restore if [ -d "$DIR" ]; then - msg_ok "Restore Directory Exists." + msg_ok "Restore Directory Exists." else - mkdir -p /var/lib/docker/volumes/hass_config/_data/restore - msg_ok "Created Restore Directory." + mkdir -p /var/lib/docker/volumes/hass_config/_data/restore + msg_ok "Created Restore Directory." fi cd /var/lib/docker/volumes/hass_config/_data/backups/ PS3="Please enter your choice: " files="$(ls -A .)" select filename in ${files}; do - msg_ok "You selected ${BL}${filename}${CL}" - break + msg_ok "You selected ${BL}${filename}${CL}" + break done msg_info "Stopping Home Assistant" docker stop homeassistant &>/dev/null diff --git a/misc/core-restore-from-backup.sh b/misc/core-restore-from-backup.sh index 1ee919f7..6a1c9526 100644 --- a/misc/core-restore-from-backup.sh +++ b/misc/core-restore-from-backup.sh @@ -7,8 +7,8 @@ clear if command -v pveversion >/dev/null 2>&1; then - echo -e "⚠️ Can't Run from the Proxmox Shell" - exit + echo -e "⚠️ Can't Run from the Proxmox Shell" + exit fi YW=$(echo "\033[33m") BL=$(echo "\033[36m") @@ -23,16 +23,16 @@ CM="${GN}✓${CL}" CROSS="${RD}✗${CL}" APP="Home Assistant Core" while true; do - read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac + read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done clear function header_info { - cat <<"EOF" + cat <<"EOF" __ __ ___ _ __ __ ______ / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / ____/___ ________ / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / __ \/ ___/ _ \ @@ -45,34 +45,34 @@ EOF header_info function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" } if [ -z "$(ls -A /root/.homeassistant/backups/)" ]; then - msg_error "No backups found! \n" - exit 1 + msg_error "No backups found! \n" + exit 1 fi DIR=/root/.homeassistant/restore if [ -d "$DIR" ]; then - msg_ok "Restore Directory Exists." + msg_ok "Restore Directory Exists." else - mkdir -p /root/.homeassistant/restore - msg_ok "Created Restore Directory." + mkdir -p /root/.homeassistant/restore + msg_ok "Created Restore Directory." fi cd /root/.homeassistant/backups/ PS3="Please enter your choice: " files="$(ls -A .)" select filename in ${files}; do - msg_ok "You selected ${BL}${filename}${CL}" - break + msg_ok "You selected ${BL}${filename}${CL}" + break done msg_info "Stopping Home Assistant" sudo service homeassistant stop diff --git a/misc/crowdsec.sh b/misc/crowdsec.sh index d18939d7..0ff7c02b 100644 --- a/misc/crowdsec.sh +++ b/misc/crowdsec.sh @@ -26,28 +26,28 @@ alias die='EXIT=$? LINE=$LINENO error_exit' trap die ERR function error_exit() { - trap - ERR - local reason="Unknown failure occured." - local msg="${1:-$reason}" - local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" - echo -e "$flag $msg" 1>&2 - exit $EXIT + trap - ERR + local reason="Unknown failure occured." + local msg="${1:-$reason}" + local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" + echo -e "$flag $msg" 1>&2 + exit $EXIT } if command -v pveversion >/dev/null 2>&1; then - echo -e "⚠️ Can't Install on Proxmox " - exit + echo -e "⚠️ Can't Install on Proxmox " + exit fi while true; do - read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac + read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done clear function header_info { - echo -e "${BL} + echo -e "${BL} _____ _ _____ / ____| | |/ ____| | | _ __ _____ ____| | (___ ___ ___ @@ -60,13 +60,13 @@ ${CL}" header_info function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } msg_info "Setting up ${APP} Repository" diff --git a/misc/edge-kernel.sh b/misc/edge-kernel.sh index df10d5e6..98110edf 100644 --- a/misc/edge-kernel.sh +++ b/misc/edge-kernel.sh @@ -7,7 +7,7 @@ # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/edge-kernel.sh)" function header_info { - cat <<"EOF" + cat <<"EOF" ____ _ ________ ______ __ __ __ __ / __ \ | / / ____/ / ____/___/ /___ ____ / //_/__ _________ ___ / /____ / /_/ / | / / __/ / __/ / __ / __ `/ _ \ / ,< / _ \/ ___/ __ \/ _ \/ / ___/ @@ -26,143 +26,143 @@ KER=$(curl -s https://api.github.com/repos/fabianishere/pve-edge-kernel/releases clear header_info while true; do - read -p "This is a Proxmox Edge Kernel Tool, USE AT YOUR OWN RISK. Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac + read -p "This is a Proxmox Edge Kernel Tool, USE AT YOUR OWN RISK. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done clear header_info show_menu() { - normal=$(echo "\033[m") - safe=$(echo "\033[32m") - menu=$(echo "\033[36m") - number=$(echo "\033[33m") - bgred=$(echo "\033[41m") - fgred=$(echo "\033[31m") - proxmox-boot-tool kernel list - echo -e "\nCurrent Kernel: ${menu}${KERNEL_ON}${normal}" - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${normal} Install Proxmox Edge Kernel ${menu}${KER}${normal} & Reboot\n" - printf "${menu}**${number} 2)${normal} Switch to Proxmox VE 7 ${menu}${PVE_KERNEL}${normal} Kernel & Reboot\n" - printf "${menu}**${number} 3)${normal} Switch to Proxmox Edge ${menu}${EDGE_KERNEL}${normal} Kernel & Reboot\n" - printf "${menu}**${number} 4)${normal} Unpin Current Kernel\n" - printf "${menu}**${number} 5)${normal} Remove All Current ${menu}${VER}*${normal} Proxmox Edge Kernels & Reboot\n" - printf "${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu, or ${fgred}x${normal} to exit." - read opt + normal=$(echo "\033[m") + safe=$(echo "\033[32m") + menu=$(echo "\033[36m") + number=$(echo "\033[33m") + bgred=$(echo "\033[41m") + fgred=$(echo "\033[31m") + proxmox-boot-tool kernel list + echo -e "\nCurrent Kernel: ${menu}${KERNEL_ON}${normal}" + printf "\n${menu}*********************************************${normal}\n" + printf "${menu}**${number} 1)${normal} Install Proxmox Edge Kernel ${menu}${KER}${normal} & Reboot\n" + printf "${menu}**${number} 2)${normal} Switch to Proxmox VE 7 ${menu}${PVE_KERNEL}${normal} Kernel & Reboot\n" + printf "${menu}**${number} 3)${normal} Switch to Proxmox Edge ${menu}${EDGE_KERNEL}${normal} Kernel & Reboot\n" + printf "${menu}**${number} 4)${normal} Unpin Current Kernel\n" + printf "${menu}**${number} 5)${normal} Remove All Current ${menu}${VER}*${normal} Proxmox Edge Kernels & Reboot\n" + printf "${menu}*********************************************${normal}\n" + printf "Please choose an option from the menu, or ${fgred}x${normal} to exit." + read opt } option_picked() { - msgcolor=$(echo "\033[01;31m") - normal=$(echo "\033[00;00m") - message=${@:-"${normal}Error: No message passed"} - printf "${msgcolor}${message}${normal}\n" + msgcolor=$(echo "\033[01;31m") + normal=$(echo "\033[00;00m") + message=${@:-"${normal}Error: No message passed"} + printf "${msgcolor}${message}${normal}\n" } clear header_info show_menu while [ "$opt" != "" ]; do - if [ "$opt" = "" ]; then - exit - else - case $opt in - 1) - while true; do - read -p "Are you sure you want to Install Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac - done - clear - option_picked "Installing Proxmox Edge Kernel & Rebooting" - apt-get install -y gnupg - curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | apt-key add - - echo "deb https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" >/etc/apt/sources.list.d/pve-edge-kernel.list - apt-get -y update - apt-get -y install pve-kernel-${VER}-edge - reboot - break - ;; - 2) - while true; do - read -p "Are you sure you want to Switch to Proxmox VE 7 ${PVE_KERNEL} Kernel & Reboot? Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac - done - clear - option_picked "Switching to Proxmox VE 7 Kernel & Rebooting" - proxmox-boot-tool kernel pin ${PVE_KERNEL} - reboot - break - ;; - 3) - while true; do - read -p "Are you sure you want to Switch to Proxmox ${EDGE_KERNEL} Edge Kernel & Reboot? Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac - done - clear - option_picked "Switching to Proxmox Edge Kernel & Rebooting" - proxmox-boot-tool kernel pin ${EDGE_KERNEL} - reboot - break - ;; - 4) - while true; do - read -p "Are you sure you want to Unpin the Current Kernel? Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac - done - clear - option_picked "Unpinning Current Kernel" - proxmox-boot-tool kernel unpin - clear - break - ;; - 5) - while true; do - read -p "Are you sure you want to Remove Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac - done - clear - option_picked "Removing Proxmox Edge Kernel & Rebooting" - apt --purge remove -y pve-kernel-${VER}*edge pve-headers-${VER}*edge - rm -rf /etc/apt/sources.list.d/pve-edge-kernel.list - proxmox-boot-tool kernel unpin - reboot - break - ;; - x) - exit - ;; - \n) - exit - ;; - *) - clear - option_picked "Please choose an option from the menu" - header_info - show_menu - ;; + if [ "$opt" = "" ]; then + exit + else + case $opt in + 1) + while true; do + read -p "Are you sure you want to Install Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac + done + clear + option_picked "Installing Proxmox Edge Kernel & Rebooting" + apt-get install -y gnupg + curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | apt-key add - + echo "deb https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" >/etc/apt/sources.list.d/pve-edge-kernel.list + apt-get -y update + apt-get -y install pve-kernel-${VER}-edge + reboot + break + ;; + 2) + while true; do + read -p "Are you sure you want to Switch to Proxmox VE 7 ${PVE_KERNEL} Kernel & Reboot? Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac + done + clear + option_picked "Switching to Proxmox VE 7 Kernel & Rebooting" + proxmox-boot-tool kernel pin ${PVE_KERNEL} + reboot + break + ;; + 3) + while true; do + read -p "Are you sure you want to Switch to Proxmox ${EDGE_KERNEL} Edge Kernel & Reboot? Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; esac - fi + done + clear + option_picked "Switching to Proxmox Edge Kernel & Rebooting" + proxmox-boot-tool kernel pin ${EDGE_KERNEL} + reboot + break + ;; + 4) + while true; do + read -p "Are you sure you want to Unpin the Current Kernel? Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac + done + clear + option_picked "Unpinning Current Kernel" + proxmox-boot-tool kernel unpin + clear + break + ;; + 5) + while true; do + read -p "Are you sure you want to Remove Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac + done + clear + option_picked "Removing Proxmox Edge Kernel & Rebooting" + apt --purge remove -y pve-kernel-${VER}*edge pve-headers-${VER}*edge + rm -rf /etc/apt/sources.list.d/pve-edge-kernel.list + proxmox-boot-tool kernel unpin + reboot + break + ;; + x) + exit + ;; + \n) + exit + ;; + *) + clear + option_picked "Please choose an option from the menu" + header_info + show_menu + ;; + esac + fi done header_info show_menu diff --git a/misc/filebrowser.sh b/misc/filebrowser.sh index 02545b48..d7dc5c17 100644 --- a/misc/filebrowser.sh +++ b/misc/filebrowser.sh @@ -6,7 +6,7 @@ # https://github.com/tteck/Proxmox/raw/main/LICENSE function header_info { - cat <<"EOF" + cat <<"EOF" _______ __ ____ / ____(_) /__ / __ )_________ _ __________ _____ / /_ / / / _ \/ __ / ___/ __ \ | /| / / ___/ _ \/ ___/ @@ -37,33 +37,33 @@ alias die='EXIT=$? LINE=$LINENO error_exit' trap die ERR function error_exit() { - trap - ERR - local reason="Unknown failure occured." - local msg="${1:-$reason}" - local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" - echo -e "$flag $msg" 1>&2 - exit $EXIT + trap - ERR + local reason="Unknown failure occured." + local msg="${1:-$reason}" + local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" + echo -e "$flag $msg" 1>&2 + exit $EXIT } clear header_info while true; do - read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac + read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done clear header_info function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } msg_info "Installing ${APP}" diff --git a/misc/kernel-clean.sh b/misc/kernel-clean.sh index 904bb197..2c06476a 100644 --- a/misc/kernel-clean.sh +++ b/misc/kernel-clean.sh @@ -6,7 +6,7 @@ # https://github.com/tteck/Proxmox/raw/main/LICENSE function header_info { - cat <<"EOF" + cat <<"EOF" __ __ __ ________ / //_/__ _________ ___ / / / ____/ /__ ____ _____ / ,< / _ \/ ___/ __ \/ _ \/ / / / / / _ \/ __ `/ __ \ @@ -33,108 +33,108 @@ current_kernel=$(uname -r) clear header_info while true; do - read -p "This will Clean Unused Kernel Images, USE AT YOUR OWN RISK. Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo -e "${RD}Please answer y/n${CL}" ;; - esac + read -p "This will Clean Unused Kernel Images, USE AT YOUR OWN RISK. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo -e "${RD}Please answer y/n${CL}" ;; + esac done clear function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } function check_root() { - if [[ $EUID -ne 0 ]]; then - echo -e "${CROSS}${RD}Error: This script must be ran as the root user.\n${CL}" - exit 1 - else - header_info - other_kernel - kernel_info - kernel_clean - fi + if [[ $EUID -ne 0 ]]; then + echo -e "${CROSS}${RD}Error: This script must be ran as the root user.\n${CL}" + exit 1 + else + header_info + other_kernel + kernel_info + kernel_clean + fi } VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" function other_kernel() { - if [[ "${VERSION}" == "bullseye" ]]; then - if [[ "$current_kernel" == *"edge"* ]]; then - echo -e "\n${CROSS} ${RD}ERROR:${CL} Proxmox ${BL}${current_kernel}${CL} Kernel Active" - echo -e "\nAn Active PVE Kernel is required to use Kernel Clean\n" - exit 1 - fi - if [[ "$current_kernel" == *"6.1"* || "$current_kernel" == *"6.2"* ]]; then - echo -e "\n${CROSS} ${RD}ERROR:${CL} Proxmox ${BL}${current_kernel}${CL} Kernel Active" - echo -e "\nThe script cannot be used when running opt-in kernels. \nProxmox VE's package management relies directly on the current default kernel, which is 5.15. \nTherefore, it is not possible to utilize this script. In this case, you should use autoremove instead. \n$(apt-get autoremove)\n" - exit 1 - fi + if [[ "${VERSION}" == "bullseye" ]]; then + if [[ "$current_kernel" == *"edge"* ]]; then + echo -e "\n${CROSS} ${RD}ERROR:${CL} Proxmox ${BL}${current_kernel}${CL} Kernel Active" + echo -e "\nAn Active PVE Kernel is required to use Kernel Clean\n" + exit 1 + fi + if [[ "$current_kernel" == *"6.1"* || "$current_kernel" == *"6.2"* ]]; then + echo -e "\n${CROSS} ${RD}ERROR:${CL} Proxmox ${BL}${current_kernel}${CL} Kernel Active" + echo -e "\nThe script cannot be used when running opt-in kernels. \nProxmox VE's package management relies directly on the current default kernel, which is 5.15. \nTherefore, it is not possible to utilize this script. In this case, you should use autoremove instead. \n$(apt-get autoremove)\n" + exit 1 fi + fi } function kernel_info() { - if [[ "$MODE" != "PBS" ]]; then - echo -e "${YW}PVE Version: ${BL}$(pveversion)\n${CL}" - fi - if [[ "$current_kernel" == *"pve"* ]]; then - echo -e "${YW}Current Kernel: ${BL}$current_kernel\n${CL}" - else - echo -e "\n${CROSS} ${RD}ERROR: No PVE Kernel Found\n${CL}" - exit 1 - fi + if [[ "$MODE" != "PBS" ]]; then + echo -e "${YW}PVE Version: ${BL}$(pveversion)\n${CL}" + fi + if [[ "$current_kernel" == *"pve"* ]]; then + echo -e "${YW}Current Kernel: ${BL}$current_kernel\n${CL}" + else + echo -e "\n${CROSS} ${RD}ERROR: No PVE Kernel Found\n${CL}" + exit 1 + fi } function kernel_clean() { - kernels=$(dpkg --list | grep 'kernel-.*-pve' | awk '{print $2}' | sort -V) - remove_kernels="" - for kernel in $kernels; do - if [ "$(echo $kernel | grep $current_kernel)" ]; then - break - else - echo -e "${BL}'$kernel' ${CL}${YW}has been added to the remove Kernel list\n${CL}" - remove_kernels+=" $kernel" - fi - done - msg_ok "Kernel Search Completed\n" - if [[ "$remove_kernels" != *"pve"* ]]; then - echo -e "${PARTY} ${GN}It appears there are no old Kernels on your system. \n${CL}" - msg_info "Exiting" - sleep 2 - msg_ok "Done" + kernels=$(dpkg --list | grep 'kernel-.*-pve' | awk '{print $2}' | sort -V) + remove_kernels="" + for kernel in $kernels; do + if [ "$(echo $kernel | grep $current_kernel)" ]; then + break else - read -p "Would you like to remove the $(echo $remove_kernels | awk '{print NF}') selected Kernels listed above? [y/n]: " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - msg_info "Removing ${CL}${RD}$(echo $remove_kernels | awk '{print NF}') ${CL}${YW}old Kernels${CL}" - /usr/bin/apt purge -y $remove_kernels >/dev/null 2>&1 - msg_ok "Successfully Removed Kernels" - msg_info "Updating GRUB" - /usr/sbin/update-grub >/dev/null 2>&1 - msg_ok "Successfully Updated GRUB" - msg_info "Exiting" - sleep 2 - msg_ok "Done" - else - msg_info "Exiting" - sleep 2 - msg_ok "Done" - fi + echo -e "${BL}'$kernel' ${CL}${YW}has been added to the remove Kernel list\n${CL}" + remove_kernels+=" $kernel" fi + done + msg_ok "Kernel Search Completed\n" + if [[ "$remove_kernels" != *"pve"* ]]; then + echo -e "${PARTY} ${GN}It appears there are no old Kernels on your system. \n${CL}" + msg_info "Exiting" + sleep 2 + msg_ok "Done" + else + read -p "Would you like to remove the $(echo $remove_kernels | awk '{print NF}') selected Kernels listed above? [y/n]: " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + msg_info "Removing ${CL}${RD}$(echo $remove_kernels | awk '{print NF}') ${CL}${YW}old Kernels${CL}" + /usr/bin/apt purge -y $remove_kernels >/dev/null 2>&1 + msg_ok "Successfully Removed Kernels" + msg_info "Updating GRUB" + /usr/sbin/update-grub >/dev/null 2>&1 + msg_ok "Successfully Updated GRUB" + msg_info "Exiting" + sleep 2 + msg_ok "Done" + else + msg_info "Exiting" + sleep 2 + msg_ok "Done" + fi + fi } if ! command -v pveversion >/dev/null 2>&1; then - echo -e " Switching to PBS mode" - MODE="PBS" - sleep 2 + echo -e " Switching to PBS mode" + MODE="PBS" + sleep 2 else - MODE="PVE" + MODE="PVE" fi check_root diff --git a/misc/scaling-governor.sh b/misc/scaling-governor.sh index 50bfbd0b..c2be28bc 100644 --- a/misc/scaling-governor.sh +++ b/misc/scaling-governor.sh @@ -6,8 +6,8 @@ # https://github.com/tteck/Proxmox/raw/main/LICENSE header_info() { - clear - cat <