A new pipe_menu for managing services is available.
what's news :
- browse the directory of the selected service
- showing the pid for the service and the associate log directly in the pipe
- showing the status for the service and the associate log directly in the pipe
- disable the service selected and/or the associate log much easier than the old pipe
- edit ALL the file of the selected service directory, same thing for the associate log
- send a signal at the service with many option (usr1, usr2, kill, alarm, interrupt, .....), same thing for the associate log
- viewing the log file with a editor (geany by default)
So just copy and paste this following code in ~/.config/pipe_menu/runit_pipe then
this is the script in bash
what's news :
- browse the directory of the selected service
- showing the pid for the service and the associate log directly in the pipe
- showing the status for the service and the associate log directly in the pipe
- disable the service selected and/or the associate log much easier than the old pipe
- edit ALL the file of the selected service directory, same thing for the associate log
- send a signal at the service with many option (usr1, usr2, kill, alarm, interrupt, .....), same thing for the associate log
- viewing the log file with a editor (geany by default)
So just copy and paste this following code in ~/.config/pipe_menu/runit_pipe then
$ sudo chmod +x ~/.config/pipe_menu/runit_pipe
modify your menu to provide it where you want with, for example, obmenu3.this is the script in bash
# !/bin/sh
# This script is under license BEERWARE
# "THE BEERWARE LICENSE" (Revision 42):
# <eric@ obarun.org> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return. Eric Vidal
# http://obarun.org
#
# Place this to your .config/openbox/menu.xml :
# <menu id="runitcontrol" label="Runit" execute="/path/to/runit_pipe" />
# Don't forget : chmod +x /path/to/runit_pipe
# # Define variables
browser="sudo spacefm"
sv="sudo sv"
path="${1:-/var/service}"
editor="sudo geany"
list=$(ls -H -d --group-directories-first $path/*)
shortname="${1# #*/}"
status="sudo sv status $path"
# # Define pid
status(){
if [[ (("$path" != "/var/service")) && (($(echo "$path" | grep main ) = "")) ]]; then
pid=$($status | awk -F'(' '{ print $2 }' | cut -d')' -f1)
run=$($status | cut -d':' -f1)
echo "<separator label=\"Status : $run\"/>"
if [[ "$run" = "run" ]]; then
echo "<separator label=\"$pid\"/>"
echo "<separator />"
fi
fi
if [[ (("$path" != "/var/service")) && (($(echo "$path" | grep /log) = "")) ]]; then
disable
echo "<separator />"
fi
}
# # Disable a service
disable(){
echo "<item label=\"Disable $shortname\">
<action name=\"Execute\">
<execute>
sudo rm $path
</execute>
</action>
</item>"
}
# # Starting a pipe_menu in xml
start_pipe(){
echo "<openbox_pipe_menu>"
}
# # Ending a pipe_menu in xml
end_pipe(){
echo "</openbox_pipe_menu>"
}
# # Browsing here
head(){
echo "<item label=\"Browse here..\">
<action name=\"Execute\">
<execute>
$browser $path
</execute>
</action>
</item>
<separator />"
}
# # Launch editor
menu_editor(){
echo "<item label=\"$shortname\">
<action name=\"Execute\">
<execute>
$editor $path/$shortname
</execute>
</action>
</item>"
}
# # Viewing log
menu_log(){
shortname=$(echo "$path" | cut -d'/' -f4)
echo "<item label=\"View log\">
<action name=\"Execute\">
<execute>
$editor /var/log/$shortname/current
</execute>
</action>
</item>
<separator />"
}
# # Manage services
control(){
echo "<separator />"
echo "<item label=\"up\">
<action name=\"Execute\">
<execute>
$sv up $path
</execute>
</action>
</item>
<item label=\"down\">
<action name=\"Execute\">
<execute>
$sv down $path
</execute>
</action>
</item>
<item label=\"once\">
<action name=\"Execute\">
<execute>
$sv once $path
</execute>
</action>
</item>
<item label=\"hup\">
<action name=\"Execute\">
<execute>
$sv hup $path
</execute>
</action>
</item>
<item label=\"exit\">
<action name=\"Execute\">
<execute>
$sv exit $path
</execute>
</action>
</item>
<item label=\"kill\">
<action name=\"Execute\">
<execute>
$sv kill $path
</execute>
</action>
</item>
<menu id=\"control\" label=\"More Signal\">
<item label=\"pause\">
<action name=\"Execute\">
<execute>
$sv pause $path
</execute>
</action>
</item>
<item label=\"cont\">
<action name=\"Execute\">
<execute>
$sv cont $path
</execute>
</action>
</item>
<item label=\"alarm\">
<action name=\"Execute\">
<execute>
$sv alarm $path
</execute>
</action>
</item>
<item label=\"interrupt\">
<action name=\"Execute\">
<execute>
$sv interrupt $path
</execute>
</action>
</item>
<item label=\"quit\">
<action name=\"Execute\">
<execute>
$sv quit $path
</execute>
</action>
</item>
<item label=\"USR1\">
<action name=\"Execute\">
<execute>
$sv 1 $path
</execute>
</action>
</item>
<item label=\"USR2\">
<action name=\"Execute\">
<execute>
$sv 2 $path
</execute>
</action>
</item>
<item label=\"term\">
<action name=\"Execute\">
<execute>
$sv term $path
</execute>
</action>
</item>
<item label=\"force-reload\">
<action name=\"Execute\">
<execute>
$sv force-reload $path
</execute>
</action>
</item>
<item label=\"force-restart\">
<action name=\"Execute\">
<execute>
$sv force-restart $path
</execute>
</action>
</item>
<item label=\"force-shutdown\">
<action name=\"Execute\">
<execute>
$sv force-shutdown $path
</execute>
</action>
</item>
</menu>"
}
# # Read directories
check_path(){
if [[ "$shortname" != "supervise" ]]; then
if [[ -d "$i" ]]; then
echo "<menu id=\"$path/$shortname\" label=\"$shortname\" execute=\"$0 $path/$shortname\" />"
else
menu_editor
fi
fi
}
# ################ Menu for service started # ##########
menu_started(){
# # Browser
head
# # Status of the service
status
# # Display menu for log
if [[ (($(echo "$path" | grep log) != "")) && (($(echo "$path" | grep socklog ) = "")) ]]; then
menu_log
fi
# # Check directories
for i in $list; do
shortname="${i# #*/}"
check_path
done
# # Display menu
if [[ $(echo "$path" | grep /var/service/) ]]; then
if [[ $(echo "$path" | grep main ) = "" ]]; then
control
fi
fi
}
# ############# Menu for service available # ########
menu_available(){
path="/etc/sv"
head
for i in $path/*; do
shortname="${i# #*/}"
if [[ -d "$i" ]]; then
echo "<menu id=\"$shortname\" label=\"$shortname\">
<item label=\"Enable\">
<action name=\"Execute\">
<execute>
sudo ln -sf $path/$shortname /var/service
</execute>
</action>
</item>
</menu>"
fi
done
}
# ############# let's go # ##################
if [[ "$path" = "/var/service" ]]; then
start_pipe
echo "<menu id=\"started\" label=\"Started\">"
menu_started
echo "</menu>"
echo "<menu id=\"available\" label=\"Available\">"
menu_available
echo "</menu>"
end_pipe
else
start_pipe
menu_started
end_pipe
fi
enjoy it :)