Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systemd unit files support on Debian / Ubuntu #8

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bitsrun"
description = "A headless login and logout CLI for 10.0.0.55 at BIT"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
license = "MIT"
homepage = "https://github.com/spencerwooo/bitsrun-rs"
Expand Down Expand Up @@ -43,3 +43,5 @@ strip = "symbols"

[package.metadata.deb]
copyright = "2023 Spencer Woo"
maintainer-scripts = "debian/"
systemd-units = { enable = true, start = false }
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![GitHub release (with filter)](https://img.shields.io/github/v/release/spencerwooo/bitsrun-rs)](https://github.com/spencerwooo/bitsrun-rs/releases/latest)
[![Crates.io](https://img.shields.io/crates/v/bitsrun?color=rgb(221%2C%20170%2C%2071))](https://crates.io/crates/bitsrun)

๐ŸŒ A headless login and logout CLI app for 10.0.0.55 at BIT, now in Rust.
๐ŸŒ A headless login and logout CLI for 10.0.0.55 at BIT, now in Rust.

![screenshot](https://github.com/spencerwooo/bitsrun-rs/assets/32114380/011e7591-1474-4df8-a371-7a9da7629959)

Expand All @@ -15,10 +15,11 @@

- `curl -fsSL https://cdn.jsdelivr.net/gh/spencerwooo/bitsrun-rs@main/install.sh | sh -`

#### Ubuntu / Debian
#### Ubuntu / Debian (recommended for `systemd` support)

- Download the latest `.deb` package from [Releases](https://github.com/spencerwooo/bitsrun-rs/releases/latest).
- `sudo dpkg -i <file>.deb`
- `sudo apt install ./<path/to/file>.deb`
- Start `bitsrun.service` if desired: edit `/lib/systemd/system/bitsrun.service` to specify absolute config path, then `sudo systemctl start bitsrun`

#### Cargo

Expand Down Expand Up @@ -54,6 +55,19 @@ bitsrun: <ip> (<username>) is online
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

To keep the session alive, use `bitsrun keep-alive`:

```console
$ bitsrun keep-alive
INFO bitsrun::daemon > starting daemon (<username>) with polling interval=3600s
INFO bitsrun::daemon > <ip> (<username>): login success,
...
^C INFO bitsrun::daemon > <username>: gracefully exiting
```

> [!NOTE]
> Use available system service managers to run `bitsrun keep-alive` as a daemon. (e.g., `systemd` for Linux, `launchd` for macOS, and Windows Service for Windows).

## Available commands

```console
Expand Down
11 changes: 11 additions & 0 deletions debian/bitsrun.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=bitsrun - A headless login and logout CLI for 10.0.0.55 at BIT
After=network.target

[Service]
Type=simple
Restart=on-abort
ExecStart=/usr/bin/bitsrun keep-alive --config /path/to/bit-user.json

[Install]
WantedBy=multi-user.target