vps prep.sh
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Set User information
export _USER="rami"
export _NAME="Rami AlGhanmi"
# Update packages and install required packages
apt-get update
apt-get upgrade --yes
apt-get install --yes sudo apt-transport-https dirmngr python python-simplejson
# Create user if it does not exist
if id "$_USER" >/dev/null 2>&1; then
echo ""
else
adduser --disabled-password --gecos "$_NAME,,," $_USER
#Set user password
echo -n "Enter User Password: "
read -s _PASS
echo "$_USER:$_PASS" | chpasswd
unset _PASS
fi
echo -e "$_USER\tALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers.d/10-admin
chmod 440 /etc/sudoers.d/10-admin
# Cleanup Variables
unset _USER
unset _NAME
echo ""