Created
October 8, 2023 07:48
-
-
Save Eventyret/364c3866aa0cacd991d0619cb5dcfd33 to your computer and use it in GitHub Desktop.
Easy Panels Server Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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