Coder Social home page Coder Social logo

lab-server-ops's Introduction

lab-server-ops Documentation

δΈ­ζ–‡

1. Introduction

1.1 Overview

  • The target audience for this project:
    • Linux system administrators
    • Personal Mac users

  • This project aims to provide a better terminal usage experience:
    • For administrators:
      1. Simplify the user distribution process (including permission isolation, group setting, key distribution, configuration of commonly used tools such as zsh/vim/tmux, etc.);
      2. Provide convenient user broadcast function;
    • For users:
      1. Rely on oh-my-zsh and its plugin ecosystem to get a convenient and comfortable Shell experience.
      2. Rely on the scripts provided by the shell programming of this project to implement a series of functions such as fuzzy jumping and history record fuzzy search.

1.2 Branch Description

  • This project has a total of 3 branches:
    1. linux Branch: Suitable for mainstream Linux systems with Linux kernel >= 5, providing administrators with complete functions.
    2. linux-minimum Branch: Suitable for mainstream linux systems with Linux kernel < 5, providing administrators with some functions.
    3. mac-personal Branch: Suitable for macOS, providing individual users with some functions.
Branch Name Adapted System Administrator Functions User Functions
linux Ubuntu(>= 19.04) Debian/Raspbian >= 10.0 1. User distribution; 2. User broadcast 1. Common tool configuration 2. Convenience enhancement script
linux-minimum Ubuntu(< 19.04) Debian/Raspbian < 10.0 CentOS7/8 1. User distribution; 2. User broadcast 1. Common user configuration
mac-personal MacOS >= 11.0 No 1. Convenience enhancement script

1.3 Feature Preview

The fuzzy jumping function largely relies on the two modern tools fzf and fd. This project is only a stitching tool for the glue layer.

1.3.1 User Distribution Feature

  • The administrator's user distribution function is fully interactive and can choose a series of functions such as user grouping, user permission visudo settings, user key distribution, etc.

new-user.gif

1.3.2 User Broadcast Feature

  • The essence of user broadcasting is that all users will load /opt/lab-server-ops/lso_user/script_broadcast/broadcast.sh
  • Administrators only need to modify this file to implement the user broadcast function.
#.zshrc

# ------------------- broadcast ---------------------
bash "/opt/lab-server-ops/lso_user/script_broadcast/broadcast.sh"

1.3.3 User Basic Configuration

  • Users generated through distribution have pre-configured basic tools
  • The .vimrc/.zshrc/.tmux.conf under the user's directory have been pre-configured
  • The public and private keys under the user's directory .ssh have been pre-configured

1.3.4 Convenience Enhancement Feature

  • You can make fuzzy jumps and edits between directories
  • You can fuzzy query the history record

command.gif

2. Installation

2.1 Confirm Branch

  • Please make sure your system is one of Deiban/Raspbian/Ubuntu/CentOS/MacOS.
  • If your system is Ubuntu(>= 19.04) or Debian/Raspbian >= 10.0, please execute
git checkout linux
  • If your system is Ubuntu(< 19.04) or Debian/Raspbian < 10.0 or CentOS7/8, please execute
git checkout linux-minimum
  • If your system is macOS please execute
git checkout mac-personal

This project has the function of automatically detecting the operating system. If the branch does not meet the requirements, automatic switching will be performed

2.2 Installation Process

2.2.1 linux Branch

  1. Pull the project
git clone https://github.com/Albert26193/lab-server-ops.git

# branch: linux
git checkout linux
  1. Install dependencies
# enter project
cd ./install

# install dependency
sudo bash install_dependency.sh

The following dependencies will be installed

    local install=(
        "tmux"
        "vim"
        "git"
        "curl"
        "wget"
        "tree"
        "fd-find"
        "fzf"
        "bat"
        "exa"
        "nvim"
    )
  1. Install the project
sudo bash install.sh
  1. Add administrator command entry

Please add the following command to your .zshrc/.bashrc according to your actual situation

source "/opt/lab-server-ops/lso_admin/lso.sh"

Then execute the following command to reload the configuration file

source ~/.zshrc
# or  source ~/.bashrc

2.2.2 linux-minimum Branch

  1. Pull the project
git clone https://github.com/Albert26193/lab-server-ops.git

# branch: linux-minimum
git checkout linux-minimum
  1. Install dependencies
# enter project
cd ./install

# install dependency
sudo bash install_dependency.sh

The following dependencies will be installed

    local install=(
        "tmux"
        "vim"
        "git"
        "curl"
        "wget"
        "tree"
    )
  1. Install the project
sudo bash install.sh
  1. Add administrator command entry

Please add the following command to your .zshrc/.bashrc according to your actual situation

source "/opt/lab-server-ops/lso_admin/lso.sh"

Then execute the following command to reload the configuration file

source ~/.zshrc
# or  source ~/.bashrc

2.2.3mac-personal Branch

  1. Pull the project
git clone https://github.com/Albert26193/lab-server-ops.git

# branch: mac-personal
git checkout mac-personal
  1. Install dependencies
  • πŸ›‘ You need to ensure that brew is installed locally in advance
# enter project
cd ./install

# install dependency
bash install_dependency.sh

The following dependencies will be installed

    local install=(
        "tmux"
        "vim"
        "git"
        "curl"
        "wget"
        "tree"
        "fd"
        "fzf"
        "bat"
        "exa"
        "nvim"
    )
  1. Install the project
bash install.sh

3. Usage

3.1 For Linux Administrators

  • After the installation is complete, your .zshrc or .bashrc should have added the command entry
source "/opt/lab-server-ops/lso_admin/lso.sh"
  • Then, execute the following command
lso_admin
  • The output is as follows

image.png

  • In the interactive panel, you will have two options

    1. Add new users: useradd, enter 1
    2. Add zsh related configuration for existing users: addzsh, enter 2
  • Then, you can interactively select user settings (grouping, key, creating symbolic links, etc.) 🍺️

3.2 For Ordinary Users

  • The commands that ordinary users can get can be viewed in .zshrc
# ~/.zshrc

# ------------------  lab-server-ops ----------------

source "${HOME}/.lso.env"
source "/opt/lab-server-ops/lso_user/lso.sh"

alias "fs"="lso_fuzzy_search"
alias "fj"="lso_fuzzy_jump"
alias "fe"="lso_fuzzy_edit"
alias "hh"="lso_fuzzy_history"
alias "pon"="lso_proxy_on"
alias "poff"="lso_proxy_off"
  • fs: fuzzy search fuzzy search, accepts two parameters, can perform fuzzy matching on directories, its configuration please refer to ~/.lso.env
  • fj: fuzzy jump fuzzy jump, accepts two parameters, can perform fuzzy jump on directories, its configuration please refer to ~/.lso.env
  • fe: fuzzy edit fuzzy edit, accepts two parameters, can perform fuzzy edit on directories, its configuration please refer to ~/.lso.env, the editor defaults to vim, you can replace it with other editors.
  • hh: fuzzy history fuzzy history match, accepts two parameters, can perform fuzzy search and match on all zsh history records.
  • pon: proxy on, can forward the current shell traffic, accepts two parameters, parameter 1 is the target server IP address, parameter 2 is the target server port
  • poff: proxy off, turn off proxy

If there are no related commands in .zshrc, it means that the Linux version is not enough, and the linux-minimum related commands are loaded

4. Configuration

  • The configuration part is for the .lso.env file, this file controls the range of fuzzy adjustment and indexing, you can freely add ignore directories and query range directories.
  • The default configuration is as follows
#!/bin/bash

# in which dir to search
lso_search_dirs=(
    "${HOME}"
    #"CodeSpace"
)

# within search range, which dir to ignore
lso_search_ignore_dirs=(
    # "Downloads"
    # "Desktop"
    # "Documents"
    ".git"
    ".local"
    ".m2"
    ".gradle"
    ".wns"
    ".nvm"
    ".npm"
    ".nrm"
    ".red-hat"
    ".redhat"
    ".oh-my-zsh"
    ".github"
    ".cache"
    ".cargo"
    ".rustup"
    ".vscode"
    ".vscode-insiders"
    ".vscode-server-insiders"
    ".vscode-server"
    ".vscode-oss"
    ".vscode-oss-insiders"
    "lib"
    "node_modules"
    "pkg"
    "bin"
    "dist"
    "pkgs"
    "from-github"
    "assets"
    "image"
    "images"
    "static"
    "data"
    "raycast"
    "obsidian-*"
    "zlt-*"
    "anaconda3"
    "Applications"
    "Library"
    "Movies"
    "Music"
    "Pictures"
    "Public"
    "Remote"
    "Zotero"
    "EVPlayer2_download"
)

# search preview or not, true: preview | false: not preview
# if your machine is not powerful enough(RAM <= 1GiB), set it to false
# otherwise, set it to true(Recommend)
lso_search_preview=true
#lso_search

5. Development Plan

  1. Add command audit function
  2. Add administrator functions related to deleting users
  3. Add administrator functions related to network and disk

lab-server-ops's People

Contributors

albert26193 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

sunshowsway

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.