Skip to content

tanhongit/dotfiles_server

 
 

Repository files navigation

Dotfiles Server

This script is used to set up a new server with my dotfiles.

OS Availability:

  • Ubuntu 20.04
  • Ubuntu 22.04
  • Debian 10

Installation

Clone the repository and run the script:

# git clone --depth=1 https://github.com/tanhongit/dotfiles_server.git
git clone git@github.com:tanhongit/dotfiles_server.git
cd dotfiles_server

Method 1: Using Makefile (Recommended)

Quick and easy commands using Make:

# Show all available commands
make help

# Setup server
make setup
# or use short alias
make s

See Makefile Guide for complete documentation.

Method 2: Direct Script

./install.sh a

Note: You may need to make the script executable by running chmod +x install.sh before running it.

chmod +x install.sh

Quick Commands (Makefile)

Command Description Short Alias
make setup Setup the server make s
make ssh-port PORT=XXXX Change SSH port make sp PORT=XXXX
make ssh-timeout Configure SSH timeout make st
make php Install PHP make p
make php-ext VER=X.X Install PHP extensions make pe VER=X.X
make global-dev Setup NVM, NPM, Yarn, ZSH make gd
make add-user USER=name Add user to developers group make au USER=name
make zabbix-server Install Zabbix Server make zs
make zabbix-client IP=X.X.X.X Install Zabbix Agent make zc IP=X.X.X.X
make update-zabbix-ip IP=X.X.X.X Update Zabbix Server IP make uzi IP=X.X.X.X

Examples:

make setup
make ssh-port PORT=19742
make global-dev
make add-user USER=john
make zabbix-client IP=192.168.1.100

Full documentation: Makefile Guide

Usage

The runner has the following commands:

Command Description
setup, s, a Setup the server
ssh_port, sp Change the SSH port
ssh_timeout, st Configure SSH timeout (auto disconnect after 5min idle)
php, php-install Install PHP version you want
php_extension, pe Install PHP extensions
lazydocker, ld Install lazydocker
global_dev, gd Setup NVM, NPM, Yarn, ZSH globally for all users
add_dev_user, adu Add user(s) to developers group for dev tools access
zabbix_server, zs Install Zabbix Server with auto web server detection
zabbix_client, zc Install Zabbix Agent (client)
update_zabbix_ip, uzi Update Zabbix Server IP for installed agent
fix_mysql, fmf Fix MySQL FROZEN issue (when downgrading from MariaDB)

Global Dev Setup

Setup development environment globally for all users (including new users):

sudo bash install.sh global_dev
# or
sudo bash install.sh gd

This will install and configure:

  • ✓ ZSH with Oh-My-Zsh (Powerlevel10k theme)
  • ✓ NVM (Node Version Manager) at /usr/local/nvm
  • ✓ Node.js (LTS version)
  • ✓ NPM (Node Package Manager) with global packages at /usr/local/nvm/npm-global
  • ✓ Yarn (Package Manager) with global packages at /usr/local/nvm/yarn-global
  • ✓ Creates developers group with proper permissions

Force update dotfiles for all existing users:

sudo bash install.sh global_dev -f
# or
sudo bash install.sh gd --force

The -f or --force flag will:

  • Force copy/update all dotfiles (.zshrc, .zsh_aliases, .p10k.zsh) from home/ folder to all existing users
  • Backup existing dotfiles before updating
  • Apply new configuration to all users with UID >= 1000
  • Automatically add all existing users to developers group

Managing User Permissions

After installing global dev tools, users need to be added to the developers group to use NVM, NPM, and Yarn:

Add specific user(s):

sudo bash install.sh add_dev_user john
# or multiple users
sudo bash install.sh add_dev_user john mary bob

Add all existing users:

sudo bash install.sh add_dev_user --all
# or
sudo bash install.sh adu -a

Important: Users must logout and login again (or run newgrp developers) to apply group membership.

After that, users can:

  • Install Node.js versions: nvm install 22
  • Install npm packages globally: npm install -g <package>
  • Install yarn packages globally: yarn global add <package>

Benefits of using developers group:

  • ✓ No need to use sudo for installing packages
  • ✓ All users in the group share the same Node.js versions
  • ✓ Centralized package management
  • ✓ Secure permissions (only authorized users can install packages)

Zabbix Setup

Setup Zabbix monitoring system with automatic web server detection:

Install Zabbix Server:

sudo bash install.sh zabbix_server
# or
sudo bash install.sh zs

Features:

  • ✓ Auto-detects Nginx or Apache (or lets you choose)
  • ✓ Installs MySQL database
  • ✓ Configures Zabbix Server, Frontend, and Agent
  • ✓ Generates secure random passwords
  • ✓ Configures firewall automatically
  • ✓ Supports Ubuntu 20.04, 22.04, 24.04
  • ✓ Zabbix 7.0 LTS

Install Zabbix Agent (Client):

# Method 1: Will prompt for Server IP
sudo bash install.sh zabbix_client
# or
sudo bash install.sh zc

# Method 2: Pass Server IP directly
sudo bash install.sh zabbix_client 192.168.1.100
# or
sudo bash install.sh zc 192.168.1.100

Features:

  • ✓ Installs Zabbix Agent
  • ✓ Prompts for Zabbix Server IP
  • ✓ Configures agent to connect to server
  • ✓ Configures firewall automatically

Update Zabbix Server IP (for already installed agents):

# Method 1: Will prompt for new Server IP
sudo bash install.sh update_zabbix_ip
# or
sudo bash install.sh uzi

# Method 2: Pass new Server IP directly
sudo bash install.sh update_zabbix_ip 192.168.1.200
# or
sudo bash install.sh uzi 192.168.1.200

Features:

  • ✓ Updates existing Zabbix Agent configuration
  • ✓ Validates IP address format
  • ✓ Creates backup before changes
  • ✓ Auto-restarts agent service
  • ✓ Verifies connection to new server
  • ✓ Supports both Zabbix Agent and Agent2

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

This script is used to set up a new server with my dotfiles.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 96.8%
  • Makefile 3.2%