Files
linux-scripts/proxmox/proxmox-pbs-essentials.sh

114 lines
5.6 KiB
Bash
Executable File

#!/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 dist-upgrade -y
# download and install packages
apt-get install -y hstr htop ncdu proxmox-backup sudo pwgen 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
# set input preferences
if [[ ! -f /etc/inputrc.default ]]
then wget -qO /etc/inputrc.default http://192.168.1.50/files/debian/inputrc.default
fi
rm /etc/inputrc > /dev/null 2>&1
cp /etc/inputrc.default /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 wget -qO /etc/bash.bashrc.default http://192.168.1.50/files/debian/bash.bashrc.default
fi
rm /etc/bash.bashrc > /dev/null 2>&1
cp /etc/bash.bashrc.default /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 cd..='cd ..'" >> /etc/bash.bashrc
echo "alias ..='cd ..'" >> /etc/bash.bashrc
echo "alias ...='cd ../..'" >> /etc/bash.bashrc
echo "alias grep='grep --color'" >> /etc/bash.bashrc
echo "alias si='sudo -i'" >> /etc/bash.bashrc
echo "alias sudo='sudo '" >> /bash.bashrc
echo "alias mkdir='mkdir -pv'" >> /bash.bashrc
echo "alias du='sudo du -h'" >> /bash.bashrc
echo "alias df='sudo df -h'" >> /etc/bash.bashrc
echo "alias ports='sudo netstat -tulpna'" >> /etc/bash.bashrc
echo "alias start='sudo systemctl start'" >> /etc/bash.bashrc
echo "alias stop='sudo systemctl stop'" >> /etc/bash.bashrc
echo "alias restart='sudo systemctl restart'" >> /etc/bash.bashrc
echo "alias status='sudo systemctl status'" >> /etc/bash.bashrc
echo "alias sdr='sudo systemctl daemon-reload'" >> /etc/bash.bashrc
echo "alias senable='sudo systemctl enable'" >> /etc/bash.bashrc
echo "alias sdisable='sudo systemctl disable'" >> /etc/bash.bashrc
echo "alias snano='sudo nano'" >> /etc/bash.bashrc
echo "alias sreboot='sudo reboot'" >> /etc/bash.bashrc
echo "alias spoweroff='sudo poweroff'" >> /etc/bash.bashrc
echo "alias tf='sudo tail -f'" >> /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 tmuxls='tmux ls'" >> /etc/bash.bashrc
echo "alias tmuxa='tmux attach -t'" >> /etc/bash.bashrc
echo "alias hh='hstr'" >> /etc/bash.bashrc
echo "export HSTR_CONFIG=hide-help,hicolor,prompt-bottom,ignorespace,raw-history-view" >> /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
# configure email for sending notifications
isInFile=$(cat /etc/postfix/main.cf | grep -c "gmail")
if [ $isInFile -eq 0 ]
then
DEBIAN_FRONTEND=noninteractive apt install -y libsasl2-modules mailutils postfix postfix-pcre
echo "smtp.gmail.com notify.akanealw@gmail.com:leawkqqpthbwacrf" > /etc/postfix/sasl_passwd
echo "/^From:.*/ REPLACE From: $(hostname) <notify.akanealw@gmail.com>" > /etc/postfix/smtp_header_checks
chmod 600 /etc/postfix/sasl_passwd
postmap hash:/etc/postfix/sasl_passwd
postmap hash:/etc/postfix/smtp_header_checks
sed -i 's@relayhost =@#relayhost = @g' /etc/postfix/main.cf
sed -i 's@smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache@#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache@g' /etc/postfix/main.cf
echo "" >> /etc/postfix/main.cf
echo "# google mail configuration" >> /etc/postfix/main.cf
echo "relayhost = smtp.gmail.com:587" >> /etc/postfix/main.cf
echo "smtp_use_tls = yes" >> /etc/postfix/main.cf
echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf
echo "smtp_sasl_security_options =" >> /etc/postfix/main.cf
echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf
echo "smtp_tls_CAfile = /etc/ssl/certs/Entrust_Root_Certification_Authority.pem" >> /etc/postfix/main.cf
echo "smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache" >> /etc/postfix/main.cf
echo "smtp_tls_session_cache_timeout = 3600s" >> /etc/postfix/main.cf
echo "smtp_header_checks = pcre:/etc/postfix/smtp_header_checks" >> /etc/postfix/main.cf
echo "" >> /etc/postfix/main.cf
postfix reload
echo "This is a test message sent from postfix on $(hostname)" | mail -s "Test Email from $(hostname)" akanealw@gmail.com
else
echo "Email already configured."
fi