Skip to content

Instantly share code, notes, and snippets.

@Eventyret
Created October 8, 2023 07:48
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 Eventyret/364c3866aa0cacd991d0619cb5dcfd33 to your computer and use it in GitHub Desktop.
Save Eventyret/364c3866aa0cacd991d0619cb5dcfd33 to your computer and use it in GitHub Desktop.
Easy Panels Server Setup
#!/bin/bash
function update_packages() {
echo -e "\nπŸ“¦ Updating packages... πŸ“¦\n"
apt-get update -y
apt-get upgrade -y
apt-get autoremove -y
apt-get autoclean -y
}
function create_new_user() {
echo -e "\nπŸ‘€ Creating a new user... πŸ‘€\n"
read -p "Enter a username (default: ubuntu): " NEW_USER_INPUT
NEW_USER=${NEW_USER_INPUT:-ubuntu}
echo -e "\nπŸ‘€ Using username: $NEW_USER πŸ‘€\n"
adduser $NEW_USER
echo -e "\nπŸ‘₯ Adding $NEW_USER to sudo group... πŸ‘₯\n"
usermod -aG sudo $NEW_USER
}
function disable_root_login() {
echo -e "\n🚫 Disabling root password SSH login... 🚫\n"
sed -i 's/^PermitRootLogin yes/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config
service ssh restart
}
function install_easy_panels() {
echo -e "\nπŸ“₯ Installing Easy Panels... πŸ“₯\n"
curl -sSL https://get.easypanel.io | sh
echo -e "\nπŸŽ‰ Easy Panels installation complete! πŸŽ‰\n"
}
function uninstall_easy_panels() {
echo -e "\nπŸ—‘οΈ Uninstalling Easy Panels... πŸ—‘οΈ\n"
docker service rm easypanel traefik error-pages
rm -rf /etc/easypanel
echo -e "\nπŸŽ‰ Easy Panels uninstallation complete! πŸŽ‰\n"
}
# Check if the system is Debian or Ubuntu
function is_debian_or_ubuntu() {
if grep -qE "Debian|Ubuntu" /etc/os-release; then
return 0
else
return 1
fi
}
# Menu for user interaction
echo -e "\nπŸš€ Welcome to the server setup! πŸš€\n"
echo "Please select an option:"
PS3='Enter your choice: '
options=("πŸ”§ Complete Setup"
"πŸ‘€ Create New User"
"🚫 Disable Root Login"
"⬆️ Upgrade Server"
"πŸ“₯ Install Easy Panels"
"πŸ—‘οΈ Uninstall Easy Panels"
"πŸ‘‹ Quit")
select opt in "${options[@]}"
do
case $opt in
"Complete Setup")
if is_debian_or_ubuntu; then
update_packages
create_new_user
disable_root_login
else
echo "🚫 The system is not Debian or Ubuntu. Skipping system upgrades and user creation. 🚫"
fi
install_easy_panels
break
;;
"Create New User")
create_new_user
break
;;
"Disable Root Login")
disable_root_login
break
;;
"Upgrade Server")
if is_debian_or_ubuntu; then
update_packages
else
echo "🚫 The system is not Debian or Ubuntu. Skipping system upgrades. 🚫"
fi
break
;;
"Install Easy Panels")
install_easy_panels
break
;;
"Uninstall Easy Panels")
uninstall_easy_panels
break
;;
"Quit")
echo "πŸ‘‹ Exiting... Stay awesome! πŸ‘‹"
break
;;
*)
echo "πŸ€” Invalid option $REPLY. Please try again. πŸ€”"
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment