Scripts

A handful of everyday server scripts. Copy one line and run it — reading the source first is recommended.

Filter by tag

Showing 23 of 23

System info at a glance

Runs as any userRead-only

One command to see the distro, kernel, CPU, memory, disk, network interfaces and common service states. Read-only, changes nothing.

curl -fsSL https://www.moiu.cn/scripts/sysinfo.sh | bash
  • system
  • readonly

Install Docker

Root required

Installs Docker and Compose with the official script and writes in mainland mirror accelerators. Asks before reinstalling.

curl -fsSL https://www.moiu.cn/scripts/docker-install.sh | bash
  • docker
  • install

Enable BBR

Root required

Switches congestion control to BBR and the queueing discipline to fq via sysctl.d. Exits early on kernels below 4.9.

curl -fsSL https://www.moiu.cn/scripts/bbr-enable.sh | bash
  • network
  • tuning

Set up swap

Root required

Creates a swap file of the given size at /swapfile, adds it to fstab for boot, and lowers swappiness to 10.

curl -fsSL https://www.moiu.cn/scripts/swap-setup.sh | bash
  • memory
  • tuning

Harden SSH

Root required

Disables root login and password auth, tightens retries and the auth window. Refuses to run without an SSH key, and rolls back if sshd -t fails.

curl -fsSL https://www.moiu.cn/scripts/ssh-harden.sh | bash
  • security
  • ssh

Archive a directory

Runs as any user

Packs a directory into a timestamped tar.gz, excluding node_modules, .git, caches and dist. No root needed.

curl -fsSL https://www.moiu.cn/scripts/dir-backup.sh | bash
  • backup
  • ops

Install Komari

Root required

Deploys the Komari monitor using the NJU mirror, with data persisted at /opt/komari/data. Requires Docker first.

curl -fsSL https://www.moiu.cn/scripts/komari-install.sh | bash
  • monitor
  • docker

Uninstall Nezha Agent

Root required

Stops services, removes systemd units, cleans directories and leftover processes, then verifies itself. Handles random-suffixed names.

curl -fsSL https://www.moiu.cn/scripts/nezha-uninstall.sh | bash
  • ops
  • cleanup

System update

Root required

Refreshes package sources, upgrades installed packages and drops unused dependencies. Warns about a pending reboot instead of taking one.

curl -fsSL https://www.moiu.cn/scripts/system-update.sh | bash
  • update
  • system

Set the time zone

Root required

Defaults to Asia/Shanghai and turns on NTP sync. Pass a zone name to change it, for example UTC.

curl -fsSL https://www.moiu.cn/scripts/timezone-set.sh | bash
  • system
  • time

Set up the firewall

Root required

Denies inbound by default, allows outbound, and opens only SSH plus 80/443. Allows SSH before enabling, so you are not locked out.

curl -fsSL https://www.moiu.cn/scripts/ufw-firewall.sh | bash
  • security
  • network

Install Nginx

Root required

Installs, starts and enables Nginx on boot. If it is already installed it exits without touching your configuration.

curl -fsSL https://www.moiu.cn/scripts/nginx-install.sh | bash
  • web
  • install

Get a TLS certificate

Root required

Uses the certbot nginx plugin to rewrite the config, set up the renewal timer and redirect http to https. The domain must already point here.

curl -fsSL https://www.moiu.cn/scripts/certbot-ssl.sh | bash
  • web
  • tls

Clean up disk space

Root required

Clears apt caches, unused dependencies, journal logs, stale /tmp files and dangling Docker images. Leaves /home and your app directories alone.

curl -fsSL https://www.moiu.cn/scripts/disk-cleanup.sh | bash
  • ops
  • disk

Check port usage

Runs as any userRead-only

Lists listening ports with their processes; pass a port number to narrow it down. Read-only, no root needed.

curl -fsSL https://www.moiu.cn/scripts/port-usage.sh | bash
  • network
  • readonly

Install Node.js

Root required

Installs a chosen major version from the official NodeSource repository (22 LTS by default). Asks before overwriting an existing install.

curl -fsSL https://www.moiu.cn/scripts/nodejs-install.sh | bash
  • runtime
  • install

Install fail2ban

Root required

Sets up an sshd jail that bans an address for an hour after five failures within ten minutes. Pairs well with the firewall script.

curl -fsSL https://www.moiu.cn/scripts/fail2ban-install.sh | bash
  • security
  • install

Set up key-based login

Root required

Writes a public key into the given user authorized_keys and fixes the permissions. The key arrives as an argument, never from standard input.

curl -fsSL https://www.moiu.cn/scripts/ssh-key-setup.sh | bash
  • security
  • ssh

Add a sudo user

Root required

Creates a user with sudo rights and optionally installs a public key for it. Detects whether the admin group is called sudo or wheel.

curl -fsSL https://www.moiu.cn/scripts/user-add.sh | bash
  • security
  • ops

Raise file descriptor limits

Root required

Raises nofile to 65535 and lifts file-max plus the connection backlogs. Busy services tend to hit exactly these three walls.

curl -fsSL https://www.moiu.cn/scripts/limits-tune.sh | bash
  • tuning
  • system

Check certificate expiry

Runs as any userRead-only

Scans the usual certificate directories and can check a live domain, reporting days left. Read-only.

curl -fsSL https://www.moiu.cn/scripts/cert-check.sh | bash
  • tls
  • readonly

Check DNS and connectivity

Runs as any userRead-only

Shows the configured resolvers, whether a domain resolves, whether public DNS is reachable, and the outbound IP. Read-only.

curl -fsSL https://www.moiu.cn/scripts/dns-check.sh | bash
  • network
  • readonly

List scheduled jobs

Root requiredRead-only

Lists every user crontab, /etc/cron.d and the systemd timers. For finding out what runs at 3am. Read-only, but needs root.

curl -fsSL https://www.moiu.cn/scripts/crontab-list.sh | bash
  • ops
  • readonly