You are not logged in.

#1 2012-11-26 02:16:39

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

serman: simple ncurses-based systemd service file manager

Project page: http://xyne.archlinux.ca/projects/serman/
Serman (service manager) is a simple ncurses-based systemd service manager. It provides an easy way to manage services with an overview of what is currently enabled, running, etc.

Serman2: Python curses rewrite

The package now includes a second executable named serman2. All of the service management functionality works but there are still a few gui bugs (mostly when reszing the window in text view). I'll sort that out soon. In the meantime, please test it and post feedback.

Screenshot of the new version

serman_10.png



Screenshot of the old version

serman_02.png
(There are more on the project page.)

Original Post

I wrote a simple script for basic dialog-based systemd service file management (enable/disable, start/stop). There's probably some much more robust, built-in way to do this with systemd but I didn't find it. Besides, I had just finished setting up systemd and writing netcfg-checklist, so curiosity got the best of me.

If this is useful it will likely be expanded and packaged. You can get serman here for now. See

serman -h

for options.

Caveats: I'm a systemd noob and this has not been extensively tested. That said, the script is simple and it should be safe unless you run it as root and play Russian roulette with the core services.

Feedback welcome.

Last edited by Xyne (2013-03-01 08:32:20)

Offline

#2 2012-11-26 03:02:16

bslackr
Member
Registered: 2012-01-27
Posts: 131

Re: serman: simple ncurses-based systemd service file manager

Just tried it, and it didn't work tongue

Traceback (most recent call last):
  File "./serman", line 161, in <module>
    main()
  File "./serman", line 86, in main
    newly_enabled = checked - enabled
UnboundLocalError: local variable 'enabled' referenced before assignment

Offline

#3 2012-11-26 13:36:17

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

Re: serman: simple ncurses-based systemd service file manager

fixed

Offline

#4 2012-11-26 15:42:32

bslackr
Member
Registered: 2012-01-27
Posts: 131

Re: serman: simple ncurses-based systemd service file manager

Works well now, seems pretty useful. Thanks.

Offline

#5 2013-01-20 19:47:44

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

Re: serman: simple ncurses-based systemd service file manager

Added some new options:

usage: serman [-h] [-e] [-o <unit command>] [-r] [-s] [--height HEIGHT]
              [--width WIDTH] [--list-height LIST_HEIGHT]

Generate dialogues for systemd service management.

optional arguments:
  -h, --help            show this help message and exit
  -e, --enable          Enable and disable services.
  -o <unit command>, --other <unit command>
                        Run a unit command on each selected service.
  -r, --restart         Start or restart services.
  -s, --start           Start and stop services.

Geometry:
  --height HEIGHT       Dialogue height. Default: Adjusted to fit list height.
  --width WIDTH         Dialogue width. Default: 60.
  --list-height LIST_HEIGHT
                        Dialogue list-height. Default: 13.

I'll likely package it soon.

Offline

#6 2013-03-01 08:32:34

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

Re: serman: simple ncurses-based systemd service file manager

*bump*
packaged

Offline

#7 2013-03-01 08:54:05

elkoraco
Member
Registered: 2013-02-18
Posts: 121

Re: serman: simple ncurses-based systemd service file manager

This is good stuff, like rcconf for sysvinit. You might see about getting it included upstream, I know Lennart was talking about being open to a python/C curses frontend next to systemadm.

Offline

#8 2013-03-01 09:50:41

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

Re: serman: simple ncurses-based systemd service file manager

This is probably too simplistic for upstream inclusion. A python curses rewrite is on my todo list.  Maybe then it will be worth contacting upstream.

Thanks for the feedback.

Offline

#9 2013-03-01 09:54:09

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,838

Re: serman: simple ncurses-based systemd service file manager

Looks nice and pre-empted my simple bash wrapper that one day I'd get round to writing.
Is there any chance of allowing the ability to pass "--user" through to work on user units?


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#10 2013-03-01 10:07:20

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,485
Website

Re: serman: simple ncurses-based systemd service file manager

skanky wrote:

any chance of allowing the ability to pass "--user" through to work on user units?

I was wondering this same thing. If it can work on both --system and --user, that would be really quite cool.

All the best,

-HG

P.S., Curses is awesome, do all the things in curses!


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

#11 2013-03-01 12:40:29

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

Re: serman: simple ncurses-based systemd service file manager

Rather than gradually duplicate multiple systemctl options, I have added a single option to pass remaining arguments to systemctl. I don't use systemd login sessions so I can't test it, but you should now be able to manage user services with "-a --user" at the end of the command. If it doesn't work, use the new "--dry-run" option, inspect the command, determine what is wrong with it, and let me know how to fix it.

New options:
-a, --args: additional arguments to systemctl
--systemctl: systemctl binary
--dry-run: print systemctl commands instead of running them (still runs some commands to list services)

The extra arguments are directly passed to systemctl without any parsing, so make sure that you know what you are doing when you use that option.

Offline

#12 2013-03-01 13:01:45

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,838

Re: serman: simple ncurses-based systemd service file manager

Just tried it with --user and it worked great, thanks. Didn't try all operations with it, just status and restart (I'll probably use those two 80% of the time), and they worked well.
Many thanks.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#13 2013-03-17 19:06:38

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

Re: serman: simple ncurses-based systemd service file manager

Xyne wrote:

A python curses rewrite is on my todo list.

Well, that's mostly done now. I was just going to glance over the Python curses documentation but got sucked into programmer's limbo and ended up rewriting serman in a single session. The code needs some cleaning (one session + completely new to ncurses = suboptimal design but too too shabby for a first attempt) and there are still a few gui bugs* (but none in service management, at least not that I've found so far).

I have included the new version as "serman2" in the package. Please give it a try. You can see a screenshot in the OP (there's another one on the site).

Quickstart guide:
serman2 --help shows the current options (minor changes)
Run serman2 and press F1 to get to the help message.

Check the comments at the top of the file for more information. I'll fix any bugs in service management as soon as I become aware of them (not expecting any though, because it's the same code as the original serman). I don't want to deal with curses resizing errors any time soon, Maybe it's just because I'm ridiculously tired, but the geometry management remains a black art to me at this point.*


Enjoy!


* If you shrink the help message window horizontally, it doesn't update, but shrinking it vertically or expanding in any direction works as expected. I think the problem is that each time it is shrunk, a character is written outside of the allocated horizontal space, but I just can't for the life of me figure out what I need to adjust. Again, I'm ridiculously tired so probably missing something simple, but it just makes no sense to me and the fscking "ERR" error messages don't help.


Sleepy time.

Offline

#14 2013-03-17 19:34:05

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: serman: simple ncurses-based systemd service file manager

I just installed this from the AUR and there is no serman2... am I missing something or is this an oversight due to sleep deprivation?

Offline

#15 2013-03-17 19:40:06

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

Re: serman: simple ncurses-based systemd service file manager

WonderWoofy wrote:

or is this an oversight due to sleep deprivation?

yeah, that

I forgot to sync my AUR packages after mirroring to the server. It's up now (just downloaded it and checked)


also, not using my repo sad mad yikes

Offline

#16 2013-03-17 19:42:32

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: serman: simple ncurses-based systemd service file manager

Then have a nice and healthy sleep!!

To quit serman2, which works with Ctrl+c, I expected something like 'q'. Would be more consistent with other cli apps imo. And maybe include vim-like navigation (hjkl, gg, G)? Don't know if I'll ever need this, but it sure looks nice smile

Offline

#17 2013-03-17 19:43:45

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: serman: simple ncurses-based systemd service file manager

Xyne wrote:

also, not using my repo

I know you have a repo, but your stuff tends to be just scripts, so because I only take a few things here and there from your contributions, I figure using the AUR for your stuff with the zero compile time it takes is not such a hassle...


Edit: Okay, its working, and its real purdy... though I have noticed two things I figured I should report back to you.  One is that it doesn't seem to handle the @ services.  Like netctl-auto@.service is indeed active as netctl-auto@wlan0.service.  Also it would be nice with some vi keybindings smile

Last edited by WonderWoofy (2013-03-17 19:50:01)

Offline

#18 2013-03-17 20:06:45

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

Re: serman: simple ncurses-based systemd service file manager

@Army & @WonderWoofy
I bound q at first, but then I made it possible to jump to characters in lists by typing them. Maybe I'll rework it later to use meta keys (maybe alt?).  The same considerations apply for vim key bindings. I plan to make it configurable in any case but I want to give it some thought first. The easiest way will be to dump all the colors, symbols, status messages and binds in a JSON file and let the user configure that however he wants.

I'm looking at a minor bug in service detection right now. I noticed that it effectively filters some of them.

Offline

#19 2013-05-01 23:20:57

PrivateLooms
Member
Registered: 2010-11-19
Posts: 5

Re: serman: simple ncurses-based systemd service file manager

I have installed serman from the AUR, but upon using serman2 , I have noticed that the status triangles & icons are not shown.

a friend has also installed it & reported the same problem.

Screenshot - image link

modedit (Xyne)
replace huge image with link to avoid accusations of letting things slide in my threads wink

Offline

#20 2013-05-02 03:27:04

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,632
Website

Re: serman: simple ncurses-based systemd service file manager

I don't think xterm supports Unicode characters. On my system, it displays empty boxes where the symbols should be, I don't know why you see nothing at all instead of boxes.

Try using rxvt-unicode instead of xterm. If you still don't see the symbols then it's likely due to missing fonts. Can you see the symbols below in your webbrowser?

circle: ●
triangle: ▲

I think they're provided by ttf-freefont so you can try installing that. If that fixes it, then I will add it as a dependency.

Otherwise, post the output of

post the output of

pacman -Qqs font

Offline

#21 2013-05-02 04:43:16

PrivateLooms
Member
Registered: 2010-11-19
Posts: 5

Re: serman: simple ncurses-based systemd service file manager

Thanks for the quick reply.


As for the symbols in the browser, yes I can see them, but I have installed (urxvt & ttf-freefont) & I still can't see the symbols in serman.

here is the output : 

[ArchLinux] >>  pacman -Qqs font

bdf-unifont
cantarell-fonts
font-misc-ethiopic
fontconfig
fontsproto
freetype2
gsfonts
lib32-freetype2
libfontenc
libxfont
libxft
pangox-compat
ttf-arabeyes-fonts
ttf-bitstream-vera
ttf-dejavu
ttf-freefont
ttf-ms-fonts
xorg-bdftopcf
xorg-font-util
xorg-font-utils
xorg-fonts-100dpi
xorg-fonts-75dpi
xorg-fonts-alias
xorg-fonts-encodings
xorg-fonts-misc
xorg-mkfontdir
xorg-mkfontscale

Last edited by PrivateLooms (2013-05-02 04:48:02)

Offline

#22 2013-05-02 04:55:09

PrivateLooms
Member
Registered: 2010-11-19
Posts: 5

Re: serman: simple ncurses-based systemd service file manager

Thanks for your help anyway.

it got fixed when I entered the following command

 export LANG=en_US.UTF-8 

Last edited by PrivateLooms (2013-05-02 07:05:12)

Offline

#23 2013-05-11 00:30:37

karol
Archivist
Registered: 2009-05-06
Posts: 25,423

Re: serman: simple ncurses-based systemd service file manager

Xyne wrote:

I don't think xterm supports Unicode characters.

On my system it does, both running as 'xterm' and as 'uxterm'.


Nice work, as always :-)

Offline

#24 2013-05-11 00:37:59

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,491
Website

Re: serman: simple ncurses-based systemd service file manager

This is great - I'm loving serman2.  Is there a way to go back to the "default" view though from the F1/F2 displays?  Right now I can't find anyway to do so but to Ctrl-C then restart serman2.  Also, I'm currently getting a blank screen with F2 on any service, but this may be due to permissions issues with systemd-journal which I've never gotten around to setting up properly.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#25 2013-05-11 00:39:39

karol
Archivist
Registered: 2009-05-06
Posts: 25,423

Re: serman: simple ncurses-based systemd service file manager

Trilby wrote:

Is there a way to go back to the "default" view though from the F1/F2 displays?  Right now I can't find anyway to do so but to Ctrl-C then restart serman2.

Press enter.
In the 'Text Views (F1, F2)' section the last bullet point says "enter returns to the main view".

It kinda forces you to read the whole thing once you press F1 when just trying things out ;P

Trilby wrote:

Also, I'm currently getting a blank screen with F2 on any service, but this may be due to permissions issues with systemd-journal which I've never gotten around to setting up properly.

Same here.

Last edited by karol (2013-05-11 00:43:46)

Offline

Board footer

Powered by FluxBB