mirror of
https://github.com/bashclub/proxmox-zfs-postinstall.git
synced 2024-11-07 18:31:58 +01:00
zfs-auto-snapshot optional, zsync install via repo
This commit is contained in:
parent
a55271c868
commit
35be4b2c0f
133
postinstall
133
postinstall
@ -32,7 +32,7 @@ set -uo pipefail
|
|||||||
PROG=$(basename "$0")
|
PROG=$(basename "$0")
|
||||||
|
|
||||||
# Required tools for usage in postinstall
|
# Required tools for usage in postinstall
|
||||||
REQUIRED_TOOLS="curl ifupdown2 git gron ipmitool libsasl2-modules lsb-release libpve-network-perl postfix ssl-cert zfs-auto-snapshot"
|
REQUIRED_TOOLS="curl ifupdown2 git gron ipmitool libsasl2-modules lsb-release libpve-network-perl postfix ssl-cert"
|
||||||
|
|
||||||
# Optional tools to install
|
# Optional tools to install
|
||||||
OPTIONAL_TOOLS="dnsutils ethtool htop iftop jq lshw lsscsi mc net-tools nvme-cli rpl screen smartmontools sudo sysstat tmux unzip vim"
|
OPTIONAL_TOOLS="dnsutils ethtool htop iftop jq lshw lsscsi mc net-tools nvme-cli rpl screen smartmontools sudo sysstat tmux unzip vim"
|
||||||
@ -162,18 +162,28 @@ vm_swappiness () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto_snapshot(){
|
auto_snapshot(){
|
||||||
if dpkg -l zfs-auto-snapshot > /dev/null 2>&1 ; then
|
install_zas=0
|
||||||
|
if whiptail --title "INSTALL ZFS-AUTO-SNAPSHOT" \
|
||||||
|
--backtitle "$PROG" \
|
||||||
|
--yes-button "INSTALL" \
|
||||||
|
--no-button "SKIP" \
|
||||||
|
--yesno "Do you want to install and configure zfs-auto-snapshot?" 9 76 ; then
|
||||||
|
install_zas=1
|
||||||
|
|
||||||
|
if dpkg -l zfs-auto-snapshot > /dev/null 2>&1 ; then
|
||||||
|
for interval in "${!auto_snap_keep[@]}"; do
|
||||||
|
if [[ "$interval" == "frequent" ]]; then
|
||||||
|
auto_snap_keep[$interval]=$(cat /etc/cron.d/zfs-auto-snapshot | grep keep | cut -d' ' -f19 | cut -d '=' -f2)
|
||||||
|
else
|
||||||
|
auto_snap_keep[$interval]=$(cat /etc/cron.$interval/zfs-auto-snapshot | grep keep | cut -d' ' -f6 | cut -d'=' -f2)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
for interval in "${!auto_snap_keep[@]}"; do
|
for interval in "${!auto_snap_keep[@]}"; do
|
||||||
if [[ "$interval" == "frequent" ]]; then
|
if ! auto_snap_keep[$interval]=$(inputbox_int "CONFIGURE ZFS-AUTO-SNAPSHOT" "Please set number of $interval snapshots to keep" 7 ${auto_snap_keep[$interval]}) ; then cancel_dialog ; fi
|
||||||
auto_snap_keep[$interval]=$(cat /etc/cron.d/zfs-auto-snapshot | grep keep | cut -d' ' -f19 | cut -d '=' -f2)
|
|
||||||
else
|
|
||||||
auto_snap_keep[$interval]=$(cat /etc/cron.$interval/zfs-auto-snapshot | grep keep | cut -d' ' -f6 | cut -d'=' -f2)
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
fi
|
fi
|
||||||
for interval in "${!auto_snap_keep[@]}"; do
|
|
||||||
if ! auto_snap_keep[$interval]=$(inputbox_int "CONFIGURE ZFS-AUTO-SNAPSHOT" "Please set number of $interval snapshots to keep" 7 ${auto_snap_keep[$interval]}) ; then cancel_dialog ; fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
select_subscription(){
|
select_subscription(){
|
||||||
@ -280,6 +290,26 @@ select_pve_repo(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ask_bashclub_repo(){
|
||||||
|
|
||||||
|
bashclub_repo=0
|
||||||
|
install_zsync=0
|
||||||
|
if whiptail --title "INSTALL BASHCLUB REPOSITORY" \
|
||||||
|
--backtitle "$PROG" \
|
||||||
|
--yes-button "INSTALL" \
|
||||||
|
--no-button "SKIP" \
|
||||||
|
--yesno "Do you want to install the bashclub apt repository?" 9 76 ; then
|
||||||
|
bashclub_repo=1
|
||||||
|
if whiptail --title "INSTALL CHECKZFS AND ZSYNC" \
|
||||||
|
--backtitle "$PROG" \
|
||||||
|
--yes-button "INSTALL" \
|
||||||
|
--no-button "SKIP" \
|
||||||
|
--yesno "Do you want to install checkzfs and bashclub-zsync?" 9 76 ; then
|
||||||
|
install_zsync=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
select_ceph_repo(){
|
select_ceph_repo(){
|
||||||
none=OFF
|
none=OFF
|
||||||
quincyenterprise=OFF
|
quincyenterprise=OFF
|
||||||
@ -393,6 +423,14 @@ set_pve_repo(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_bashclub_repo (){
|
||||||
|
if [ $bashclub_repo -gt 0 ]; then
|
||||||
|
log "Configuring bashclub apt repositories"
|
||||||
|
echo "deb [signed-by=/usr/share/keyrings/bashclub-archive-keyring.gpg] https://apt.bashclub.org/release bookworm main" > /etc/apt/sources.list.d/bashclub.list
|
||||||
|
wget -O- https://apt.bashclub.org/gpg/bashclub.pub | gpg --dearmor > /usr/share/keyrings/bashclub-archive-keyring.gpg
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
update_system(){
|
update_system(){
|
||||||
log "Downloading latest package lists"
|
log "Downloading latest package lists"
|
||||||
apt update > /dev/null 2>&1
|
apt update > /dev/null 2>&1
|
||||||
@ -402,6 +440,12 @@ update_system(){
|
|||||||
|
|
||||||
install_tools(){
|
install_tools(){
|
||||||
log "Installing toolset - Depending on your version this could take a while..."
|
log "Installing toolset - Depending on your version this could take a while..."
|
||||||
|
if [ $install_zas -gt 0 ]; then
|
||||||
|
OPTIONAL_TOOLS="zfs-auto-snapshot $OPTIONAL_TOOLS"
|
||||||
|
fi
|
||||||
|
if [ $install_zsync -gt 0 ]; then
|
||||||
|
OPTIONAL_TOOLS="bashclub-zsync $OPTIONAL_TOOLS"
|
||||||
|
fi
|
||||||
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq install $REQUIRED_TOOLS $OPTIONAL_TOOLS > /dev/null 2>&1
|
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq install $REQUIRED_TOOLS $OPTIONAL_TOOLS > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,21 +470,24 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_auto_snapshot(){
|
set_auto_snapshot(){
|
||||||
# configure zfs-auto-snapshot
|
|
||||||
for interval in "${!auto_snap_keep[@]}"; do
|
if [ $install_zas -gt 0 ]; then
|
||||||
log "Setting zfs-auto-snapshot retention: $interval = ${auto_snap_keep[$interval]}"
|
# configure zfs-auto-snapshot
|
||||||
if [[ "$interval" == "frequent" ]]; then
|
for interval in "${!auto_snap_keep[@]}"; do
|
||||||
CURRENT=$(cat /etc/cron.d/zfs-auto-snapshot | grep keep | cut -d' ' -f19 | cut -d '=' -f2)
|
log "Setting zfs-auto-snapshot retention: $interval = ${auto_snap_keep[$interval]}"
|
||||||
if [[ "${auto_snap_keep[$interval]}" != "$CURRENT" ]]; then
|
if [[ "$interval" == "frequent" ]]; then
|
||||||
rpl "keep=$CURRENT" "keep=${auto_snap_keep[$interval]}" /etc/cron.d/zfs-auto-snapshot > /dev/null 2>&1
|
CURRENT=$(cat /etc/cron.d/zfs-auto-snapshot | grep keep | cut -d' ' -f19 | cut -d '=' -f2)
|
||||||
|
if [[ "${auto_snap_keep[$interval]}" != "$CURRENT" ]]; then
|
||||||
|
rpl "keep=$CURRENT" "keep=${auto_snap_keep[$interval]}" /etc/cron.d/zfs-auto-snapshot > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
CURRENT=$(cat /etc/cron.$interval/zfs-auto-snapshot | grep keep | cut -d' ' -f6 | cut -d'=' -f2)
|
||||||
|
if [[ "${auto_snap_keep[$interval]}" != "$CURRENT" ]]; then
|
||||||
|
rpl "keep=$CURRENT" "keep=${auto_snap_keep[$interval]}" /etc/cron.$interval/zfs-auto-snapshot > /dev/null 2>&1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
done
|
||||||
CURRENT=$(cat /etc/cron.$interval/zfs-auto-snapshot | grep keep | cut -d' ' -f6 | cut -d'=' -f2)
|
fi
|
||||||
if [[ "${auto_snap_keep[$interval]}" != "$CURRENT" ]]; then
|
|
||||||
rpl "keep=$CURRENT" "keep=${auto_snap_keep[$interval]}" /etc/cron.$interval/zfs-auto-snapshot > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_swappiness(){
|
set_swappiness(){
|
||||||
@ -620,36 +667,6 @@ set_default_volblocksize(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_checkzfs(){
|
|
||||||
log "Installing checkzfs to /usr/local/bin/checkzfs"
|
|
||||||
wget -q --no-cache -O /usr/local/bin/checkzfs https://raw.githubusercontent.com/bashclub/check-zfs-replication/main/checkzfs.py
|
|
||||||
chmod +x /usr/local/bin/checkzfs
|
|
||||||
log "Installing check-snapshot-age to /usr/local/bin/check-snapshot-age"
|
|
||||||
wget -q --no-cache -O /usr/local/bin/check-snapshot-age https://raw.githubusercontent.com/bashclub/check-zfs-replication/main/check-snapshot-age
|
|
||||||
chmod +x /usr/local/bin/check-snapshot-age
|
|
||||||
}
|
|
||||||
|
|
||||||
install_zsync(){
|
|
||||||
log "Installing bashclub-zsync"
|
|
||||||
wget -q --no-cache -O /usr/bin/bashclub-zsync https://git.bashclub.org/bashclub/zsync/raw/branch/main/bashclub-zsync/usr/bin/bashclub-zsync
|
|
||||||
chmod +x /usr/bin/bashclub-zsync
|
|
||||||
cat << EOF > /etc/logrotate.d/bashclub-zsync
|
|
||||||
/var/log/bashclub-zsync/*.log {
|
|
||||||
weekly
|
|
||||||
rotate 12
|
|
||||||
compress
|
|
||||||
delaycompress
|
|
||||||
missingok
|
|
||||||
notifempty
|
|
||||||
create 644 root root
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
mkdir -p /var/log/bashclub-zsync
|
|
||||||
cat << EOF > /etc/cron.d/bashclub-zsync
|
|
||||||
#00 23 * * * root /usr/bin/bashclub-zsync -c /etc/bashclub/zsync.conf > /var/log/bashclub-zsync/zsync.log
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
virtiowin_updater() {
|
virtiowin_updater() {
|
||||||
log "Installing virtio-win-updater"
|
log "Installing virtio-win-updater"
|
||||||
cat << EOF > /usr/local/bin/virtio-win-updater
|
cat << EOF > /usr/local/bin/virtio-win-updater
|
||||||
@ -706,6 +723,7 @@ installation_task(){
|
|||||||
set_locales
|
set_locales
|
||||||
set_pve_repo
|
set_pve_repo
|
||||||
set_ceph_repo
|
set_ceph_repo
|
||||||
|
set_bashclub_repo
|
||||||
update_system
|
update_system
|
||||||
install_tools
|
install_tools
|
||||||
enable_sdn
|
enable_sdn
|
||||||
@ -715,8 +733,6 @@ installation_task(){
|
|||||||
pve_conf_backup
|
pve_conf_backup
|
||||||
suppress_no_subscription_warning
|
suppress_no_subscription_warning
|
||||||
harden_ssh
|
harden_ssh
|
||||||
install_checkzfs
|
|
||||||
install_zsync
|
|
||||||
set_mail_delivery
|
set_mail_delivery
|
||||||
create_swap_pool
|
create_swap_pool
|
||||||
set_default_volblocksize
|
set_default_volblocksize
|
||||||
@ -745,7 +761,7 @@ summary(){
|
|||||||
repository: $repo_selection \n\
|
repository: $repo_selection \n\
|
||||||
subscription: $(pvesubscription get | grep status | cut -d' ' -f2)\n\
|
subscription: $(pvesubscription get | grep status | cut -d' ' -f2)\n\
|
||||||
suppress subscription warning: $suppress_warning\n\
|
suppress subscription warning: $suppress_warning\n\
|
||||||
auto-snapshot: $autosnap\n\
|
install auto-snapshot: $install_zas ($autosnap)\n\
|
||||||
ssh-hardening: $ssh_hardening\n\
|
ssh-hardening: $ssh_hardening\n\
|
||||||
mail delivery: $mailconfig
|
mail delivery: $mailconfig
|
||||||
sender email: $senderaddress
|
sender email: $senderaddress
|
||||||
@ -787,6 +803,9 @@ select_pve_repo
|
|||||||
# Select Ceoh repository
|
# Select Ceoh repository
|
||||||
select_ceph_repo
|
select_ceph_repo
|
||||||
|
|
||||||
|
# Ask for adding bashclub repo
|
||||||
|
ask_bashclub_repo
|
||||||
|
|
||||||
# subscription related actions
|
# subscription related actions
|
||||||
select_subscription
|
select_subscription
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user