Skip to content
/ os Public

Space.sh module to handle operating system tasks such as user processes, packages and services management

License

Notifications You must be signed in to change notification settings

space-sh/os

Repository files navigation

OS module | build status

Handle operating system tasks such as user management, packages and services management.

/creategroup/

Create a group in the system

/createuser/

Create a new user

/disableroot/

Disable root login

Run this to make it so that the root user no longer can login
over SSH. This increases the security of the machine.
Note: make sure the super user has been setup successfully first.

/disableuser/

Disable an user account

Disable a user from logging in.

/groupexist/

Check if a group exists

/harden/

Harden the machine

/info/

Show information about the OS

/install/

Install any pkg

Pkg name as positional argument.
Always provide Debian names.

/installsudo/

Install the 'sudo' pkg

/mksudo/

Make an existing user into sudo

/motd/

Create/replace motd file

/reboot/

Reboot the system

/security/

  • limits

/service/

Control a service

/shell/

Enter into shell

/update/

Update the OS package lists

/upgrade/

Update and upgrade OS

/userexist/

Check if a user exists

Functions

OS_DEP_INSTALL()

Check for dependencies

OS_ID()

Get the OS identification and package manager.

Expects:

  • out_ostype
  • out_ospkgmgr
  • out_oshome - Users home dir.
  • out_oscwd - Current CWD.

OS_INFO()

Show some information about the current OS.

OS_IS_INSTALLED()

Check if program is installed.
If not installed then install its package, if provided.

Parameters:

  • $1: program name
  • $2: package name

Returns:

  • 0: program is available
  • 0: program is not available and failed to install it

_OS_PKG_TRANSLATE()

Translates Debian style package names into
the current OS package manager naming.

A translation could be translated into one or many
package names.

Expects:

  • ${pkg}: package(s) name(s) to adjust

_OS_PROGRAM_TRANSLATE()

Translates Debian style program names into
the current OS distributions program naming.

Expects:

  • ${program}: program name to translate

OS_INSTALL_PKG()

Install one or more packages.

Give the Debian style name of packages
and the function will attempt to translate
it to the current package managers name for it.

Parameters:

  • $1: package(s) name(s)

Returns:

  • 0: success
  • 1: failed to install package either due to unknown package manager or package name

OS_UPDATE()

Update the system package lists.

OS_UPGRADE()

Upgrade the system.

Returns:

  • Non-zero on error.

OS_SERVICE()

Control a service.

Parameters:

  • $1: service name
  • $2: action

Returns:

  • 0: success
  • 1: failure

OS_REBOOT()

Reboot the system.

OS_USER_EXIST()

Check if a user does exist.

Parameters:

  • $1: the name of the user to lookup.

Returns:

  • 0: users does exist
  • 1: failure. User does NOT exist

OS_GROUP_EXIST()

Check if a group does exist.

Parameters:

  • $1: the name of the group to lookup.

Returns:

  • 0: group does exist
  • 1: failure. Group does NOT exist

OS_CREATE_USER()

Create passwordless user and install ssh key for it.

Parameters:

  • $1: The name of the user to create.
  • $2: Path of the pub key file to install for the user.

Returns:

  • 0: success
  • 1: failure

OS_ADD_USER()

Add a user, with a home directory.

Parameters:

  • $1: user name
  • $2: home path directory
  • $3: shell path

Returns:

  • 0: success
  • 1: failed to call useradd/adduser

OS_ADD_GROUP()

Add a group to the system

Parameters:

  • $1: group name

Returns:

  • 0: success
  • 1: failed to call groupadd

OS_COMMAND()

Parameters:

  • $1: command to look for

  • Return:

  • Same as 'command'

OS_MKSUDO_USER()

Make a user passwordless SUDO.

Parameters:

  • $1: The name of the user to make into sudo user.

Returns:

  • 0: success
  • 1: failure

OS_USER_ADD_GROUP()

Add a given user to a group

Parameters:

  • $1: user name
  • $2: group name

Returns:

  • Non-zero on error.

OS_MOTD()

Copy a motd file into the system.
Message of the day is the greeting text that shows when you login.

Parameters;
$1: The path of the motd file to upload.

OS_DISABLE_ROOT()

Disable root from logging in both via ssh and physically.

Returns:

  • 0: success
  • 1: failure

OS_DISABLE_USER()

Disable a user from logging in both via ssh and physically.

Parameters:

  • $1: The name of the user to make inactive.

Returns:

  • 0: success
  • 1: failure

OS_SHELL()

Enter userland shell or exec command.

Parameters:

  • $1: shell name (optional).
  • $@: optional commands to run in shell.

OS_KILL_ALL()

Kill all descendant processes to given PID.

Parameters:

  • $1: PID to kill descendants for
  • $2: Include PID it self, default 1.

Returns:

  • non-zero on error

OS_SECURITY_LIMITS_SET()

Configure resource limits

Parameters:

  • $1: domain name (username or groupname, for instance)
  • $2: type of resource limit (soft or hard)
  • $3: resource item name
  • $4: value to attribute to resource item

About

Space.sh module to handle operating system tasks such as user processes, packages and services management

Resources

License

Stars

Watchers

Forks

Languages