Skip to content

Commit

Permalink
Added manpage sources.
Browse files Browse the repository at this point in the history
Closes #9.
  • Loading branch information
xvitaly committed Apr 11, 2020
1 parent 077a45b commit ace4248
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install:
- sh: >-
sudo apt-get update
sudo apt-get install --yes g++ cmake make
sudo apt-get -y install g++ cmake make
build_script:
- sh: >-
git submodule update --init --recursive
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
os: linux

dist: bionic

language: cpp
Expand Down
2 changes: 2 additions & 0 deletions cmake/External.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(GNUInstallDirs)
include(FindPackageHandleStandardArgs)
include(cmake/FindFmt.cmake)
include(cmake/FindCxxOpts.cmake)
include(cmake/FindPandoc.cmake)
13 changes: 13 additions & 0 deletions cmake/FindPandoc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
find_program(
Pandoc_EXECUTABLE
NAMES pandoc
DOC "Pandoc main executable"
)

find_package_handle_standard_args(
Pandoc
FOUND_VAR Pandoc_FOUND
REQUIRED_VARS Pandoc_EXECUTABLE
)

mark_as_advanced(Pandoc_EXECUTABLE)
121 changes: 121 additions & 0 deletions packaging/assets/manpage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
% zswap-cli(1) | General Commands Manual

# NAME

zswap-cli - command-line tool to control ZSwap Linux kernel module

# SYNOPSIS

**zswap-cli** [**OPTION**...]

# DESCRIPTION

ZSwap-cli is a simple command-line tool to control ZSwap Linux kernel module.

# COMMAND-LINE OPTIONS

#### \-\-env
Get options from environment variables instead of cmdline.

#### -e, \-\-enabled
Enable or disable ZSwap kernel module.

#### -s, \-\-same_filled_pages_enabled
Enable or disable memory pages deduplication.

#### -p, \-\-max_pool_percent
The maximum percentage of memory that the compressed pool can occupy.

#### -c, \-\-compressor
The default comression algorithm.

#### -z, \-\-zpool
The kernel's zpool type.

#### -a, \-\-accept_threhsold_percent
The threshold at which ZSwap would start accepting pages again after it became full.

#### -h, \-\-help
Print help message and exit.

# ENVIRONMENT OPTIONS

ZSwap-cli support of getting options from environment variables.

## Supported options

* **ZSWAP_ENABLED_VALUE** - enable (**Y**) or disable (**N**) ZSwap kernel module.
* **ZSWAP_SAME_FILLED_PAGES_ENABLED_VALUE** - enable (**Y**) or disable (**N**) memory pages deduplication.
* **ZSWAP_MAX_POOL_PERCENT_VALUE** - the maximum percentage of memory that the compressed pool can occupy (integer from **1** to **100**).
* **ZSWAP_COMPRESSOR_VALUE** - the default comression algorithm.
* **ZSWAP_ZPOOL_VALUE** - the kernel's zpool type.
* **ZSWAP_ACCEPT_THREHSOLD_PERCENT_VALUE** - the threshold at which ZSwap would start accepting pages again after it became full (integer from **1** to **100**).

## Forwarding options

Export environment options using `export` command:

```
export ZSWAP_ENABLED_VALUE=Y
export ZSWAP_SAME_FILLED_PAGES_ENABLED_VALUE=Y
export ZSWAP_MAX_POOL_PERCENT_VALUE=60
export ZSWAP_COMPRESSOR_VALUE=zstd
export ZSWAP_ZPOOL_VALUE=z3fold
export ZSWAP_ACCEPT_THREHSOLD_PERCENT_VALUE=40
```

Start application with `--env` command-line argument:

```
sudo zswap-cli --env
```

# EXIT STATUS

0: Successful exit.

1: Insuffient access rights.

# SYSTEMD UNIT

After installation, the systemd-unit **zswap-cli.service** will be added.

## Changing settings

All settings are stored in **/etc/default/zswap-cli** file. It use environment options syntax.

## Enabling unit

Enable systemd-unit and run it on system startup:

```
sudo systemctl enable --now zswap-cli.service
```

## Disabling unit

Disable systemd-unit and stop runing it on system startup:

```
sudo systemctl disable zswap-cli.service
```

## Running unit

You can also run systemd-unit without adding it to startup.

Start unit and enable ZSwap:

```
sudo systemctl start zswap-cli.service
```

Stop unit and disable ZSwap:

```
sudo systemctl stop zswap-cli.service
```

# AUTHORS

Vitaly Zaitsev ⟨[email protected]⟩.
7 changes: 6 additions & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ add_executable(zswap-cli ${INTERNAL_LIBS})
target_link_libraries(zswap-cli PRIVATE ${EXTERNAL_LIBS})

configure_file("${CMAKE_SOURCE_DIR}/packaging/assets/zswap-cli.service.in" "${CMAKE_CURRENT_BINARY_DIR}/zswap-cli.service" @ONLY)

install(TARGETS zswap-cli DESTINATION "${CMAKE_INSTALL_SBINDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zswap-cli.service" DESTINATION "lib/systemd/system")
install(FILES "${CMAKE_SOURCE_DIR}/packaging/assets/zswap-cli.default" DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/default" RENAME "zswap-cli")

if (Pandoc_FOUND)
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/zswap-cli.1" COMMAND "${Pandoc_EXECUTABLE}" ARGS "${CMAKE_SOURCE_DIR}/packaging/assets/manpage.md" -s -t man -o "${CMAKE_CURRENT_BINARY_DIR}/zswap-cli.1" COMMENT "Building manpage using Pandoc." VERBATIM)
add_custom_target(zswap-man ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/zswap-cli.1")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zswap-cli.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
endif()

0 comments on commit ace4248

Please sign in to comment.