1.0.2 ā€¢ Published 1 year ago

@sys-cli/core v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

sys-cli

Portable basic system network configuration provider command-line tool.

Table of contents

Install

$ sudo npm install --global @sys-cli/core

Features

  • Set the system network (ip/netmask/gateway/ifname/cidr), and search adaptively according to the network card ports existing in the system.
  • Set the system hostname and update the hostname mapping relationship in /etc/hosts.

Usage

In this section, we are going to review all the sub-commands and use-cases associated with the sys-cli command-line tool through different examples.

Help

  • main command
[root@localhost ~]# sys-cli -h
Usage: sys-cli <command> [options]

Options:
  -V, --version        output the version number
  -d, --debug          whether to enable debug mode (default: false)
  -h, --help           display help for command

Commands:
  netconfig [options]  linux system network interface configuration
  osconfig [options]   linux system basic configuration
  help [command]       display help for command
  • subcommand
[root@localhost ~]# sys-cli sysconfig -h
Usage: sys-cli netconfig [options]

linux system network interface configuration

Options:
  -c, --cidr <ip/mask>     classless inter-domain routing
  -g, --gateway <gateway>  gateway address
  -i, --ipaddr <ipaddr>    ipv4 address
  -m, --netmask <netmask>  subnet mask
  -n, --ifname <ifname>    nic device interface name
  -y, --yes                whether to skip the interaction (default: false)
  -h, --help               display help for command

[root@localhost ~]# sys-cli osconfig -h
Usage: sys-cli osconfig [options]

linux system basic configuration

Options:
  -f, --force                whether to force update configuration (default: false)
  -n, --hostname <hostname>  system hostname
  -h, --help                 display help for command

Example

  • interactive command
[root@localhost ~]# sys-cli netconfig
? Please enter the nic device number ens192    10GbE    šŸ™†šŸ»
? Please enter IP address 10.95.0.52
? Please enter Netmask 255.255.255.240
? Please enter Gateway 10.95.0.49
ā ¹ šŸ›°  Press y to continue...
ā § šŸš€ Start setting up local network services...
sys-cli success šŸŽ‰ Network setup successful ~
  • non-interactive command
# set network
[root@localhost ~]# sys-cli netconfig -n eth0 -i 192.168.0.100 -m 255.255.255.0 -g 192.168.0.254 -y
sys-cli success šŸŽ‰ Network setup successful ~

# cidr options
[root@localhost ~]# sys-cli netconfig --ifname ens192 --cidr 10.0.128.5/24 --gateway 10.0.128.1 -y
sys-cli success šŸŽ‰ Network setup successful ~

# set hostname
[root@localhost ~]# sys-cli osconfig -n my-dev-server -f
sys-cli success šŸŽ‰ The hostname is set successfully ~

Notes

  • Use this scaffolding to quickly and easily configure your system, like setting up networking, hostnames, etc.

  • Only applicable to GNU/Linux system, currently adapted distributions, such as: CentOS7, Debian11, RHEL7.5, OpenSUSE12.3, etc.

  • Directory tree after installation

.
ā”œā”€ā”€ bin                               # Command env path
ā”‚   ā””ā”€ā”€ sys-cli -> ../lib/node_modules/@sys-cli/core/bin/sys-cli.js
ā””ā”€ā”€ lib                               # Scaffolding internal link library
    ā””ā”€ā”€ node_modules
        ā””ā”€ā”€ @sys-cli
            ā””ā”€ā”€ core
                ā”œā”€ā”€ LICENSE
                ā”œā”€ā”€ README.md
                ā”œā”€ā”€ bin
                ā”œā”€ā”€ lib
                ā”œā”€ā”€ node_modules
                ā””ā”€ā”€ package.json