backed up scripts

This commit is contained in:
2023-08-20 18:48:41 -05:00
parent d0fb60d373
commit e56de1079d
20 changed files with 1341 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
#!/bin/bash
docker restart gluetun && echo gluetun restarted
sleep 45
docker restart qbittorrent && echo qbittorrent restarted
sleep 5
docker restart sabnzbd && echo sabnzbd restarted
sleep 5
docker restart jdownloader && echo jdownloader restarted
sleep 5

View File

@@ -1,26 +1,32 @@
#!/bin/bash
# proxyserver
echo "starting proxyserver backup"
ssh proxyserver rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxyserver/akanealw/
ssh proxyserver sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxyserver/root/
# dockerserver
echo "starting dockerserver backup"
ssh dockerserver rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/dockerserver/akanealw/
ssh dockerserver sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/dockerserver/root/
# plexserver
echo "starting plexserver backup"
ssh plexserver rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/plexserver/akanealw/
ssh plexserver sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/plexserver/root/
# proxmox1
echo "starting proxmox1 backup"
ssh proxmox1 rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxmox1/akanealw/
ssh proxmox1 sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxmox1/root/
# proxmox2
echo "starting proxmox2 backup"
ssh proxmox2 rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxmox2/akanealw/
ssh proxmox2 sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxmox2/root/
# fileserver
echo "starting fileserver backup"
cp -prv /home/akanealw/scripts/ /home/akanealw/gitrepos/fileserver/files/bashscripts/fileserver/akanealw/
sudo cp -prv /root/scripts/ /home/akanealw/gitrepos/fileserver/files/bashscripts/fileserver/root/

View File

@@ -0,0 +1,34 @@
#!/bin/bash
# proxyserver
echo "starting proxyserver backup"
ssh proxyserver rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxyserver/akanealw/
ssh proxyserver sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxyserver/root/
# dockerserver
echo "starting dockerserver backup"
ssh dockerserver rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/dockerserver/akanealw/
ssh dockerserver sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/dockerserver/root/
# plexserver
echo "starting plexserver backup"
ssh plexserver rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/plexserver/akanealw/
ssh plexserver sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/plexserver/root/
# proxmox1
echo "starting proxmox1 backup"
ssh proxmox1 rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxmox1/akanealw/
ssh proxmox1 sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxmox1/root/
# proxmox2
echo "starting proxmox2 backup"
ssh proxmox2 rsync -azvP /home/akanealw/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxmox2/akanealw/
ssh proxmox2 sudo rsync -azvP /root/scripts/ akanealw@fileserver:/home/akanealw/gitrepos/fileserver/files/bashscripts/proxmox2/root/
# fileserver
echo "starting fileserver backup"
cp -prv /home/akanealw/scripts/ /home/akanealw/gitrepos/fileserver/files/bashscripts/fileserver/akanealw/
sudo cp -prv /root/scripts/ /home/akanealw/gitrepos/fileserver/files/bashscripts/fileserver/root/
# chown all files copied
sudo chown -R akanealw:akanealw /home/akanealw/gitrepos/fileserver/files/

View File

@@ -0,0 +1,248 @@
#!/bin/bash
# autoreply config update dialog with no
if [[ ! -f /etc/apt/apt.conf.d/local ]] ; then
echo "Dpkg::Options {" >> /etc/apt/apt.conf.d/local
echo " "--force-confdef";" >> /etc/apt/apt.conf.d/local
echo " "--force-confold";" >> /etc/apt/apt.conf.d/local
echo "}" >> /etc/apt/apt.conf.d/local
fi
# update bookworm to new debian.sources file
if [[ -f /etc/apt/sources.list ]] ; then
isInFile=$(cat /etc/apt/sources.list | grep -c "bullseye")
if [ $isInFile -eq 0 ]; then
mkdir /etc/apt/mirrors > /dev/null 2>&1
echo "https://deb.debian.org/debian" >> /etc/apt/mirrors/debian.list
echo "https://deb.debian.org/debian-security" >> /etc/apt/mirrors/debian-security.list
echo "Types: deb deb-src" >> /etc/apt/sources.list.d/debian.sources
echo "URIs: mirror+file:///etc/apt/mirrors/debian.list" >> /etc/apt/sources.list.d/debian.sources
echo "Suites: bookworm bookworm-updates bookworm-backports" >> /etc/apt/sources.list.d/debian.sources
echo "Components: main contrib non-free non-free-firmware" >> /etc/apt/sources.list.d/debian.sources
echo "" >> /etc/apt/sources.list.d/debian.sources
echo "Types: deb deb-src" >> /etc/apt/sources.list.d/debian.sources
echo "URIs: mirror+file:///etc/apt/mirrors/debian-security.list" >> /etc/apt/sources.list.d/debian.sources
echo "Suites: bookworm-security" >> /etc/apt/sources.list.d/debian.sources
echo "Components: main" >> /etc/apt/sources.list.d/debian.sources
mv /etc/apt/sources.list /etc/apt/sources.list.bak > /dev/null 2>&1
rm /etc/apt/sources.list.11.backup > /dev/null 2>&1
fi
fi
# update and upgrade
apt-get update
apt-get upgrade -y
# download and install packages
apt-get install -y lsb-release cron qemu-guest-agent sudo nano curl wget zip unzip git rsync man-db cifs-utils nfs-common parted libtalloc2 libwbclient0 net-tools gnupg apt-transport-https tmux gdisk bash-completion
# add akanealw user if not existing
isInFile=$(cat /etc/passwd | grep -c "akanealw")
if [ $isInFile -eq 0 ]; then
echo "Set password for akanealw"
useradd -m -p $(openssl passwd -1 ${PASSWORD}) -s /bin/bash -d /home/akanealw akanealw
mkdir /home/akanealw/.ssh
chown akanealw:akanealw /home/akanealw/.ssh
chmod 700 /home/akanealw/.ssh
cp /root/.ssh/authorized_keys /home/akanealw/.ssh > /dev/null 2>&1
chown akanealw:akanealw /home/akanealw/.ssh/authorized_keys > /dev/null 2>&1
chmod 600 /home/akanealw/.ssh/authorized_keys > /dev/null 2>&1
fi
# create akanealw file in /etc/sudoers.d
if [[ ! -f /etc/sudoers.d/akanealw ]] ; then
echo "akanealw ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/akanealw
fi
# enable ping for all users
setcap 'cap_net_admin,cap_net_raw+ep' $(which ping)
# remove all motd
rm /etc/motd > /dev/null 2>&1
# disable systemd-networkd-wait-online.service
systemctl disable systemd-networkd-wait-online.service
# git config
git config --global credential.helper store
git config --global user.name "akanealw"
git config --global user.email "akanealw@gmail.com"
git config --global init.defaultBranch main
# show ip in /etc/issue
name=$(basename /sys/class/net/e*)
isInFile=$(cat /etc/issue | grep -c "$name")
if [ $isInFile -eq 0 ]; then
cp /etc/issue /etc/issue.bak
echo "$name: \4{$name}" >> /etc/issue
echo "" >> /etc/issue
fi
# set input preferences
if [[ ! -f /etc/inputrc.bak ]] ; then
cp /etc/inputrc /etc/inputrc.bak > /dev/null 2>&1
fi
rm /etc/inputrc > /dev/null 2>&1
cp /etc/inputrc.bak /etc/inputrc
echo "" >> /etc/inputrc
echo "set completion-ignore-case On" >> /etc/inputrc
# set bash preferences and aliases
if [[ -f /etc/bash.bashrc.default ]] ; then
mv /etc/bash.bashrc.default /etc/bash.bashrc.bak > /dev/null 2>&1
fi
if [[ ! -f /etc/bash.bashrc.bak ]] ; then
cp /etc/bash.bashrc /etc/bash.bashrc.bak > /dev/null 2>&1
fi
rm /etc/bash.bashrc > /dev/null 2>&1
cp /etc/bash.bashrc.bak /etc/bash.bashrc
echo "" >> /etc/bash.bashrc
echo "# custom settings and aliases" >> /etc/bash.bashrc
echo "set -o noclobber" >> /etc/bash.bashrc
echo "alias lsa='ls -alhvF'" >> /etc/bash.bashrc
echo "alias systart='sudo systemctl start'" >> /etc/bash.bashrc
echo "alias systop='sudo systemctl stop'" >> /etc/bash.bashrc
echo "alias sysrest='sudo systemctl restart'" >> /etc/bash.bashrc
echo "alias systat='sudo systemctl status'" >> /etc/bash.bashrc
echo "alias aptupy='sudo apt update && sudo apt upgrade -y'" >> /etc/bash.bashrc
echo "alias aptiy='sudo apt install -y'" >> /etc/bash.bashrc
echo "alias aptry='sudo apt remove -y'" >> /etc/bash.bashrc
echo "alias aptrpy='sudo apt remove --purge -y'" >> /etc/bash.bashrc
echo "alias aptary='sudo apt autoremove -y'" >> /etc/bash.bashrc
echo "alias apts='sudo apt search'" >> /etc/bash.bashrc
echo "alias aptl='sudo apt list --installed'" >> /etc/bash.bashrc
echo "alias aptsh='sudo apt show'" >> /etc/bash.bashrc
echo "alias aptac='sudo apt-get autoclean'" >> /etc/bash.bashrc
echo "alias dpkgi='sudo dpkg -i'" >> /etc/bash.bashrc
echo "alias tmxls='tmux ls'" >> /etc/bash.bashrc
echo "alias tmxa='tmux attach -t'" >> /etc/bash.bashrc
echo "alias dc='docker compose'" >> /etc/bash.bashrc
echo "alias dcup='docker compose up -d'" >> /etc/bash.bashrc
echo "alias dcaup='docker compose -f admin-compose.yml up -d'" >> /etc/bash.bashrc
echo "alias dcdown='docker compose down'" >> /etc/bash.bashrc
echo "alias dcadown='docker compose -f admin-compose.yml down'" >> /etc/bash.bashrc
echo "alias dcpull='docker compose pull'" >> /etc/bash.bashrc
echo "alias dcapull='docker compose -f admin-compose.yml pull'" >> /etc/bash.bashrc
echo "alias dps='docker ps'" >> /etc/bash.bashrc
echo "alias dipaf='docker image prune -a -f'" >> /etc/bash.bashrc
# create tmux config
rm /etc/tmux.conf* > /dev/null 2>&1
echo "unbind C-b" >> /etc/tmux.conf
echo "set-option -g prefix C-a" >> /etc/tmux.conf
echo "bind-key C-a send-prefix" >> /etc/tmux.conf
# create credentials and map network drives
isInFile=$(cat /etc/fstab | grep -c "192.168.1.41")
if [ $isInFile -eq 0 ]; then
mkdir /mnt/truenasdata > /dev/null 2>&1
chown akanealw:akanealw /mnt/truenasdata
echo "# nfs shares" >> /etc/fstab
echo "192.168.1.41:/mnt/data /mnt/truenasdata nfs defaults,nolock,soft,vers=4.2 0 0" >> /etc/fstab
fi
# ask to install samba
if [[ ! -f /etc/samba/smb.conf ]] ; then
read -r -p "Install Samba? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]] ; then
apt-get install -y samba --no-install-recommends
# configure default samba share
(echo "8ung1e1!"; sleep 1; echo "8ung1e1!" ) | smbpasswd -s -a akanealw
sed -i s/WORKGROUP/akanealw/ /etc/samba/smb.conf
isInFile=$(cat /etc/samba/smb.conf | grep -c "akanealw]")
if [ $isInFile -eq 0 ]; then
echo "[akanealw]" >> /etc/samba/smb.conf
echo " comment = akanealw" >> /etc/samba/smb.conf
echo " read only = no" >> /etc/samba/smb.conf
echo " path = /home/akanealw" >> /etc/samba/smb.conf
echo " guest ok = no" >> /etc/samba/smb.conf
echo "" >> /etc/samba/smb.conf
fi
fi
fi
# ask to install docker
if [[ ! -f /etc/apt/keyrings/docker.gpg ]] ; then
read -r -p "Install Docker? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
# prepare for install
apt-get update
apt-get install -y ca-certificates curl gnupg lsb-release
mkdir -p /home/akanealw/docker/appdata
chown -R akanealw:akanealw /home/akanealw/docker
mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# install docker
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# post install
groupadd docker > /dev/null 2>&1
usermod -aG docker akanealw
systemctl enable docker.service
systemctl enable containerd.service
fi
fi
# ask to regenerate machine-id
if [[ ! -f /etc/machine-id-regenerated ]] ; then
read -r -p "Regenerate machine-id? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
# regenerate machine-id
rm -f /etc/machine-id /var/lib/dbus/machine-id
dbus-uuidgen --ensure=/etc/machine-id
dbus-uuidgen --ensure
touch /etc/machine-id-regenerated
fi
fi
# ask to regenerate ssh host keys
if [[ ! -d /etc/cloud ]] ; then
if [[ ! -f /home/akanealw/.ssh/ssh_keys_regenerated ]] ; then
read -r -p "Regenerate SSH Keys? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
mkdir /home/akanealw/.ssh
touch /home/akanealw/.ssh/ssh_keys_regenerated
chmod 700 /home/akanealw/.ssh
chown -R akanealw:akanealw /home/akanealw/.ssh
fi
fi
fi
# ask to set static ip address
if [[ ! -d /etc/cloud ]] ; then
if [[ ! -f /etc/network/interfaces.bak ]] ; then
read -r -p "Set Static IP address? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]] ; then
read -r -p "Enter Static IP Address with subnet prefix: " staticip
read -r -p "Enter Gateway IP Address: " gatewayip
read -r -p "Enter Primary DNS IP Address: " dnsip1
read -r -p "Enter Secondary DNS IP Address: " dnsip2
# get adapter name
name=$(basename /sys/class/net/e*)
# backup original interfaces file
if [[ ! -f /etc/network/interfaces.bak ]] ; then
cp /etc/network/interfaces /etc/network/interfaces.bak
fi
rm /etc/network/interfaces
cp /etc/network/interfaces.bak /etc/network/interfaces
# set static ip
sed -i "s,^iface $name inet dhcp*,iface $name inet static," /etc/network/interfaces
echo " address $staticip" >> /etc/network/interfaces
echo " gateway $gatewayip" >> /etc/network/interfaces
# backup resolv.conf file
if [[ ! -f /etc/resolv.conf.bak ]] ; then
cp /etc/resolv.conf /etc/resolv.conf.bak
fi
rm /etc/resolv.conf
# set primary dns ip
echo "nameserver $dnsip1" >> /etc/resolv.conf
echo "nameserver $dnsip2" >> /etc/resolv.conf
# restart the interface
ifdown $name
ifup $name
fi
fi
fi

View File

@@ -2,3 +2,4 @@
find "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache/PhotoTranscoder" -name "*.jpg" -type f -mtime +5 -delete
find "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache/PhotoTranscoder" -name "*.ppm" -type f -mtime +5 -delete
curl -fsS -m 10 --retry 5 -o /dev/null https://uptimekuma.akanealw.com/api/push/vOOCgMo8GW?status=up&msg=OK&ping=

View File

@@ -0,0 +1,11 @@
#!/bin/bash
until ping -c1 192.168.1.41 >/dev/null 2>&1; do :; done
sleep 45
mount -t nfs 192.168.1.41:/mnt/data/media /mnt/truenasmedia
sleep 15
/usr/sbin/pct start 102
sleep 15
/usr/sbin/pct start 107
sleep 15
/usr/sbin/qm start 200

View File

@@ -0,0 +1,140 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2023 tteck
# Author: tteck (tteckster)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
function header_info {
cat <<"EOF"
__ __ __ ________
/ //_/__ _________ ___ / / / ____/ /__ ____ _____
/ ,< / _ \/ ___/ __ \/ _ \/ / / / / / _ \/ __ `/ __ \
/ /| / __/ / / / / / __/ / / /___/ / __/ /_/ / / / /
/_/ |_\___/_/ /_/ /_/\___/_/ \____/_/\___/\__,_/_/ /_/
EOF
}
set -euo pipefail
shopt -s inherit_errexit nullglob
YW=$(echo "\033[33m")
BL=$(echo "\033[36m")
RD=$(echo "\033[01;31m")
BGN=$(echo "\033[4;92m")
GN=$(echo "\033[1;92m")
DGN=$(echo "\033[32m")
CL=$(echo "\033[m")
BFR="\\r\\033[K"
HOLD="-"
CM="${GN}${CL}"
CROSS="${RD}${CL}"
PARTY="🎉"
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
done
clear
function msg_info() {
local msg="$1"
echo -ne " ${HOLD} ${YW}${msg}..."
}
function msg_ok() {
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
}
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
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
}
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"
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
else
MODE="PVE"
fi
check_root

View File

@@ -0,0 +1,243 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2023 tteck
# Author: tteck (tteckster)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
header_info() {
clear
cat <<"EOF"
____ _ ________ ____ __ ____ __ ____
/ __ \ | / / ____/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / /
/ /_/ / | / / __/ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / /
/ ____/| |/ / /___ / ____/ /_/ (__ ) /_ _/ // / / (__ ) /_/ /_/ / / /
/_/ |___/_____/ /_/ \____/____/\__/ /___/_/ /_/____/\__/\__,_/_/_/
EOF
}
RD=$(echo "\033[01;31m")
YW=$(echo "\033[33m")
GN=$(echo "\033[1;92m")
CL=$(echo "\033[m")
BFR="\\r\\033[K"
HOLD="-"
CM="${GN}${CL}"
CROSS="${RD}${CL}"
set -euo pipefail
shopt -s inherit_errexit nullglob
msg_info() {
local msg="$1"
echo -ne " ${HOLD} ${YW}${msg}..."
}
msg_ok() {
local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
}
msg_error() {
local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
}
start_routines() {
header_info
VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)"
if lscpu | grep -qP 'Vendor ID:.*GenuineIntel' && lscpu | grep -qP 'Model name:.*N' && [[ "$VERSION" == "bullseye" ]]; then
whiptail --msgbox --title "N-SERIES PROCESSOR DETECTED" "To ensure compatibility with Proxmox VE on systems equipped with N-series processors, it is recommended to install Proxmox Virtual Environment 8" 10 58
fi
CHOICE=$(whiptail --title "SOURCES" --menu "The package manager will use the correct sources to update and install packages on your Proxmox VE server.\n \nCorrect Proxmox VE sources?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Correcting Proxmox VE Sources"
cat <<EOF >/etc/apt/sources.list
deb http://ftp.debian.org/debian ${VERSION} main contrib
deb http://ftp.debian.org/debian ${VERSION}-updates main contrib
deb http://security.debian.org/debian-security ${VERSION}-security main contrib
EOF
msg_ok "Corrected Proxmox VE Sources"
;;
no)
msg_error "Selected no to Correcting Proxmox VE Sources"
;;
esac
CHOICE=$(whiptail --title "PVE-ENTERPRISE" --menu "The 'pve-enterprise' repository is only available to users who have purchased a Proxmox VE subscription.\n \nDisable 'pve-enterprise' repository?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Disabling 'pve-enterprise' repository"
cat <<EOF >/etc/apt/sources.list.d/pve-enterprise.list
# deb https://enterprise.proxmox.com/debian/pve ${VERSION} pve-enterprise
EOF
msg_ok "Disabled 'pve-enterprise' repository"
;;
no)
msg_error "Selected no to Disabling 'pve-enterprise' repository"
;;
esac
CHOICE=$(whiptail --title "PVE-NO-SUBSCRIPTION" --menu "The 'pve-no-subscription' repository provides access to all of the open-source components of Proxmox VE.\n \nEnable 'pve-no-subscription' repository?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Enabling 'pve-no-subscription' repository"
cat <<EOF >/etc/apt/sources.list.d/pve-install-repo.list
deb http://download.proxmox.com/debian/pve ${VERSION} pve-no-subscription
EOF
msg_ok "Enabled 'pve-no-subscription' repository"
;;
no)
msg_error "Selected no to Enabling 'pve-no-subscription' repository"
;;
esac
if [[ "${VERSION}" == "bookworm" ]]; then
CHOICE=$(whiptail --title "CEPH PACKAGE REPOSITORIES" --menu "The 'Ceph Package Repositories' provides access to both the 'no-subscription' and 'enterprise' repositories.\n \nEnable 'ceph package repositories?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Enabling 'ceph package repositories'"
cat <<EOF >/etc/apt/sources.list.d/ceph.list
# deb http://download.proxmox.com/debian/ceph-quincy bookworm enterprise
deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription
EOF
msg_ok "Enabled 'ceph package repositories'"
;;
no)
msg_error "Selected no to Enabling 'ceph package repositories'"
;;
esac
fi
CHOICE=$(whiptail --title "PVETEST" --menu "The 'pvetest' repository can give advanced users access to new features and updates before they are officially released.\n \nAdd (Disabled) 'pvetest' repository?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Adding 'pvetest' repository and set disabled"
cat <<EOF >/etc/apt/sources.list.d/pvetest-for-beta.list
# deb http://download.proxmox.com/debian/pve ${VERSION} pvetest
EOF
msg_ok "Added 'pvetest' repository"
;;
no)
msg_error "Selected no to Adding 'pvetest' repository"
;;
esac
if [[ ! -f /etc/apt/apt.conf.d/no-nag-script ]]; then
CHOICE=$(whiptail --title "SUBSCRIPTION NAG" --menu "This will disable the nag message reminding you to purchase a subscription every time you log in to the web interface.\n \nDisable subscription nag?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
whiptail --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58
msg_info "Disabling subscription nag"
echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" >/etc/apt/apt.conf.d/no-nag-script
apt --reinstall install proxmox-widget-toolkit &>/dev/null
msg_ok "Disabled subscription nag (Delete browser cache)"
;;
no)
whiptail --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58
msg_error "Selected no to Disabling subscription nag"
;;
esac
fi
if ! systemctl is-active --quiet pve-ha-lrm; then
CHOICE=$(whiptail --title "HIGH AVAILABILITY" --menu "Enable high availability?" 10 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Enabling high availability"
systemctl enable -q --now pve-ha-lrm
systemctl enable -q --now pve-ha-crm
systemctl enable -q --now corosync
msg_ok "Enabled high availability"
;;
no)
msg_error "Selected no to Enabling high availability"
;;
esac
fi
if systemctl is-active --quiet pve-ha-lrm; then
CHOICE=$(whiptail --title "HIGH AVAILABILITY" --menu "If you plan to utilize a single node instead of a clustered environment, you can disable unnecessary high availability (HA) services, thus reclaiming system resources.\n\nIf HA becomes necessary at a later stage, the services can be re-enabled.\n\nDisable high availability?" 18 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Disabling high availability"
systemctl disable -q --now pve-ha-lrm
systemctl disable -q --now pve-ha-crm
systemctl disable -q --now corosync
msg_ok "Disabled high availability"
;;
no)
msg_error "Selected no to Disabling high availability"
;;
esac
fi
CHOICE=$(whiptail --title "UPDATE" --menu "\nUpdate Proxmox VE now?" 11 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Updating Proxmox VE (Patience)"
apt-get update &>/dev/null
apt-get -y dist-upgrade &>/dev/null
msg_ok "Updated Proxmox VE"
;;
no)
msg_error "Selected no to Updating Proxmox VE"
;;
esac
CHOICE=$(whiptail --title "REBOOT" --menu "\nReboot Proxmox VE now? (recommended)" 11 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Rebooting Proxmox VE"
sleep 2
msg_ok "Completed Post Install Routines"
reboot
;;
no)
msg_error "Selected no to Rebooting Proxmox VE (Reboot recommended)"
msg_ok "Completed Post Install Routines"
;;
esac
}
header_info
echo -e "\nThis script will Perform Post Install Routines.\n"
while true; do
read -p "Start the Proxmox VE Post Install Script (y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) clear; exit ;;
*) echo "Please answer yes or no." ;;
esac
done
if ! command -v pveversion >/dev/null 2>&1; then
header_info
msg_error "\n No PVE Detected!\n"
exit
fi
start_routines

View File

@@ -0,0 +1,73 @@
#!/bin/bash
# autoreply config update dialog with no
if [[ ! -f /etc/apt/apt.conf.d/local ]] ; then
echo "Dpkg::Options {" >> /etc/apt/apt.conf.d/local
echo " "--force-confdef";" >> /etc/apt/apt.conf.d/local
echo " "--force-confold";" >> /etc/apt/apt.conf.d/local
echo "}" >> /etc/apt/apt.conf.d/local
fi
# update and upgrade
apt-get update
apt-get upgrade -y
# download and install packages
apt-get install -y sudo curl wget zip unzip git man-db cifs-utils nfs-common ntfs-3g parted libtalloc2 libwbclient0 net-tools gnupg apt-transport-https tmux gdisk bash-completion
# update templates
pveam update
# remove all motd
rm /etc/motd > /dev/null 2>&1
# set input preferences
if [[ ! -f /etc/inputrc.bak ]] ; then
cp /etc/inputrc /etc/inputrc.bak > /dev/null 2>&1
fi
rm /etc/inputrc > /dev/null 2>&1
cp /etc/inputrc.bak /etc/inputrc
echo "" >> /etc/inputrc
echo "set completion-ignore-case On" >> /etc/inputrc
# set bash preferences and aliases
if [[ -f /etc/bash.bashrc.default ]] ; then
mv /etc/bash.bashrc.default /etc/bash.bashrc.bak > /dev/null 2>&1
fi
if [[ ! -f /etc/bash.bashrc.bak ]] ; then
cp /etc/bash.bashrc /etc/bash.bashrc.bak > /dev/null 2>&1
fi
rm /etc/bash.bashrc > /dev/null 2>&1
cp /etc/bash.bashrc.bak /etc/bash.bashrc
echo "" >> /etc/bash.bashrc
echo "# custom settings and aliases" >> /etc/bash.bashrc
echo "set -o noclobber" >> /etc/bash.bashrc
echo "alias lsa='ls -alhvF'" >> /etc/bash.bashrc
echo "alias systart='sudo systemctl start'" >> /etc/bash.bashrc
echo "alias systop='sudo systemctl stop'" >> /etc/bash.bashrc
echo "alias sysrest='sudo systemctl restart'" >> /etc/bash.bashrc
echo "alias systat='sudo systemctl status'" >> /etc/bash.bashrc
echo "alias aptupy='sudo apt update && sudo apt upgrade -y'" >> /etc/bash.bashrc
echo "alias aptiy='sudo apt install -y'" >> /etc/bash.bashrc
echo "alias aptry='sudo apt remove -y'" >> /etc/bash.bashrc
echo "alias aptrpy='sudo apt remove --purge -y'" >> /etc/bash.bashrc
echo "alias aptary='sudo apt autoremove -y'" >> /etc/bash.bashrc
echo "alias apts='sudo apt search'" >> /etc/bash.bashrc
echo "alias aptl='sudo apt list --installed'" >> /etc/bash.bashrc
echo "alias aptsh='sudo apt show'" >> /etc/bash.bashrc
echo "alias aptac='sudo apt-get autoclean'" >> /etc/bash.bashrc
echo "alias dpkgi='sudo dpkg -i'" >> /etc/bash.bashrc
echo "alias tmxls='tmux ls'" >> /etc/bash.bashrc
echo "alias tmxa='tmux attach -t'" >> /etc/bash.bashrc
# create tmux config
rm /etc/tmux.conf* > /dev/null 2>&1
echo "unbind C-b" >> /etc/tmux.conf
echo "set-option -g prefix C-a" >> /etc/tmux.conf
echo "bind-key C-a send-prefix" >> /etc/tmux.conf
# git config
git config --global credential.helper store
git config --global user.name "akanealw"
git config --global user.email "akanealw@gmail.com"
git config --global init.defaultBranch main

View File

@@ -0,0 +1,49 @@
#!/bin/bash
cd /root/cloud-images
# remove old images
rm * > /dev/null 2>&1
rsync -avz root@proxmox2:/root/cloud-images/*.tar.xz /root/cloud-images/
rsync -avz root@proxmox2:/root/cloud-images/*.qcow2 /root/cloud-images/
# debian 12 bookworm cloud
tar -xvf debian-12-genericcloud-amd64.tar.xz
mv disk.raw debian-12-generic-amd64.raw
/usr/sbin/qm set 303 --delete scsi0
sleep 3
/usr/sbin/qm set 303 --delete unused0
sleep 3
/usr/sbin/qm set 303 --scsi0 local-zfs:0,import-from=/root/cloud-images/debian-12-generic-amd64.raw,discard=on,ssd=1
sleep 3
/usr/sbin/qm set 303 --boot order=scsi0
sleep 3
/usr/sbin/qm cloudinit update 303
sleep 3
# ubuntu jammy 22.04
/usr/sbin/qm set 314 --delete scsi0
sleep 3
/usr/sbin/qm set 314 --delete unused0
sleep 3
/usr/sbin/qm set 314 --scsi0 local-zfs:0,import-from=/root/cloud-images/ubuntu-22.04-server-cloudimg-amd64.qcow2,discard=on,ssd=1
sleep 3
/usr/sbin/qm set 314 --boot order=scsi0
sleep 3
/usr/sbin/qm cloudinit update 314
sleep 3
# ubuntu jammy 22.04 minimal
/usr/sbin/qm set 315 --delete scsi0
sleep 3
/usr/sbin/qm set 315 --delete unused0
sleep 3
/usr/sbin/qm set 315 --scsi0 local-zfs:0,import-from=/root/cloud-images/ubuntu-22.04-minimal-cloudimg-amd64.qcow2,discard=on,ssd=1
sleep 3
/usr/sbin/qm set 315 --boot order=scsi0
sleep 3
/usr/sbin/qm cloudinit update 315
sleep 3
curl -fsS -m 10 --retry 5 -o /dev/null https://uptimekuma.akanealw.com/api/push/HFKN90p5e9?status=up&msg=OK&ping=

View File

@@ -0,0 +1,4 @@
#!/bin/bash
ssh dockerserver ./scripts/restart-gluetun-and-services.sh
curl -fsS -m 10 --retry 5 -o /dev/null https://uptimekuma.akanealw.com/api/push/eT36YM3T94?status=up&msg=OK&ping=

View File

@@ -0,0 +1,3 @@
#!/bin/bash
ssh proxmox1 sudo poweroff

View File

@@ -0,0 +1,3 @@
#!/bin/bash
wakeonlan 68:1c:a2:13:05:f5

View File

@@ -0,0 +1,48 @@
#!/bin/bash
cd /root/cloud-images
# remove old images
rm * > /dev/null 2>&1
# debian 12 bookworm cloud
wget -q https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.tar.xz
tar -xvf debian-12-genericcloud-amd64.tar.xz
mv disk.raw debian-12-generic-amd64.raw
/usr/sbin/qm set 302 --delete scsi0
sleep 3
/usr/sbin/qm set 302 --delete unused0
sleep 3
/usr/sbin/qm set 302 --scsi0 local-zfs:0,import-from=/root/cloud-images/debian-12-generic-amd64.raw,discard=on,ssd=1
sleep 3
/usr/sbin/qm set 302 --boot order=scsi0
sleep 3
/usr/sbin/qm cloudinit update 302
sleep 3
# ubuntu jammy 22.04
wget -q -O ubuntu-22.04-server-cloudimg-amd64.qcow2 https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
/usr/sbin/qm set 311 --delete scsi0
sleep 3
/usr/sbin/qm set 311 --delete unused0
sleep 3
/usr/sbin/qm set 311 --scsi0 local-zfs:0,import-from=/root/cloud-images/ubuntu-22.04-server-cloudimg-amd64.qcow2,discard=on,ssd=1
sleep 3
/usr/sbin/qm set 311 --boot order=scsi0
sleep 3
/usr/sbin/qm cloudinit update 311
sleep 3
# ubuntu jammy 22.04 minimal
wget -q -O ubuntu-22.04-minimal-cloudimg-amd64.qcow2 https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img
/usr/sbin/qm set 313 --delete scsi0
sleep 3
/usr/sbin/qm set 313 --delete unused0
sleep 3
/usr/sbin/qm set 313 --scsi0 local-zfs:0,import-from=/root/cloud-images/ubuntu-22.04-minimal-cloudimg-amd64.qcow2,discard=on,ssd=1
sleep 3
/usr/sbin/qm set 313 --boot order=scsi0
sleep 3
/usr/sbin/qm cloudinit update 313
sleep 3
curl -fsS -m 10 --retry 5 -o /dev/null https://uptimekuma.akanealw.com/api/push/h2TE9rvDGr?status=up&msg=OK&ping=

View File

@@ -0,0 +1,5 @@
#!/bin/bash
until ping -c1 192.168.1.41 >/dev/null 2>&1; do :; done
sleep 45
/usr/sbin/qm start 211

View File

@@ -0,0 +1,140 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2023 tteck
# Author: tteck (tteckster)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
function header_info {
cat <<"EOF"
__ __ __ ________
/ //_/__ _________ ___ / / / ____/ /__ ____ _____
/ ,< / _ \/ ___/ __ \/ _ \/ / / / / / _ \/ __ `/ __ \
/ /| / __/ / / / / / __/ / / /___/ / __/ /_/ / / / /
/_/ |_\___/_/ /_/ /_/\___/_/ \____/_/\___/\__,_/_/ /_/
EOF
}
set -euo pipefail
shopt -s inherit_errexit nullglob
YW=$(echo "\033[33m")
BL=$(echo "\033[36m")
RD=$(echo "\033[01;31m")
BGN=$(echo "\033[4;92m")
GN=$(echo "\033[1;92m")
DGN=$(echo "\033[32m")
CL=$(echo "\033[m")
BFR="\\r\\033[K"
HOLD="-"
CM="${GN}${CL}"
CROSS="${RD}${CL}"
PARTY="🎉"
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
done
clear
function msg_info() {
local msg="$1"
echo -ne " ${HOLD} ${YW}${msg}..."
}
function msg_ok() {
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
}
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
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
}
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"
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
else
MODE="PVE"
fi
check_root

View File

@@ -0,0 +1,243 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2023 tteck
# Author: tteck (tteckster)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
header_info() {
clear
cat <<"EOF"
____ _ ________ ____ __ ____ __ ____
/ __ \ | / / ____/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / /
/ /_/ / | / / __/ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / /
/ ____/| |/ / /___ / ____/ /_/ (__ ) /_ _/ // / / (__ ) /_/ /_/ / / /
/_/ |___/_____/ /_/ \____/____/\__/ /___/_/ /_/____/\__/\__,_/_/_/
EOF
}
RD=$(echo "\033[01;31m")
YW=$(echo "\033[33m")
GN=$(echo "\033[1;92m")
CL=$(echo "\033[m")
BFR="\\r\\033[K"
HOLD="-"
CM="${GN}${CL}"
CROSS="${RD}${CL}"
set -euo pipefail
shopt -s inherit_errexit nullglob
msg_info() {
local msg="$1"
echo -ne " ${HOLD} ${YW}${msg}..."
}
msg_ok() {
local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
}
msg_error() {
local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
}
start_routines() {
header_info
VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)"
if lscpu | grep -qP 'Vendor ID:.*GenuineIntel' && lscpu | grep -qP 'Model name:.*N' && [[ "$VERSION" == "bullseye" ]]; then
whiptail --msgbox --title "N-SERIES PROCESSOR DETECTED" "To ensure compatibility with Proxmox VE on systems equipped with N-series processors, it is recommended to install Proxmox Virtual Environment 8" 10 58
fi
CHOICE=$(whiptail --title "SOURCES" --menu "The package manager will use the correct sources to update and install packages on your Proxmox VE server.\n \nCorrect Proxmox VE sources?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Correcting Proxmox VE Sources"
cat <<EOF >/etc/apt/sources.list
deb http://ftp.debian.org/debian ${VERSION} main contrib
deb http://ftp.debian.org/debian ${VERSION}-updates main contrib
deb http://security.debian.org/debian-security ${VERSION}-security main contrib
EOF
msg_ok "Corrected Proxmox VE Sources"
;;
no)
msg_error "Selected no to Correcting Proxmox VE Sources"
;;
esac
CHOICE=$(whiptail --title "PVE-ENTERPRISE" --menu "The 'pve-enterprise' repository is only available to users who have purchased a Proxmox VE subscription.\n \nDisable 'pve-enterprise' repository?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Disabling 'pve-enterprise' repository"
cat <<EOF >/etc/apt/sources.list.d/pve-enterprise.list
# deb https://enterprise.proxmox.com/debian/pve ${VERSION} pve-enterprise
EOF
msg_ok "Disabled 'pve-enterprise' repository"
;;
no)
msg_error "Selected no to Disabling 'pve-enterprise' repository"
;;
esac
CHOICE=$(whiptail --title "PVE-NO-SUBSCRIPTION" --menu "The 'pve-no-subscription' repository provides access to all of the open-source components of Proxmox VE.\n \nEnable 'pve-no-subscription' repository?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Enabling 'pve-no-subscription' repository"
cat <<EOF >/etc/apt/sources.list.d/pve-install-repo.list
deb http://download.proxmox.com/debian/pve ${VERSION} pve-no-subscription
EOF
msg_ok "Enabled 'pve-no-subscription' repository"
;;
no)
msg_error "Selected no to Enabling 'pve-no-subscription' repository"
;;
esac
if [[ "${VERSION}" == "bookworm" ]]; then
CHOICE=$(whiptail --title "CEPH PACKAGE REPOSITORIES" --menu "The 'Ceph Package Repositories' provides access to both the 'no-subscription' and 'enterprise' repositories.\n \nEnable 'ceph package repositories?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Enabling 'ceph package repositories'"
cat <<EOF >/etc/apt/sources.list.d/ceph.list
# deb http://download.proxmox.com/debian/ceph-quincy bookworm enterprise
deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription
EOF
msg_ok "Enabled 'ceph package repositories'"
;;
no)
msg_error "Selected no to Enabling 'ceph package repositories'"
;;
esac
fi
CHOICE=$(whiptail --title "PVETEST" --menu "The 'pvetest' repository can give advanced users access to new features and updates before they are officially released.\n \nAdd (Disabled) 'pvetest' repository?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Adding 'pvetest' repository and set disabled"
cat <<EOF >/etc/apt/sources.list.d/pvetest-for-beta.list
# deb http://download.proxmox.com/debian/pve ${VERSION} pvetest
EOF
msg_ok "Added 'pvetest' repository"
;;
no)
msg_error "Selected no to Adding 'pvetest' repository"
;;
esac
if [[ ! -f /etc/apt/apt.conf.d/no-nag-script ]]; then
CHOICE=$(whiptail --title "SUBSCRIPTION NAG" --menu "This will disable the nag message reminding you to purchase a subscription every time you log in to the web interface.\n \nDisable subscription nag?" 14 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
whiptail --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58
msg_info "Disabling subscription nag"
echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" >/etc/apt/apt.conf.d/no-nag-script
apt --reinstall install proxmox-widget-toolkit &>/dev/null
msg_ok "Disabled subscription nag (Delete browser cache)"
;;
no)
whiptail --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58
msg_error "Selected no to Disabling subscription nag"
;;
esac
fi
if ! systemctl is-active --quiet pve-ha-lrm; then
CHOICE=$(whiptail --title "HIGH AVAILABILITY" --menu "Enable high availability?" 10 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Enabling high availability"
systemctl enable -q --now pve-ha-lrm
systemctl enable -q --now pve-ha-crm
systemctl enable -q --now corosync
msg_ok "Enabled high availability"
;;
no)
msg_error "Selected no to Enabling high availability"
;;
esac
fi
if systemctl is-active --quiet pve-ha-lrm; then
CHOICE=$(whiptail --title "HIGH AVAILABILITY" --menu "If you plan to utilize a single node instead of a clustered environment, you can disable unnecessary high availability (HA) services, thus reclaiming system resources.\n\nIf HA becomes necessary at a later stage, the services can be re-enabled.\n\nDisable high availability?" 18 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Disabling high availability"
systemctl disable -q --now pve-ha-lrm
systemctl disable -q --now pve-ha-crm
systemctl disable -q --now corosync
msg_ok "Disabled high availability"
;;
no)
msg_error "Selected no to Disabling high availability"
;;
esac
fi
CHOICE=$(whiptail --title "UPDATE" --menu "\nUpdate Proxmox VE now?" 11 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Updating Proxmox VE (Patience)"
apt-get update &>/dev/null
apt-get -y dist-upgrade &>/dev/null
msg_ok "Updated Proxmox VE"
;;
no)
msg_error "Selected no to Updating Proxmox VE"
;;
esac
CHOICE=$(whiptail --title "REBOOT" --menu "\nReboot Proxmox VE now? (recommended)" 11 58 2 \
"yes" " " \
"no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Rebooting Proxmox VE"
sleep 2
msg_ok "Completed Post Install Routines"
reboot
;;
no)
msg_error "Selected no to Rebooting Proxmox VE (Reboot recommended)"
msg_ok "Completed Post Install Routines"
;;
esac
}
header_info
echo -e "\nThis script will Perform Post Install Routines.\n"
while true; do
read -p "Start the Proxmox VE Post Install Script (y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) clear; exit ;;
*) echo "Please answer yes or no." ;;
esac
done
if ! command -v pveversion >/dev/null 2>&1; then
header_info
msg_error "\n No PVE Detected!\n"
exit
fi
start_routines

View File

@@ -0,0 +1,73 @@
#!/bin/bash
# autoreply config update dialog with no
if [[ ! -f /etc/apt/apt.conf.d/local ]] ; then
echo "Dpkg::Options {" >> /etc/apt/apt.conf.d/local
echo " "--force-confdef";" >> /etc/apt/apt.conf.d/local
echo " "--force-confold";" >> /etc/apt/apt.conf.d/local
echo "}" >> /etc/apt/apt.conf.d/local
fi
# update and upgrade
apt-get update
apt-get upgrade -y
# download and install packages
apt-get install -y sudo curl wget zip unzip git man-db cifs-utils nfs-common ntfs-3g parted libtalloc2 libwbclient0 net-tools gnupg apt-transport-https tmux gdisk bash-completion
# update templates
pveam update
# remove all motd
rm /etc/motd > /dev/null 2>&1
# set input preferences
if [[ ! -f /etc/inputrc.bak ]] ; then
cp /etc/inputrc /etc/inputrc.bak > /dev/null 2>&1
fi
rm /etc/inputrc > /dev/null 2>&1
cp /etc/inputrc.bak /etc/inputrc
echo "" >> /etc/inputrc
echo "set completion-ignore-case On" >> /etc/inputrc
# set bash preferences and aliases
if [[ -f /etc/bash.bashrc.default ]] ; then
mv /etc/bash.bashrc.default /etc/bash.bashrc.bak > /dev/null 2>&1
fi
if [[ ! -f /etc/bash.bashrc.bak ]] ; then
cp /etc/bash.bashrc /etc/bash.bashrc.bak > /dev/null 2>&1
fi
rm /etc/bash.bashrc > /dev/null 2>&1
cp /etc/bash.bashrc.bak /etc/bash.bashrc
echo "" >> /etc/bash.bashrc
echo "# custom settings and aliases" >> /etc/bash.bashrc
echo "set -o noclobber" >> /etc/bash.bashrc
echo "alias lsa='ls -alhvF'" >> /etc/bash.bashrc
echo "alias systart='sudo systemctl start'" >> /etc/bash.bashrc
echo "alias systop='sudo systemctl stop'" >> /etc/bash.bashrc
echo "alias sysrest='sudo systemctl restart'" >> /etc/bash.bashrc
echo "alias systat='sudo systemctl status'" >> /etc/bash.bashrc
echo "alias aptupy='sudo apt update && sudo apt upgrade -y'" >> /etc/bash.bashrc
echo "alias aptiy='sudo apt install -y'" >> /etc/bash.bashrc
echo "alias aptry='sudo apt remove -y'" >> /etc/bash.bashrc
echo "alias aptrpy='sudo apt remove --purge -y'" >> /etc/bash.bashrc
echo "alias aptary='sudo apt autoremove -y'" >> /etc/bash.bashrc
echo "alias apts='sudo apt search'" >> /etc/bash.bashrc
echo "alias aptl='sudo apt list --installed'" >> /etc/bash.bashrc
echo "alias aptsh='sudo apt show'" >> /etc/bash.bashrc
echo "alias aptac='sudo apt-get autoclean'" >> /etc/bash.bashrc
echo "alias dpkgi='sudo dpkg -i'" >> /etc/bash.bashrc
echo "alias tmxls='tmux ls'" >> /etc/bash.bashrc
echo "alias tmxa='tmux attach -t'" >> /etc/bash.bashrc
# create tmux config
rm /etc/tmux.conf* > /dev/null 2>&1
echo "unbind C-b" >> /etc/tmux.conf
echo "set-option -g prefix C-a" >> /etc/tmux.conf
echo "bind-key C-a send-prefix" >> /etc/tmux.conf
# git config
git config --global credential.helper store
git config --global user.name "akanealw"
git config --global user.email "akanealw@gmail.com"
git config --global init.defaultBranch main

View File

@@ -0,0 +1,3 @@
#!/bin/bash
ssh proxmox1 sudo poweroff

View File

@@ -0,0 +1,4 @@
#!/bin/bash
wakeonlan 68:1c:a2:13:05:f5
curl -fsS -m 10 --retry 5 -o /dev/null https://uptimekuma.akanealw.com/api/push/WKVxvGZXIw?status=up&msg=OK&ping=