Skip to content

Instantly share code, notes, and snippets.

@coolacid
Created April 21, 2018 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolacid/b22279269769cf093813b55fb1a10473 to your computer and use it in GitHub Desktop.
Save coolacid/b22279269769cf093813b55fb1a10473 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Modified by Coolacid -
################################################################################
# This is property of eXtremeSHOK.com
# You are free to use, modify and distribute, however you may not remove this notice.
# Copyright (c) Adrian Jon Kriel :: admin@extremeshok.com
################################################################################
#
# Script updates can be found at: https://github.com/extremeshok/xshok-proxmox
#
# post-installation script for Proxmox
#
# License: BSD (Berkeley Software Distribution)
#
################################################################################
#
# Assumptions: proxmox installed
# Recommeneded partitioning scheme:
# Raid 1 / 100GB ext4
# 2x swap 8192mb (16384mb total)
# Remaining unpartitioned
#
################################################################################
#
# THERE ARE USER CONFIGURABLE OPTIONS IN THIS SCRIPT
# ALL CONFIGURATION OPTIONS ARE LOCATED BELOW THIS MESSAGE
#
##############################################################
## disable enterprise proxmox repo
if [ -f /etc/apt/sources.list.d/pve-enterprise.list ]; then
echo -e "#deb https://enterprise.proxmox.com/debian stretch pve-enterprise\n" > /etc/apt/sources.list.d/pve-enterprise.list
fi
## enable public proxmox repo
if [ ! -f /etc/apt/sources.list.d/pve-public-repo.list ] && [ ! -f /etc/apt/sources.list.d/pve-install-repo.list ] ; then
echo -e "deb http://download.proxmox.com/debian stretch pve-no-subscription\n" > /etc/apt/sources.list.d/pve-public-repo.list
fi
## Add non-free to sources
sed -i "s/main contrib/main non-free contrib/g" /etc/apt/sources.list
## Install the latest ceph provided by proxmox
echo "deb http://download.proxmox.com/debian/ceph-luminous stretch main" > /etc/apt/sources.list.d/ceph.list
## Bugfix frozen/hung update caused by broken ceph systemd script
if [ -f /etc/systemd/system/ceph.service ]; then
sed -i "s/=ceph.target/=multi-user.target/" /etc/systemd/system/ceph.service
systemctl daemon-reload; systemctl disable ceph.service; systemctl enable ceph.service; systemctl daemon-reexec
fi
## Refresh the package lists
apt-get update
## Fix no public key error for debian repo
apt-get -y install debian-archive-keyring
## Update proxmox and install various system utils
apt-get -y dist-upgrade --force-yes
pveam update
## Fix no public key error for debian repo
apt-get -y install debian-archive-keyring
## Remove no longer required packages and purge old cached updates
apt-get -y autoremove
apt-get -y autoclean
## Install openvswitch for a virtual internal network
apt-get install -y openvswitch-switch
## Install zfs support, appears to be missing on some Proxmox installs.
apt-get install -y zfsutils
## Install ceph support
pveceph install
## Install common system utilities
apt-get install -y whois omping wget axel nano ntp pigz net-tools htop iptraf iotop iftop iperf vim vim-nox screen unzip zip software-properties-common aptitude curl dos2unix dialog mlocate build-essential git
#snmpd snmp-mibs-downloader
## Set pigz to replace gzip, 2x faster gzip compression
cat > /bin/pigzwrapper <<EOF
#!/bin/sh
PATH=/bin:\$PATH
GZIP="-1"
exec /usr/bin/pigz "\$@"
EOF
mv -f /bin/gzip /bin/gzip.original
cp -f /bin/pigzwrapper /bin/gzip
chmod +x /bin/pigzwrapper
chmod +x /bin/gzip
## Increase vzdump backup speed
sed -i "s/#bwlimit: KBPS/bwlimit: 1024000/" /etc/vzdump.conf
## Bugfix: pve 5.1 high swap usage with low memory usage
echo "vm.swapiness=10" >> /etc/sysctl.conf
sysctl -p
## Remove subscription banner
sed -i.bak "s/data.status !== 'Active'/false/g" /usr/share/pve-manager/js/pvemanagerlib.js
# create a daily cron to make sure the banner does not re-appear
cat > /etc/cron.daily/proxmox-nosub <<EOF
##!/bin/sh
sed -i.bak "s/data.status !== 'Active'/false/g" /usr/share/pve-manager/js/pvemanagerlib.js
EOF
chmod 755 /etc/cron.daily/proxmox-nosub
## Increase max user watches
# BUG FIX : No space left on device
echo 1048576 > /proc/sys/fs/inotify/max_user_watches
echo "fs.inotify.max_user_watches=1048576" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
## Increase max FD limit / ulimit
cat <<'EOF' >> /etc/security/limits.conf
* soft nproc 131072
* hard nproc 131072
* soft nofile 131072
* hard nofile 131072
root soft nproc 131072
root hard nproc 131072
root soft nofile 131072
root hard nofile 131072
EOF
## Increase kernel max Key limit
cat <<'EOF' > /etc/sysctl.d/60-maxkeys.conf
kernel.keys.root_maxkeys=1000000
kernel.keys.maxkeys=1000000
EOF
## Script Finish
echo -e '\033[1;33m Finished....please restart the server \033[0m'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment