Skip to content

Add option for systemd unit naming#1882

Open
TehPeGaSuS wants to merge 4 commits intoeggheads:developfrom
TehPeGaSuS:patch-1
Open

Add option for systemd unit naming#1882
TehPeGaSuS wants to merge 4 commits intoeggheads:developfrom
TehPeGaSuS:patch-1

Conversation

@TehPeGaSuS
Copy link
Contributor

Found by: PeGaSuS
Patch by: PeGaSuS
Fixes:

One-line summary:
Added a way to specify the systemd unit name to avoid accidental overwriting of existing systemd units

Additional description (if needed):

Test cases demonstrating functionality (if applicable):

bots@dev1:~/ptirc/eggdrop/Seeker$ ./scripts/autobotchk seeker.conf -systemd

autobotchk 1.11, (C) 1999-2003 Jeff Fisher (guppy@eggheads.org)
                   (C) 2004-2022 Eggheads Development Team
------------------------------------------------------------

Opening 'seeker.conf' for processing ... done
Scanning the config file .................. done
Enter systemd unit name (without .service) [default: Seeker]: 
Enabling user lingering...
Creating systemd directory...
Created symlink /home/bots/.config/systemd/user/default.target.wants/Seeker.service → /home/bots/.config/systemd/user/Seeker.service.
systemd job successfully installed as 'Seeker.service'.
* Use 'systemctl --user <start|stop|restart|reload|enable|disable> Seeker.service' to control your Eggdrop
Starting Eggdrop...
Success.

bots@dev1:~/ptirc/eggdrop/Seeker$ systemctl --user status Seeker.service
● Seeker.service - Seeker (Eggdrop)
     Loaded: loaded (/home/bots/.config/systemd/user/Seeker.service; enabled; preset: enabled)
     Active: active (running) since Sat 2026-02-28 19:36:44 CET; 13s ago
    Process: 18352 ExecStart=/home/bots/ptirc/eggdrop/Seeker/eggdrop seeker.conf (code=exited, status=0/SUCCESS)
   Main PID: 18353 (eggdrop)
      Tasks: 1 (limit: 3471)
     Memory: 7.6M (peak: 8.7M)
        CPU: 155ms
     CGroup: /user.slice/user-1001.slice/user@1001.service/app.slice/Seeker.service
             └─18353 /home/bots/ptirc/eggdrop/Seeker/eggdrop seeker.conf

Feb 28 19:36:44 dev1.0bin.xyz eggdrop[18352]: Stats.tcl: Data loaded from stats.dat.
Feb 28 19:36:44 dev1.0bin.xyz eggdrop[18352]: Stats.tcl: HTTPD listening on 0.0.0.0:4001
Feb 28 19:36:44 dev1.0bin.xyz eggdrop[18352]: Stats.tcl v1.0 loaded. Tracking by nick. HTTPD: port 4001.
Feb 28 19:36:44 dev1.0bin.xyz eggdrop[18352]: Userfile loaded, unpacking...
Feb 28 19:36:44 dev1.0bin.xyz eggdrop[18352]: === Seeker: 1 channel, 1 user.
Feb 28 19:36:44 dev1.0bin.xyz eggdrop[18352]: Certificate loaded: eggdrop.crt (sha1 fingerprint 6C:92:9D:17:67:A1:EA:96:17:1C:84:37:F0:94:25:88:C2:DD:D0:C5)
Feb 28 19:36:44 dev1.0bin.xyz eggdrop[18353]: Eggdrop v1.10.1+webui (C) 1997 Robey Pointer (C) 1999-2025 Eggheads Development Team
Feb 28 19:36:44 dev1.0bin.xyz eggdrop[18352]: Eggdrop v1.10.1+webui (C) 1997 Robey Pointer (C) 1999-2025 Eggheads Development Team
Feb 28 19:36:44 dev1.0bin.xyz eggdrop[18352]: Launched into the background  (pid: 18353)
Feb 28 19:36:44 dev1.0bin.xyz systemd[847]: Started Seeker.service - Seeker (Eggdrop).

### ----------

bots@dev1:~/ptirc/eggdrop/Seeker$ systemctl --user stop Seeker.service 

bots@dev1:~/ptirc/eggdrop/Seeker$ systemctl --user disable Seeker.service 
Removed "/home/bots/.config/systemd/user/default.target.wants/Seeker.service".

bots@dev1:~/ptirc/eggdrop/Seeker$ rm ~/.config/systemd/user/Seeker.service 

### ----------

bots@dev1:~/ptirc/eggdrop/Seeker$ ./scripts/autobotchk seeker.conf -systemd

autobotchk 1.11, (C) 1999-2003 Jeff Fisher (guppy@eggheads.org)
                   (C) 2004-2022 Eggheads Development Team
------------------------------------------------------------

Opening 'seeker.conf' for processing ... done
Scanning the config file .................. done
Enter systemd unit name (without .service) [default: Seeker]: ptirc-seeker
Enabling user lingering...
Creating systemd directory...
Created symlink /home/bots/.config/systemd/user/default.target.wants/ptirc-seeker.service → /home/bots/.config/systemd/user/ptirc-seeker.service.
systemd job successfully installed as 'ptirc-seeker.service'.
* Use 'systemctl --user <start|stop|restart|reload|enable|disable> ptirc-seeker.service' to control your Eggdrop
Starting Eggdrop...
Success.

bots@dev1:~/ptirc/eggdrop/Seeker$ systemctl --user status ptirc-seeker.service 
● ptirc-seeker.service - Seeker (Eggdrop)
     Loaded: loaded (/home/bots/.config/systemd/user/ptirc-seeker.service; enabled; preset: enabled)
     Active: active (running) since Sat 2026-02-28 19:37:51 CET; 9s ago
    Process: 18484 ExecStart=/home/bots/ptirc/eggdrop/Seeker/eggdrop seeker.conf (code=exited, status=0/SUCCESS)
   Main PID: 18485 (eggdrop)
      Tasks: 1 (limit: 3471)
     Memory: 7.6M (peak: 8.6M)
        CPU: 152ms
     CGroup: /user.slice/user-1001.slice/user@1001.service/app.slice/ptirc-seeker.service
             └─18485 /home/bots/ptirc/eggdrop/Seeker/eggdrop seeker.conf

Feb 28 19:37:51 dev1.0bin.xyz eggdrop[18484]: Stats.tcl: Data loaded from stats.dat.
Feb 28 19:37:51 dev1.0bin.xyz eggdrop[18484]: Stats.tcl: HTTPD listening on 0.0.0.0:4001
Feb 28 19:37:51 dev1.0bin.xyz eggdrop[18484]: Stats.tcl v1.0 loaded. Tracking by nick. HTTPD: port 4001.
Feb 28 19:37:51 dev1.0bin.xyz eggdrop[18484]: Userfile loaded, unpacking...
Feb 28 19:37:51 dev1.0bin.xyz eggdrop[18484]: === Seeker: 1 channel, 1 user.
Feb 28 19:37:51 dev1.0bin.xyz eggdrop[18484]: Certificate loaded: eggdrop.crt (sha1 fingerprint 6C:92:9D:17:67:A1:EA:96:17:1C:84:37:F0:94:25:88:C2:DD:D0:C5)
Feb 28 19:37:51 dev1.0bin.xyz eggdrop[18485]: Eggdrop v1.10.1+webui (C) 1997 Robey Pointer (C) 1999-2025 Eggheads Development Team
Feb 28 19:37:51 dev1.0bin.xyz eggdrop[18484]: Eggdrop v1.10.1+webui (C) 1997 Robey Pointer (C) 1999-2025 Eggheads Development Team
Feb 28 19:37:51 dev1.0bin.xyz eggdrop[18484]: Launched into the background  (pid: 18485)
Feb 28 19:37:51 dev1.0bin.xyz systemd[847]: Started ptirc-seeker.service - Seeker (Eggdrop).

bots@dev1:~/ptirc/eggdrop/Seeker$ systemctl --user stop ptirc-seeker.service 

@vanosg vanosg added this to the v1.10.2 milestone Mar 14, 2026
# Prompt for custom unit name
puts -nonewline "Enter systemd unit name (without .service) \[default: ${botnet-nick}\]: "
flush stdout
set input [string trim [gets stdin]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some validation to this, otherwise you allow path traversal (by specifying "../../../"), e.g. a regex enforcing it to be [a-zA-Z0-9_-], I think systemd has restriction on unit names as well

### systemd stuff
if {$systemd} {
# Prompt for custom unit name
puts -nonewline "Enter systemd unit name (without .service) \[default: ${botnet-nick}\]: "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Allow specifying the unit name as a commandline option instead of prompting the user interactively (you can still prompt if not specified of course, this would just be an additional option to skip the interactive prompt)

puts $fd ""
puts $fd "\[Unit\]"
puts $fd "Description=${botnet-nick} (Eggdrop)"
puts $fd "Description=${unitname} (Eggdrop)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably keep the botnet-nick in there as well, just to be more informative, in addition to the unitname

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants