Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
95ebba50e3
|
|||
0506889700
|
|||
59d2325f73
|
|||
0477798c9e
|
|||
750cde1aa1
|
|||
16f8b86d1b
|
|||
3bd632a39b
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
- Terminal Commands are exactly the same as sv, but produces a beautified layout.
|
- Terminal Commands are exactly the same as sv, but produces a beautified layout.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Manage and view runit services.
|
## Manage and view runit services.
|
||||||
|
|
||||||
@@ -21,6 +21,8 @@ Quick Examples:
|
|||||||
- `rsm enable <svc>` - enable a service (autostart at boot)
|
- `rsm enable <svc>` - enable a service (autostart at boot)
|
||||||
- `rsm disable <svc>` - disable a service (no autostart at boot)
|
- `rsm disable <svc>` - disable a service (no autostart at boot)
|
||||||
- `rsm hup <svc>` - refresh a service (`SIGHUP`)
|
- `rsm hup <svc>` - refresh a service (`SIGHUP`)
|
||||||
|
- `rsm logs <svc>` or `rsm alllogs <svc>` - lists all logs for a service (access and error)
|
||||||
|
- `rsm errorlogs <svc>` - lists all error logs for a service
|
||||||
|
|
||||||
Status:
|
Status:
|
||||||
|
|
||||||
|
85
rsm
85
rsm
@@ -9,9 +9,11 @@
|
|||||||
# Date: August 29, 2018
|
# Date: August 29, 2018
|
||||||
# License: MIT
|
# License: MIT
|
||||||
|
|
||||||
RSM_VERSION='v1.4.0'
|
RSM_VERSION='v1.4.5'
|
||||||
|
|
||||||
export SVDIR=${SVDIR:-/run/runit/service/}
|
export SVDIR=${SVDIR:-/run/runit/service/}
|
||||||
|
export LOGDIR="/var/log/"
|
||||||
|
export RSVDIR="/run/runit/service/"
|
||||||
export FLDIR=${FLDIR:-/etc/runit/sv/}
|
export FLDIR=${FLDIR:-/etc/runit/sv/}
|
||||||
|
|
||||||
|
|
||||||
@@ -136,7 +138,7 @@ $progname [-u] [-d <dir>] [-h] [-t] [SUBCOMMAND] [...]
|
|||||||
|
|
||||||
${coloryellow}OPTIONS:${colorgreen}
|
${coloryellow}OPTIONS:${colorgreen}
|
||||||
${colorgreen}-c <yes|no|auto> $cr Enable/disable color output, defaults to auto
|
${colorgreen}-c <yes|no|auto> $cr Enable/disable color output, defaults to auto
|
||||||
${colorgreen}-d <dir> $cr Directory to look into, defaults to env SVDIR or /var/service if unset
|
${colorgreen}-d <dir> $cr Directory to look into, defaults to env SVDIR or /run/runit/service is unset
|
||||||
${colorgreen}-h $cr Print this message and exit
|
${colorgreen}-h $cr Print this message and exit
|
||||||
${colorgreen}-l $cr Show log processes, this is a shortcut for 'status -l'
|
${colorgreen}-l $cr Show log processes, this is a shortcut for 'status -l'
|
||||||
${colorgreen}-t $cr Tree view, this is a shortcut for 'status -t'
|
${colorgreen}-t $cr Tree view, this is a shortcut for 'status -t'
|
||||||
@@ -166,6 +168,10 @@ ${colorgreen}start <service> $cr Start the service
|
|||||||
${colorgreen}stop <service> $cr Stop the service
|
${colorgreen}stop <service> $cr Stop the service
|
||||||
${colorgreen}restart <service> $cr Restart the service
|
${colorgreen}restart <service> $cr Restart the service
|
||||||
${colorgreen}reload <service> $cr Reload the service (send SIGHUP)
|
${colorgreen}reload <service> $cr Reload the service (send SIGHUP)
|
||||||
|
${colorgreen}logs <service> $cr Outputs the service's logfilenames and their access & error logs from /var/log/<serice>/
|
||||||
|
${colorgreen}alllogs <service> $cr The same like logs <service>
|
||||||
|
${colorgreen}errorlogs <service> $cr Outputs the service's logfilenames and their errorlogs from /var/log/<serice>/
|
||||||
|
|
||||||
|
|
||||||
${coloryellow}EXAMPLES:${colorgreen}
|
${coloryellow}EXAMPLES:${colorgreen}
|
||||||
${colorgreen}$progname $cr Show service status in /var/service
|
${colorgreen}$progname $cr Show service status in /var/service
|
||||||
@@ -385,7 +391,9 @@ do_status() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $filter && $svc != *"$filter"* ]]; then
|
if [[ -n $filter && $svc != *"$filter"* ]]; then
|
||||||
verbose "filtering out '$svc' because match '$filter'"
|
if [[ $verbosity != 1 ]]; then
|
||||||
|
verbose "filtering out '$svc' because it does not match '$filter'"
|
||||||
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -470,6 +478,7 @@ do_enable_disable() {
|
|||||||
ret=1
|
ret=1
|
||||||
else
|
else
|
||||||
ln -s ${FLDIR}${svc} ${SVDIR}
|
ln -s ${FLDIR}${svc} ${SVDIR}
|
||||||
|
do_status
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
disable)
|
disable)
|
||||||
@@ -479,6 +488,7 @@ do_enable_disable() {
|
|||||||
ret=1
|
ret=1
|
||||||
else
|
else
|
||||||
unlink ${SVDIR}${svc}
|
unlink ${SVDIR}${svc}
|
||||||
|
do_status
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -494,8 +504,6 @@ do_enable_disable() {
|
|||||||
|
|
||||||
# show logs
|
# show logs
|
||||||
do_show_logs() {
|
do_show_logs() {
|
||||||
local LOGDIR="/var/log/"
|
|
||||||
monitors_array=($(xrandr -q))
|
|
||||||
local cmd=$1
|
local cmd=$1
|
||||||
local svc
|
local svc
|
||||||
local ret=0
|
local ret=0
|
||||||
@@ -513,22 +521,29 @@ do_show_logs() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if ! [[ -d ${SVDIR}${cmd} ]]; then
|
|
||||||
printf "\n%20s\n" "${colorgreen}The following log files found:"
|
if [[ -f "${RSVDIR}${cmd}" ]]; then
|
||||||
local logs_files_array=($(ls /var/log/$cmd/*.*))
|
if ! [[ -d ${RSVDIR}${cmd} ]]; then
|
||||||
printf "\n$colorblue"
|
printf "\n%20s\n" "${colorgreen}The following log files found:"
|
||||||
printf '%s\n' "${logs_files_array[@]}"
|
local logs_files_array=($(ls /var/log/$cmd/*.*))
|
||||||
|
printf "\n$colorblue"
|
||||||
|
printf '%s\n' "${logs_files_array[@]}"
|
||||||
|
|
||||||
printf "\n$colormagenta"
|
printf "\n$colormagenta"
|
||||||
read -n 1 -s -r -p "Press any key to continue"
|
read -n 1 -s -r -p "Press any key to continue"
|
||||||
|
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "\n${colorcyan}Log files full output:\n"
|
printf "\n${colorcyan}Log files full output:\n"
|
||||||
printf "${coloryellow}\n"
|
printf "${coloryellow}\n"
|
||||||
printf "${coloryellow}${opt}"
|
printf "${coloryellow}${opt}"
|
||||||
|
|
||||||
tail -n 10 ${LOGDIR}${cmd}/*.* | more
|
tail -n 10 ${LOGDIR}${cmd}/*.* | more
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ -f "${RSVDIR}${cmd}" ]]; then
|
||||||
|
printf "\n%20s\n" "${colorred}The service's ${cmd} log files have not been found or do not exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rmsg "$ret" "[$progname $cmd $*], exit code: $ret"
|
rmsg "$ret" "[$progname $cmd $*], exit code: $ret"
|
||||||
@@ -537,8 +552,6 @@ do_show_logs() {
|
|||||||
|
|
||||||
# show error logs
|
# show error logs
|
||||||
do_show_err_logs() {
|
do_show_err_logs() {
|
||||||
local LOGDIR="/var/log/"
|
|
||||||
monitors_array=($(xrandr -q))
|
|
||||||
local cmd=$1
|
local cmd=$1
|
||||||
local svc
|
local svc
|
||||||
local ret=0
|
local ret=0
|
||||||
@@ -556,22 +569,28 @@ do_show_err_logs() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if ! [[ -d ${SVDIR}${cmd} ]]; then
|
if [[ -f "${RSVDIR}${cmd}" ]]; then
|
||||||
printf "\n%20s\n" "${colorgreen}The following log files found:"
|
if ! [[ -d ${RSVDIR}${cmd} ]]; then
|
||||||
local logs_files_array=($(ls /var/log/$cmd/*.*))
|
printf "\n%20s\n" "${colorred}The following error log files found:"
|
||||||
printf "\n$colorblue"
|
local logs_files_array=($(ls /var/log/$cmd/*error*.*))
|
||||||
printf '%s\n' "${logs_files_array[@]}"
|
printf "\n$colorblue"
|
||||||
|
printf '%s\n' "${logs_files_array[@]}"
|
||||||
|
|
||||||
printf "\n$colormagenta"
|
printf "\n$colormagenta"
|
||||||
read -n 1 -s -r -p "Press any key to continue"
|
read -n 1 -s -r -p "Press any key to continue"
|
||||||
|
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "\n${colorcyan}Log files full output:\n"
|
printf "\n${colorcyan}Log files full output:\n"
|
||||||
printf "${coloryellow}\n"
|
printf "${coloryellow}\n"
|
||||||
printf "${coloryellow}${opt}"
|
printf "${coloryellow}${opt}"
|
||||||
|
|
||||||
tail -n 10 ${LOGDIR}${cmd}/*error*.* | more
|
tail -n 10 ${LOGDIR}${cmd}/*error*.* | more
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ -f "${RSVDIR}${cmd}" ]]; then
|
||||||
|
printf "\n%20s\n" "${colorred}The service's ${cmd} error log files have not been found or do not exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rmsg "$ret" "[$progname $cmd $*], exit code: $ret"
|
rmsg "$ret" "[$progname $cmd $*], exit code: $ret"
|
||||||
|
Reference in New Issue
Block a user