Update setup
This commit is contained in:
@@ -1,5 +1,22 @@
|
|||||||
# Setup Server
|
#!/bin/bash
|
||||||
echo '### Setting up Server ###'
|
|
||||||
|
# Configuration for Colors
|
||||||
|
BLUE='\033[1;34m'
|
||||||
|
GREEN='\033[1;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
CYAN='\033[1;36m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
print_step() {
|
||||||
|
printf "\n${BLUE}========== %s ==========${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
print_info() {
|
||||||
|
printf "${CYAN}➜ %s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_server() {
|
||||||
|
print_step "Setting up Server"
|
||||||
|
print_info "Updating packages and configuring firewall..."
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo ufw allow 22/tcp
|
sudo ufw allow 22/tcp
|
||||||
sudo ufw allow 443/tcp
|
sudo ufw allow 443/tcp
|
||||||
@@ -7,15 +24,23 @@ sudo ufw allow 8123/tcp
|
|||||||
sudo ufw allow 8123/udp
|
sudo ufw allow 8123/udp
|
||||||
sudo ufw allow 3000/tcp
|
sudo ufw allow 3000/tcp
|
||||||
sudo ufw allow 3001/tcp
|
sudo ufw allow 3001/tcp
|
||||||
|
}
|
||||||
|
|
||||||
# Setup Docker
|
setup_docker() {
|
||||||
echo '### Setting up Docker ###'
|
print_step "Setting up Docker"
|
||||||
|
print_info "Installing prerequisites..."
|
||||||
sudo apt -y install lsb-release gnupg apt-transport-https ca-certificates curl software-properties-common
|
sudo apt -y install lsb-release gnupg apt-transport-https ca-certificates curl software-properties-common
|
||||||
|
if [ ! -f /etc/apt/trusted.gpg.d/docker.gpg ]; then
|
||||||
|
print_info "Downloading Docker GPG key..."
|
||||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg
|
||||||
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
fi
|
||||||
|
print_info "Adding Docker repository..."
|
||||||
|
sudo add-apt-repository -y "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
print_info "Installing Docker CE..."
|
||||||
|
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||||
|
|
||||||
|
print_info "Configuring Docker service and permissions..."
|
||||||
sudo systemctl enable --now docker.service
|
sudo systemctl enable --now docker.service
|
||||||
if ! getent group docker > /dev/null 2>&1; then
|
if ! getent group docker > /dev/null 2>&1; then
|
||||||
sudo groupadd docker
|
sudo groupadd docker
|
||||||
@@ -24,33 +49,54 @@ if ! id -nG "$USER" | grep -qw "docker"; then
|
|||||||
sudo usermod -aG docker "$USER"
|
sudo usermod -aG docker "$USER"
|
||||||
fi
|
fi
|
||||||
sudo docker network create homelogic 2>/dev/null || true
|
sudo docker network create homelogic 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
# Setup ZSH
|
setup_zsh() {
|
||||||
echo '### Setting up ZSH ###'
|
print_step "Setting up ZSH"
|
||||||
|
print_info "Configuring .zshrc and hushlogin..."
|
||||||
touch ../.hushlogin
|
touch ../.hushlogin
|
||||||
cp -f .zshrc.base ../.zshrc
|
cp -f .zshrc.base ../.zshrc
|
||||||
|
|
||||||
sudo apt install zsh
|
sudo apt install -y zsh
|
||||||
|
|
||||||
ZSH_PATH=$(command -v zsh)
|
ZSH_PATH=$(command -v zsh)
|
||||||
if [ "${SHELL##*/}" != "zsh" ] && [ -n "$ZSH_PATH" ]; then
|
if [ "${SHELL##*/}" != "zsh" ] && [ -n "$ZSH_PATH" ]; then
|
||||||
|
print_info "Changing default shell to ZSH..."
|
||||||
chsh -s "$ZSH_PATH"
|
chsh -s "$ZSH_PATH"
|
||||||
fi
|
fi
|
||||||
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
|
print_info "Installing Oh My Zsh and plugins..."
|
||||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions 2>/dev/null || true
|
||||||
|
RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||||
|
}
|
||||||
|
|
||||||
# Setup Tailscale
|
setup_tailscale() {
|
||||||
echo '### Setting up Tailscale ###'
|
print_step "Setting up Tailscale"
|
||||||
printf "Do you want to install and setup Tailscale? [Y/n] "
|
printf "\n${YELLOW}❓ Do you want to install and setup Tailscale? [Y/n] ${NC}"
|
||||||
read choice
|
read choice
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
n|N|no|No|NO )
|
n|N|no|No|NO )
|
||||||
echo "Skipping Tailscale setup."
|
print_info "Skipping Tailscale setup."
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
if ! command -v tailscale > /dev/null 2>&1; then
|
if ! command -v tailscale > /dev/null 2>&1; then
|
||||||
|
print_info "Installing Tailscale..."
|
||||||
curl -fsSL https://tailscale.com/install.sh | sh
|
curl -fsSL https://tailscale.com/install.sh | sh
|
||||||
sudo tailscale up
|
sudo tailscale up
|
||||||
|
else
|
||||||
|
print_info "Tailscale is already installed."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
setup_server
|
||||||
|
setup_docker
|
||||||
|
setup_zsh
|
||||||
|
setup_tailscale
|
||||||
|
|
||||||
|
printf "\n${GREEN}✔ Setup complete! Please log out and log back in for all changes to take effect.${NC}\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute main process
|
||||||
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user